-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
154 changed files
with
368 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,26 +16,29 @@ jobs: | |
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
env: | ||
IMG: tests.com/coralogix-operator:v0.0.1 | ||
CORALOGIX_REGION: ${{ secrets.CORALOGIX_REGION }} | ||
CORALOGIX_API_KEY: ${{ secrets.CORALOGIX_API_KEY }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Build the controller-manager Docker image | ||
run: | | ||
make docker-build | ||
- name: Create k8s Kind Cluster | ||
uses: helm/[email protected] | ||
- name: Install kuttl | ||
- name: Load the controller-manager image into Kind | ||
run: | | ||
curl -Lo /usr/local/bin/kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v0.12.1/kubectl-kuttl_0.12.1_linux_x86_64 | ||
chmod +x /usr/local/bin/kubectl-kuttl | ||
kind load docker-image ${{ env.IMG }} --name chart-testing | ||
- name: Install CRDs | ||
run: make install | ||
- name: Install Go | ||
uses: actions/setup-go@37335c7bb261b353407cff977110895fa0b4f7d8 | ||
with: | ||
go-version: 1.22.x | ||
- name: Running operator and Tests | ||
- name: Deploy the controller-manager | ||
run: | | ||
make deploy | ||
- name: Run e2e Tests | ||
env: | ||
CORALOGIX_REGION: ${{ secrets.CORALOGIX_REGION }} | ||
CORALOGIX_API_KEY: ${{ secrets.CORALOGIX_API_KEY }} | ||
run: | | ||
go run -ldflags="-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn" main.go & | ||
sleep 30s | ||
make e2e | ||
make e2e-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: integration-tests | ||
on: | ||
schedule: | ||
- cron: 0 0 * * * | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "charts/**" | ||
pull_request: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "charts/**" | ||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Create k8s Kind Cluster | ||
uses: helm/[email protected] | ||
- name: Install kuttl | ||
run: | | ||
curl -Lo /usr/local/bin/kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v0.12.1/kubectl-kuttl_0.12.1_linux_x86_64 | ||
chmod +x /usr/local/bin/kubectl-kuttl | ||
- name: Install CRDs | ||
run: make install | ||
- name: Install Go | ||
uses: actions/setup-go@37335c7bb261b353407cff977110895fa0b4f7d8 | ||
with: | ||
go-version: 1.22.x | ||
- name: Running operator and Tests | ||
env: | ||
CORALOGIX_REGION: ${{ secrets.CORALOGIX_REGION }} | ||
CORALOGIX_API_KEY: ${{ secrets.CORALOGIX_API_KEY }} | ||
run: | | ||
go run -ldflags="-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn" main.go & | ||
sleep 30s | ||
make integration-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: unit | ||
name: unit-tests | ||
on: | ||
pull_request: | ||
paths-ignore: | ||
|
@@ -21,7 +21,7 @@ jobs: | |
uses: helm/[email protected] | ||
- name: Install CRDs | ||
run: make install | ||
- run: make test | ||
- run: make unit-tests | ||
- name: Patch Coverage | ||
uses: seriousben/go-patch-cover-action@v1 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestSuite | ||
testDirs: | ||
- tests/e2e/alerts | ||
- tests/e2e/rulegroups | ||
- tests/e2e/recordingrulegroupsets | ||
- tests/e2e/prometheusrules | ||
- tests/e2e/outboundwebhooks | ||
- tests/e2e/alertmangerconfigs | ||
- tests/integration/alerts | ||
- tests/integration/rulegroups | ||
- tests/integration/recordingrulegroupsets | ||
- tests/integration/prometheusrules | ||
- tests/integration/outboundwebhooks | ||
- tests/integration/alertmangerconfigs | ||
namespace: default | ||
timeout: 60 | ||
timeout: 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
Copyright 2024. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
prometheus "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" | ||
"k8s.io/client-go/kubernetes" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
|
||
cxsdk "github.com/coralogix/coralogix-management-sdk/go" | ||
|
||
coralogixv1alpha1 "github.com/coralogix/coralogix-operator/apis/coralogix/v1alpha1" | ||
) | ||
|
||
var ClientsInstance = &Clients{} | ||
|
||
type Clients struct { | ||
CxClientSet *cxsdk.ClientSet | ||
CrClient client.Client | ||
K8sClient *kubernetes.Clientset | ||
} | ||
|
||
func (c *Clients) InitCoralogixClientSet(targetURL, teamsLevelAPIKey string, userLevelAPIKey string) { | ||
if c.CxClientSet == nil { | ||
c.CxClientSet = cxsdk.NewClientSet(targetURL, teamsLevelAPIKey, userLevelAPIKey) | ||
} | ||
} | ||
|
||
func (c *Clients) InitControllerRuntimeClient() error { | ||
if c.CrClient == nil { | ||
crClient, err := client.New(config.GetConfigOrDie(), client.Options{}) | ||
if err != nil { | ||
return err | ||
} | ||
if err = prometheus.AddToScheme(crClient.Scheme()); err != nil { | ||
return err | ||
} | ||
if err = coralogixv1alpha1.AddToScheme(crClient.Scheme()); err != nil { | ||
return err | ||
} | ||
c.CrClient = crClient | ||
} | ||
return nil | ||
} | ||
|
||
func (c *Clients) InitK8sClient() error { | ||
if c.K8sClient == nil { | ||
k8sClient, err := kubernetes.NewForConfig(config.GetConfigOrDie()) | ||
if err != nil { | ||
return err | ||
} | ||
c.K8sClient = k8sClient | ||
} | ||
return nil | ||
} | ||
|
||
func (c *Clients) GetCoralogixClientSet() *cxsdk.ClientSet { | ||
return c.CxClientSet | ||
} | ||
|
||
func (c *Clients) GetControllerRuntimeClient() client.Client { | ||
return c.CrClient | ||
} | ||
|
||
func (c *Clients) GetK8sClient() *kubernetes.Clientset { | ||
return c.K8sClient | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2024. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
cxsdk "github.com/coralogix/coralogix-management-sdk/go" | ||
) | ||
|
||
func TestE2E(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Coralogix operator E2E test suite") | ||
} | ||
|
||
var _ = BeforeSuite(func(ctx context.Context) { | ||
region := strings.ToLower(os.Getenv("CORALOGIX_REGION")) | ||
apiKey := os.Getenv("CORALOGIX_API_KEY") | ||
|
||
By("Initializing clients") | ||
ClientsInstance.InitCoralogixClientSet(cxsdk.CoralogixGrpcEndpointFromRegion(region), apiKey, apiKey) | ||
Expect(ClientsInstance.InitControllerRuntimeClient()).To(Succeed()) | ||
Expect(ClientsInstance.InitK8sClient()).To(Succeed()) | ||
|
||
By("Validating that the controller-manager pod is running") | ||
Eventually(func() corev1.PodPhase { | ||
k8sClient := ClientsInstance.GetK8sClient() | ||
podList, err := k8sClient.CoreV1(). | ||
Pods("coralogix-operator-system"). | ||
List(ctx, metav1.ListOptions{LabelSelector: "control-plane=controller-manager"}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
return podList.Items[0].Status.Phase | ||
}, time.Minute, time.Second).Should(Equal(corev1.PodRunning)) | ||
}) |
Oops, something went wrong.