|
| 1 | +/* |
| 2 | +Copyright 2024. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package e2e |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + "os" |
| 22 | + "strings" |
| 23 | + "testing" |
| 24 | + "time" |
| 25 | + |
| 26 | + . "github.com/onsi/ginkgo/v2" |
| 27 | + . "github.com/onsi/gomega" |
| 28 | + corev1 "k8s.io/api/core/v1" |
| 29 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 30 | + |
| 31 | + cxsdk "github.com/coralogix/coralogix-management-sdk/go" |
| 32 | +) |
| 33 | + |
| 34 | +func TestE2E(t *testing.T) { |
| 35 | + RegisterFailHandler(Fail) |
| 36 | + RunSpecs(t, "Coralogix operator E2E test suite") |
| 37 | +} |
| 38 | + |
| 39 | +var _ = BeforeSuite(func(ctx context.Context) { |
| 40 | + region := strings.ToLower(os.Getenv("CORALOGIX_REGION")) |
| 41 | + apiKey := os.Getenv("CORALOGIX_API_KEY") |
| 42 | + |
| 43 | + By("Initializing clients") |
| 44 | + ClientsInstance.InitCoralogixClientSet(cxsdk.CoralogixGrpcEndpointFromRegion(region), apiKey, apiKey) |
| 45 | + Expect(ClientsInstance.InitControllerRuntimeClient()).To(Succeed()) |
| 46 | + Expect(ClientsInstance.InitK8sClient()).To(Succeed()) |
| 47 | + |
| 48 | + By("Validating that the controller-manager pod is running") |
| 49 | + Eventually(func() corev1.PodPhase { |
| 50 | + k8sClient := ClientsInstance.GetK8sClient() |
| 51 | + podList, err := k8sClient.CoreV1(). |
| 52 | + Pods("coralogix-operator-system"). |
| 53 | + List(ctx, metav1.ListOptions{LabelSelector: "control-plane=controller-manager"}) |
| 54 | + Expect(err).NotTo(HaveOccurred()) |
| 55 | + return podList.Items[0].Status.Phase |
| 56 | + }, time.Minute, time.Second).Should(Equal(corev1.PodRunning)) |
| 57 | +}) |
0 commit comments