diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4435bc6..ee23f457 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,15 +20,38 @@ jobs: uses: actions/setup-go@v2 with: go-version: '1.19.8' + cache: true - name: Checkout the repo uses: actions/checkout@v2 + - name: Start minikube + id: minikube + uses: medyagh/setup-minikube@master + with: + cpus: 2 + memory: 4g + - name: Check generate files run: make generate-deploy && make bundle && git status && git diff-index --quiet HEAD -- + - name: Build the image + run: | + podman build --build-arg TARGETOS=linux --build-arg TARGETARCH=amd64 --label quay.expires-after=90d --label git-sha=$GITHUB_SHA --no-cache --platform linux/amd64 --manifest $IMAGE_NAME:dev.latest . + + - name: Push the image into minikube + run: | + export SHELL=/bin/bash + eval $(minikube -p minikube docker-env) + docker image list + export OPERATOR_IMAGE=$(grep -Po '(?<=image: ).*' ./deploy/operator.yaml) + podman tag $IMAGE_NAME:dev.latest $OPERATOR_IMAGE + podman save --output activemq-artemis-operator-image.tar --format docker-archive $OPERATOR_IMAGE + docker image load --input activemq-artemis-operator-image.tar + docker image list + - name: Execute the tests - run: make test + run: make test-mk-do-fast-v - name: Set up Node.js uses: actions/setup-node@v2 @@ -49,12 +72,13 @@ jobs: npm install && npm run build - name: Set up QEMU + if: ${{ github.event_name == 'push' }} uses: docker/setup-qemu-action@v1 - - name: Build the image + - name: Build the image for arm64 + if: ${{ github.event_name == 'push' }} run: | - podman build --build-arg TARGETOS=linux --build-arg TARGETARCH=amd64 --label quay.expires-after=90d --label git-sha=$GITHUB_SHA --no-cache --platform linux/amd64 --manifest $IMAGE_NAME:dev.latest . - #podman build --build-arg TARGETOS=linux --build-arg TARGETARCH=arm64 --label quay.expires-after=90d --label git-sha=$GITHUB_SHA --no-cache --platform linux/arm64 --manifest $IMAGE_NAME:dev.latest . + podman build --build-arg TARGETOS=linux --build-arg TARGETARCH=arm64 --label quay.expires-after=90d --label git-sha=$GITHUB_SHA --no-cache --platform linux/arm64 --manifest $IMAGE_NAME:dev.latest . - name: Push the dev image if: ${{ github.event_name == 'push' }} diff --git a/Makefile b/Makefile index 5457d601..1fd5489d 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ test-mk-do-fast test-mk-do-fast-v: TEST_ARGS += -test.timeout=40m -ginkgo.label- test-mk-do-fast test-mk-do-fast-v: TEST_VARS = DEPLOY_OPERATOR=true ENABLE_WEBHOOKS=false USE_EXISTING_CLUSTER=true test-v test-mk-v test-mk-do-v test-mk-do-fast-v: TEST_ARGS += -v -test-v test-mk test-mk-v test-mk-do test-mk-do-v test-mk-do-fast test-mk-do-fast-v: TEST_ARGS += -ginkgo.slow-spec-threshold=30s -ginkgo.fail-fast -coverprofile cover-mk.out +test-v test-mk test-mk-v test-mk-do test-mk-do-v test-mk-do-fast test-mk-do-fast-v: TEST_ARGS += -ginkgo.poll-progress-after=30s -ginkgo.fail-fast -coverprofile cover-mk.out test test-v test-mk test-mk-v test-mk-do test-mk-do-v test-mk-do-fast test-mk-do-fast-v: manifests generate fmt vet envtest $(TEST_VARS) go test ./... -p 1 $(TEST_ARGS) $(TEST_EXTRA_ARGS) diff --git a/controllers/activemqartemis_controller_deploy_operator_test.go b/controllers/activemqartemis_controller_deploy_operator_test.go index d590503c..8638181f 100644 --- a/controllers/activemqartemis_controller_deploy_operator_test.go +++ b/controllers/activemqartemis_controller_deploy_operator_test.go @@ -36,6 +36,10 @@ var _ = Describe("artemis controller", Label("do"), func() { BeforeEachSpec() }) + AfterEach(func() { + AfterEachSpec() + }) + Context("tls jolokia access", Label("do-secure-console-with-sni"), func() { It("check the util works in test env", func() { domainName := common.GetClusterDomain() diff --git a/controllers/activemqartemis_controller_test.go b/controllers/activemqartemis_controller_test.go index ad9710b8..4fce88df 100644 --- a/controllers/activemqartemis_controller_test.go +++ b/controllers/activemqartemis_controller_test.go @@ -122,6 +122,8 @@ var _ = Describe("artemis controller", func() { for e := wis.Front(); e != nil; e = e.Next() { e.Value.(watch.Interface).Stop() } + + AfterEachSpec() }) Context("tls secret reuse", Label("tls-secret-reuse"), func() { diff --git a/controllers/activemqartemis_pub_sub_scale_test.go b/controllers/activemqartemis_pub_sub_scale_test.go index 36ce9daa..0e62d93f 100644 --- a/controllers/activemqartemis_pub_sub_scale_test.go +++ b/controllers/activemqartemis_pub_sub_scale_test.go @@ -48,6 +48,10 @@ var _ = Describe("pub sub scale", func() { BeforeEachSpec() }) + AfterEach(func() { + AfterEachSpec() + }) + Context("pub n sub, ha pub, partitioned sub", Label("slow"), func() { It("validation", func() { if os.Getenv("USE_EXISTING_CLUSTER") == "true" { diff --git a/controllers/activemqartemis_scale_zero_test.go b/controllers/activemqartemis_scale_zero_test.go index 80640c90..522aa353 100644 --- a/controllers/activemqartemis_scale_zero_test.go +++ b/controllers/activemqartemis_scale_zero_test.go @@ -46,6 +46,10 @@ var _ = Describe("subresource scale down", func() { BeforeEachSpec() }) + AfterEach(func() { + AfterEachSpec() + }) + Context("scale to zero via scale subresource", func() { It("deploy plan 1", func() { if os.Getenv("USE_EXISTING_CLUSTER") == "true" { diff --git a/controllers/activemqartemisaddress_controller_deploy_operator_test.go b/controllers/activemqartemisaddress_controller_deploy_operator_test.go index e7d41b3a..74bdb59c 100644 --- a/controllers/activemqartemisaddress_controller_deploy_operator_test.go +++ b/controllers/activemqartemisaddress_controller_deploy_operator_test.go @@ -54,6 +54,10 @@ var _ = Describe("Address controller DO", Label("do"), func() { BeforeEachSpec() }) + AfterEach(func() { + AfterEachSpec() + }) + Context("Address test", func() { It("Deploy CR with size 5 (pods)", Label("slow"), func() { diff --git a/controllers/activemqartemisaddress_controller_test.go b/controllers/activemqartemisaddress_controller_test.go index 9fd076c9..97e38751 100644 --- a/controllers/activemqartemisaddress_controller_test.go +++ b/controllers/activemqartemisaddress_controller_test.go @@ -53,6 +53,10 @@ var _ = Describe("Address controller tests", func() { BeforeEachSpec() }) + AfterEach(func() { + AfterEachSpec() + }) + Context("address queue config defaults", Label("queue-config-defaults"), func() { if os.Getenv("USE_EXISTING_CLUSTER") == "true" { queueName := "myqueue" diff --git a/controllers/activemqartemisscaledown_controller_test.go b/controllers/activemqartemisscaledown_controller_test.go index a40fd5fd..6a2ede62 100644 --- a/controllers/activemqartemisscaledown_controller_test.go +++ b/controllers/activemqartemisscaledown_controller_test.go @@ -44,6 +44,10 @@ var _ = Describe("Scale down controller", func() { BeforeEachSpec() }) + AfterEach(func() { + AfterEachSpec() + }) + Context("Scale down test", func() { It("deploy plan 2 clustered", Label("basic-scaledown-check"), func() { diff --git a/controllers/activemqartemissecurity_controller_test.go b/controllers/activemqartemissecurity_controller_test.go index 8c32b0ad..9768cc08 100644 --- a/controllers/activemqartemissecurity_controller_test.go +++ b/controllers/activemqartemissecurity_controller_test.go @@ -61,6 +61,7 @@ var _ = Describe("security controller", func() { }) AfterEach(func() { + AfterEachSpec() }) Context("broker with security custom resources", Label("broker-security-res"), func() { diff --git a/controllers/common_util_test.go b/controllers/common_util_test.go index def2ec3c..9f00b8e9 100644 --- a/controllers/common_util_test.go +++ b/controllers/common_util_test.go @@ -186,13 +186,13 @@ func newArtemisSpecWithFastProbes() brokerv1beta1.ActiveMQArtemisSpec { spec := brokerv1beta1.ActiveMQArtemisSpec{} // sensible fast defaults for tests against existing cluster - spec.DeploymentPlan.LivenessProbe = &corev1.Probe{ - InitialDelaySeconds: 1, - PeriodSeconds: 2, - } spec.DeploymentPlan.ReadinessProbe = &corev1.Probe{ InitialDelaySeconds: 1, - PeriodSeconds: 2, + PeriodSeconds: 3, + } + spec.DeploymentPlan.LivenessProbe = &corev1.Probe{ + InitialDelaySeconds: 6, + PeriodSeconds: 3, } return spec @@ -436,6 +436,23 @@ func RunCommandInPod(podName string, containerName string, command []string) (*s return &content, nil } +func EventsOfPod(podWithOrdinal string, namespace string, g Gomega) *corev1.EventList { + + cfg, err := config.GetConfig() + g.Expect(err).To(BeNil()) + + clientset, err := kubernetes.NewForConfig(cfg) + g.Expect(err).To(BeNil()) + + events, err := clientset.CoreV1().Events(namespace).List(context.TODO(), metav1.ListOptions{ + FieldSelector: "involvedObject.name=" + podWithOrdinal, + TypeMeta: metav1.TypeMeta{Kind: "Pod"}, + }) + g.Expect(err).To(BeNil()) + + return events +} + func LogsOfPod(podWithOrdinal string, brokerName string, namespace string, g Gomega) string { gvk := schema.GroupVersionKind{ diff --git a/controllers/controllermanager_test.go b/controllers/controllermanager_test.go index 6db17854..d5e6dec5 100644 --- a/controllers/controllermanager_test.go +++ b/controllers/controllermanager_test.go @@ -39,6 +39,10 @@ var _ = Describe("tests regarding controller manager", func() { BeforeEachSpec() }) + AfterEach(func() { + AfterEachSpec() + }) + Context("operator namespaces test", func() { It("test resolving watching namespace", func() { diff --git a/controllers/suite_test.go b/controllers/suite_test.go index f5cfd5f4..23a10224 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -687,10 +687,15 @@ func BeforeEachSpec() { specCount++ //Print running spec - fmt.Println("\n\033[32mRunning Spec " + - strconv.FormatInt(specCount, 10) + ": " + - CurrentSpecReport().FullText() + " " + - "\033[33m[" + CurrentSpecShortName() + "]\033[0m\n" + - CurrentSpecReport().LeafNodeLocation.FileName + ":" + - strconv.Itoa(CurrentSpecReport().LeafNodeLocation.LineNumber)) + currentSpecReport := CurrentSpecReport() + fmt.Printf("\n\033[1m\033[32mSpec %d running: %s \033[33m[%s]\033[0m\n%s:%d", + specCount, currentSpecReport.FullText(), CurrentSpecShortName(), + currentSpecReport.LeafNodeLocation.FileName, currentSpecReport.LeafNodeLocation.LineNumber) +} + +func AfterEachSpec() { + //Print ran spec + currentSpecReport := CurrentSpecReport() + fmt.Printf("\n\033[1m\033[32mSpec %d ran in %f seconds \033[0m\n", + specCount, currentSpecReport.RunTime.Seconds()) }