From d3564a8392a2ba9e4c5b2e50ba17968dc60b94ec Mon Sep 17 00:00:00 2001 From: Dillen Padhiar Date: Thu, 19 Sep 2024 11:07:53 -0700 Subject: [PATCH 1/8] test: capture resource changes and output as artifacts Signed-off-by: Dillen Padhiar --- .github/workflows/ci.yaml | 11 +++- Makefile | 5 +- tests/e2e/common.go | 19 ++++++- tests/e2e/functional_test.go | 21 ++++++++ tests/e2e/isbservice.go | 94 ++++++++++++++++++++++++++++++++ tests/e2e/monovertex.go | 95 ++++++++++++++++++++++++++++++++ tests/e2e/numaflowcontroller.go | 49 +++++++++++++++++ tests/e2e/pipeline.go | 96 +++++++++++++++++++++++++++++++++ tests/e2e/suite_test.go | 13 +++-- 9 files changed, 395 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 32fbd150..af3353bc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -167,6 +167,15 @@ jobs: with: name: controller-logs-${{matrix.datalossprevention}} path: | - tests/e2e/output/ + tests/e2e/output/controllers/ + retention-days: 7 + + - name: Archive resource changes + uses: actions/upload-artifact@v4 + if: always() + with: + name: resource-changes-${{matrix.datalossprevention}} + path: | + tests/e2e/output/resources/ retention-days: 7 \ No newline at end of file diff --git a/Makefile b/Makefile index 3095450a..4e12a651 100644 --- a/Makefile +++ b/Makefile @@ -115,9 +115,12 @@ test: codegen fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -p 1 -race -short -v $$(go list ./... | grep -v /tests/e2e) .PHONY: test-e2e -test-e2e: codegen fmt vet envtest ## Run e2e tests. +test-e2e: cleanup-e2e codegen fmt vet envtest ## Run e2e tests. GOFLAGS="-count=1" go test -v ./tests/e2e/... +.PHONY: cleanup-e2e +cleanup-e2e: + rm -r -f tests/e2e/output GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint diff --git a/tests/e2e/common.go b/tests/e2e/common.go index ef8ff968..90063624 100644 --- a/tests/e2e/common.go +++ b/tests/e2e/common.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "sync" "time" . "github.com/onsi/ginkgo/v2" @@ -39,19 +40,33 @@ var ( monoVertexRolloutClient planepkg.MonoVertexRolloutInterface kubeClient clientgo.Interface + wg sync.WaitGroup + stopCh chan struct{} + dataLossPrevention string ) const ( Namespace = "numaplane-system" - NumaplaneCtrlLogs = "output/numaplane-controller.log" - NumaflowCtrlLogs = "output/numaflow-controller.log" + ControllerOutputPath = "output/controllers" + ResourceChangesOutputPath = "output/resources" + + NumaplaneAPIVersion = "numaplane.numaproj.io/v1alpha1" + NumaflowAPIVersion = "numaflow.numaproj.io/v1alpha1" NumaplaneLabel = "app.kubernetes.io/part-of=numaplane" NumaflowLabel = "app.kubernetes.io/part-of=numaflow, app.kubernetes.io/component=controller-manager" ) +type Output struct { + APIVersion string `json:"apiVersion"` + Kind string `json:"kind"` + Metadata metav1.ObjectMeta `json:"metadata"` + Spec interface{} `json:"spec"` + Status interface{} `json:"status,omitempty"` +} + // document for Ginkgo framework and print to console func document(testName string) { snapshotCluster(testName) diff --git a/tests/e2e/functional_test.go b/tests/e2e/functional_test.go index fcda0917..03dff9d6 100644 --- a/tests/e2e/functional_test.go +++ b/tests/e2e/functional_test.go @@ -184,6 +184,9 @@ var _ = Describe("Functional e2e", Serial, func() { return err }, testTimeout, testPollingInterval).Should(Succeed()) + wg.Add(1) + go watchNumaflowControllerRollout() + verifyNumaflowControllerRolloutReady() verifyNumaflowControllerReady(Namespace) @@ -201,6 +204,12 @@ var _ = Describe("Functional e2e", Serial, func() { return err }, testTimeout, testPollingInterval).Should(Succeed()) + wg.Add(1) + go watchISBServiceRollout() + + wg.Add(1) + go watchISBService() + verifyISBSvcRolloutReady(isbServiceRolloutName) verifyISBSvcReady(Namespace, isbServiceRolloutName, 3) @@ -219,12 +228,18 @@ var _ = Describe("Functional e2e", Serial, func() { return err }, testTimeout, testPollingInterval).Should(Succeed()) + wg.Add(1) + go watchPipelineRollout() + document("Verifying that the Pipeline was created") verifyPipelineSpec(Namespace, pipelineRolloutName, func(retrievedPipelineSpec numaflowv1.PipelineSpec) bool { return len(pipelineSpec.Vertices) == 2 // TODO: make less kludgey //return reflect.DeepEqual(pipelineSpec, retrievedPipelineSpec) // this may have had some false negatives due to "lifecycle" field maybe, or null values in one }) + wg.Add(1) + go watchPipeline() + verifyPipelineRolloutReady(pipelineRolloutName) verifyPipelineReady(Namespace, pipelineRolloutName, 2) @@ -248,6 +263,12 @@ var _ = Describe("Functional e2e", Serial, func() { return monoVertexSpec.Source != nil }) + wg.Add(1) + go watchMonoVertexRollout() + + wg.Add(1) + go watchMonoVertex() + verifyMonoVertexRolloutReady(monoVertexRolloutName) verifyMonoVertexReady(Namespace, monoVertexRolloutName) diff --git a/tests/e2e/isbservice.go b/tests/e2e/isbservice.go index f7c85c0d..26177021 100644 --- a/tests/e2e/isbservice.go +++ b/tests/e2e/isbservice.go @@ -1,15 +1,20 @@ package e2e import ( + "context" "fmt" + "os" + "path/filepath" "time" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/yaml" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/util/retry" numaflowv1 "github.com/numaproj/numaflow/pkg/apis/numaflow/v1alpha1" @@ -126,3 +131,92 @@ func updateISBServiceRolloutInK8S(name string, f func(apiv1.ISBServiceRollout) ( }) Expect(err).ShouldNot(HaveOccurred()) } + +func watchISBServiceRollout() { + + defer wg.Done() + watcher, err := isbServiceRolloutClient.Watch(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Printf("Failed to start watcher: %v\n", err) + return + } + defer watcher.Stop() + + file, err := os.OpenFile(filepath.Join(ResourceChangesOutputPath, "isbservice_rollout.yaml"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Printf("Failed to open log file: %v\n", err) + return + } + defer file.Close() + + for { + select { + case event := <-watcher.ResultChan(): + if event.Type == watch.Modified { + if rollout, ok := event.Object.(*apiv1.ISBServiceRollout); ok { + rollout.ManagedFields = nil + rl := Output{ + APIVersion: NumaplaneAPIVersion, + Kind: "ISBServiceRollout", + Metadata: rollout.ObjectMeta, + Spec: rollout.Spec, + Status: rollout.Status, + } + bytes, _ := yaml.Marshal(rl) + updateLog := fmt.Sprintf("ISBServiceRollout update time: %v\n%s\n", time.Now().Format(time.RFC3339), string(bytes)) + file.WriteString(updateLog) + } + } + case <-stopCh: + return + } + } +} + +func watchISBService() { + + defer wg.Done() + watcher, err := dynamicClient.Resource(getGVRForISBService()).Namespace(Namespace).Watch(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Printf("Failed to start watcher: %v\n", err) + return + } + defer watcher.Stop() + + file, err := os.OpenFile(filepath.Join(ResourceChangesOutputPath, "isbservice.yaml"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Printf("Failed to open log file: %v\n", err) + return + } + defer file.Close() + + for { + select { + case event := <-watcher.ResultChan(): + if event.Type == watch.Modified { + if obj, ok := event.Object.(*unstructured.Unstructured); ok { + isbsvc := numaflowv1.InterStepBufferService{} + err = util.StructToStruct(&obj, &isbsvc) + if err != nil { + fmt.Printf("Failed to convert unstruct: %v\n", err) + return + } + isbsvc.ManagedFields = nil + output := Output{ + APIVersion: NumaflowAPIVersion, + Kind: "InterStepBufferService", + Metadata: isbsvc.ObjectMeta, + Spec: isbsvc.Spec, + Status: isbsvc.Status, + } + bytes, _ := yaml.Marshal(output) + updateLog := fmt.Sprintf("ISBService update time: %v\nSpec: %s\n", time.Now().Format(time.RFC3339), string(bytes)) + file.WriteString(updateLog) + } + } + case <-stopCh: + return + } + } + +} diff --git a/tests/e2e/monovertex.go b/tests/e2e/monovertex.go index 3b4e7602..4b284e8b 100644 --- a/tests/e2e/monovertex.go +++ b/tests/e2e/monovertex.go @@ -1,13 +1,19 @@ package e2e import ( + "context" "fmt" + "os" + "path/filepath" + "time" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/util/retry" + "sigs.k8s.io/yaml" numaflowv1 "github.com/numaproj/numaflow/pkg/apis/numaflow/v1alpha1" "github.com/numaproj/numaplane/internal/util" @@ -125,3 +131,92 @@ func updateMonoVertexRolloutInK8S(name string, f func(apiv1.MonoVertexRollout) ( }) Expect(err).ShouldNot(HaveOccurred()) } + +func watchMonoVertexRollout() { + + defer wg.Done() + watcher, err := monoVertexRolloutClient.Watch(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Printf("Failed to start watcher: %v\n", err) + return + } + defer watcher.Stop() + + file, err := os.OpenFile(filepath.Join(ResourceChangesOutputPath, "monovertex_rollout.yaml"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Printf("Failed to open log file: %v\n", err) + return + } + defer file.Close() + + for { + select { + case event := <-watcher.ResultChan(): + if event.Type == watch.Modified { + if rollout, ok := event.Object.(*apiv1.MonoVertexRollout); ok { + rollout.ManagedFields = nil + rl := Output{ + APIVersion: NumaplaneAPIVersion, + Kind: "MonoVertexRollout", + Metadata: rollout.ObjectMeta, + Spec: rollout.Spec, + Status: rollout.Status, + } + bytes, _ := yaml.Marshal(rl) + updateLog := fmt.Sprintf("MonoVertexRollout update time: %v\n%s\n", time.Now().Format(time.RFC3339), string(bytes)) + file.WriteString(updateLog) + } + } + case <-stopCh: + return + } + } +} + +func watchMonoVertex() { + + defer wg.Done() + watcher, err := dynamicClient.Resource(getGVRForMonoVertex()).Namespace(Namespace).Watch(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Printf("Failed to start watcher: %v\n", err) + return + } + defer watcher.Stop() + + file, err := os.OpenFile(filepath.Join(ResourceChangesOutputPath, "monovertex.yaml"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Printf("Failed to open log file: %v\n", err) + return + } + defer file.Close() + + for { + select { + case event := <-watcher.ResultChan(): + if event.Type == watch.Modified { + if obj, ok := event.Object.(*unstructured.Unstructured); ok { + mvtx := numaflowv1.MonoVertex{} + err = util.StructToStruct(&obj, &mvtx) + if err != nil { + fmt.Printf("Failed to convert unstruct: %v\n", err) + return + } + mvtx.ManagedFields = nil + output := Output{ + APIVersion: NumaflowAPIVersion, + Kind: "MonoVertex", + Metadata: mvtx.ObjectMeta, + Spec: mvtx.Spec, + Status: mvtx.Status, + } + bytes, _ := yaml.Marshal(output) + updateLog := fmt.Sprintf("MonoVertex update time: %v\nSpec: %s\n", time.Now().Format(time.RFC3339), string(bytes)) + file.WriteString(updateLog) + } + } + case <-stopCh: + return + } + } + +} diff --git a/tests/e2e/numaflowcontroller.go b/tests/e2e/numaflowcontroller.go index ce9bccdd..d7215441 100644 --- a/tests/e2e/numaflowcontroller.go +++ b/tests/e2e/numaflowcontroller.go @@ -1,10 +1,18 @@ package e2e import ( + "context" + "fmt" + "os" + "path/filepath" + "time" + . "github.com/onsi/gomega" + "sigs.k8s.io/yaml" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/util/retry" apiv1 "github.com/numaproj/numaplane/pkg/apis/numaplane/v1alpha1" @@ -79,3 +87,44 @@ func updateNumaflowControllerRolloutInK8S(f func(apiv1.NumaflowControllerRollout }) Expect(err).ShouldNot(HaveOccurred()) } + +func watchNumaflowControllerRollout() { + + defer wg.Done() + watcher, err := numaflowControllerRolloutClient.Watch(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Printf("Failed to start watcher: %v\n", err) + return + } + defer watcher.Stop() + + file, err := os.OpenFile(filepath.Join(ResourceChangesOutputPath, "numaflowcontroller_rollout.yaml"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Printf("Failed to open log file: %v\n", err) + return + } + defer file.Close() + + for { + select { + case event := <-watcher.ResultChan(): + if event.Type == watch.Modified { + if rollout, ok := event.Object.(*apiv1.NumaflowControllerRollout); ok { + rollout.ManagedFields = nil + rl := Output{ + APIVersion: NumaplaneAPIVersion, + Kind: "NumaflowControllerRollout", + Metadata: rollout.ObjectMeta, + Spec: rollout.Spec, + Status: rollout.Status, + } + bytes, _ := yaml.Marshal(rl) + updateLog := fmt.Sprintf("NumaflowControllerRollout update time: %v\n%s\n", time.Now().Format(time.RFC3339), string(bytes)) + file.WriteString(updateLog) + } + } + case <-stopCh: + return + } + } +} diff --git a/tests/e2e/pipeline.go b/tests/e2e/pipeline.go index 861663cd..ae354546 100644 --- a/tests/e2e/pipeline.go +++ b/tests/e2e/pipeline.go @@ -1,14 +1,20 @@ package e2e import ( + "context" "fmt" + "os" + "path/filepath" + "time" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/util/retry" + "sigs.k8s.io/yaml" numaflowv1 "github.com/numaproj/numaflow/pkg/apis/numaflow/v1alpha1" @@ -171,3 +177,93 @@ func updatePipelineSpec(u *unstructured.Unstructured, f func(numaflowv1.Pipeline u.Object["spec"] = newMap return nil } + +// build watcher functions for both Pipeline and PipelineRollout +func watchPipelineRollout() { + + defer wg.Done() + watcher, err := pipelineRolloutClient.Watch(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Printf("Failed to start watcher: %v\n", err) + return + } + defer watcher.Stop() + + file, err := os.OpenFile(filepath.Join(ResourceChangesOutputPath, "pipeline_rollout.yaml"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Printf("Failed to open log file: %v\n", err) + return + } + defer file.Close() + + for { + select { + case event := <-watcher.ResultChan(): + if event.Type == watch.Modified { + if rollout, ok := event.Object.(*apiv1.PipelineRollout); ok { + rollout.ManagedFields = nil + rl := Output{ + APIVersion: NumaplaneAPIVersion, + Kind: "PipelineRollout", + Metadata: rollout.ObjectMeta, + Spec: rollout.Spec, + Status: rollout.Status, + } + bytes, _ := yaml.Marshal(rl) + updateLog := fmt.Sprintf("PipelineRollout update time: %v\n%s\n", time.Now().Format(time.RFC3339), string(bytes)) + file.WriteString(updateLog) + } + } + case <-stopCh: + return + } + } +} + +func watchPipeline() { + + defer wg.Done() + watcher, err := dynamicClient.Resource(getGVRForPipeline()).Namespace(Namespace).Watch(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Printf("Failed to start watcher: %v\n", err) + return + } + defer watcher.Stop() + + file, err := os.OpenFile(filepath.Join(ResourceChangesOutputPath, "pipeline.yaml"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Printf("Failed to open log file: %v\n", err) + return + } + defer file.Close() + + for { + select { + case event := <-watcher.ResultChan(): + if event.Type == watch.Modified { + if obj, ok := event.Object.(*unstructured.Unstructured); ok { + pl := numaflowv1.Pipeline{} + err = util.StructToStruct(&obj, &pl) + if err != nil { + fmt.Printf("Failed to convert unstruct: %v\n", err) + return + } + pl.ManagedFields = nil + output := Output{ + APIVersion: NumaflowAPIVersion, + Kind: "Pipeline", + Metadata: pl.ObjectMeta, + Spec: pl.Spec, + Status: pl.Status, + } + bytes, _ := yaml.Marshal(output) + updateLog := fmt.Sprintf("Pipeline update time: %v\nSpec: %s\n", time.Now().Format(time.RFC3339), string(bytes)) + file.WriteString(updateLog) + } + } + case <-stopCh: + return + } + } + +} diff --git a/tests/e2e/suite_test.go b/tests/e2e/suite_test.go index 1558eaec..e4d9c243 100644 --- a/tests/e2e/suite_test.go +++ b/tests/e2e/suite_test.go @@ -19,6 +19,7 @@ package e2e import ( "context" "os" + "path/filepath" "testing" . "github.com/onsi/ginkgo/v2" @@ -46,8 +47,12 @@ func TestE2E(t *testing.T) { var _ = BeforeSuite(func() { var err error - err = os.Mkdir("output", os.ModePerm) + + err = os.MkdirAll("output/controllers", os.ModePerm) + Expect(err).NotTo(HaveOccurred()) + err = os.MkdirAll("output/resources", os.ModePerm) Expect(err).NotTo(HaveOccurred()) + stopCh = make(chan struct{}) dataLossPrevention = os.Getenv("DATA_LOSS_PREVENTION") @@ -106,7 +111,8 @@ var _ = AfterSuite(func() { cancel() By("tearing down test environment") - getPodLogs(kubeClient, Namespace, NumaplaneLabel, "manager", NumaplaneCtrlLogs) + close(stopCh) + getPodLogs(kubeClient, Namespace, NumaplaneLabel, "manager", filepath.Join(ControllerOutputPath, "numaplane-controller.log")) err := testEnv.Stop() Expect(err).NotTo(HaveOccurred()) @@ -116,8 +122,7 @@ var _ = AfterEach(func() { report := CurrentSpecReport() if report.Failed() { - getPodLogs(kubeClient, Namespace, NumaplaneLabel, "manager", NumaplaneCtrlLogs) - getPodLogs(kubeClient, Namespace, NumaflowLabel, "controller-manager", NumaflowCtrlLogs) + getPodLogs(kubeClient, Namespace, NumaflowLabel, "controller-manager", filepath.Join(ControllerOutputPath, "numaflow-controller.log")) AbortSuite("Test spec has failed, aborting suite run") } From 05a6f2df3a496352b1fd756e807658093c20af5a Mon Sep 17 00:00:00 2001 From: Dillen Padhiar Date: Thu, 19 Sep 2024 11:10:11 -0700 Subject: [PATCH 2/8] fix: only upload resource changes artifact if test fails Signed-off-by: Dillen Padhiar --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index af3353bc..ef2b0f1c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -172,7 +172,7 @@ jobs: - name: Archive resource changes uses: actions/upload-artifact@v4 - if: always() + if: failure() with: name: resource-changes-${{matrix.datalossprevention}} path: | From 65cbf7ba943a773b2452e60f0f092e6ac752dc72 Mon Sep 17 00:00:00 2001 From: Dillen Padhiar Date: Thu, 19 Sep 2024 11:15:30 -0700 Subject: [PATCH 3/8] fix: codegen Signed-off-by: Dillen Padhiar --- tests/e2e/suite_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/suite_test.go b/tests/e2e/suite_test.go index 7defcb56..a09bd771 100644 --- a/tests/e2e/suite_test.go +++ b/tests/e2e/suite_test.go @@ -56,10 +56,10 @@ var _ = BeforeSuite(func() { } err = os.Mkdir(directory, os.ModePerm) Expect(err).NotTo(HaveOccurred()) - err = os.MkdirAll("output/controllers", os.ModePerm) + err = os.MkdirAll("output/controllers", os.ModePerm) Expect(err).NotTo(HaveOccurred()) err = os.MkdirAll("output/resources", os.ModePerm) - + stopCh = make(chan struct{}) dataLossPrevention = os.Getenv("DATA_LOSS_PREVENTION") From 5bd1f7ac43d26432fa138c49fce455751562a308 Mon Sep 17 00:00:00 2001 From: Dillen Padhiar Date: Thu, 19 Sep 2024 11:16:21 -0700 Subject: [PATCH 4/8] fix: codegen Signed-off-by: Dillen Padhiar --- tests/e2e/suite_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/suite_test.go b/tests/e2e/suite_test.go index a09bd771..f08f178c 100644 --- a/tests/e2e/suite_test.go +++ b/tests/e2e/suite_test.go @@ -59,6 +59,7 @@ var _ = BeforeSuite(func() { err = os.MkdirAll("output/controllers", os.ModePerm) Expect(err).NotTo(HaveOccurred()) err = os.MkdirAll("output/resources", os.ModePerm) + Expect(err).NotTo(HaveOccurred()) stopCh = make(chan struct{}) From 5d438b893cfe4c644e0d759266c2c6e1ce619b8c Mon Sep 17 00:00:00 2001 From: Dillen Padhiar Date: Thu, 19 Sep 2024 11:20:13 -0700 Subject: [PATCH 5/8] fix: lint Signed-off-by: Dillen Padhiar --- tests/e2e/isbservice.go | 12 ++++++++++-- tests/e2e/monovertex.go | 12 ++++++++++-- tests/e2e/numaflowcontroller.go | 6 +++++- tests/e2e/pipeline.go | 12 ++++++++++-- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/tests/e2e/isbservice.go b/tests/e2e/isbservice.go index 26177021..fb71a1fa 100644 --- a/tests/e2e/isbservice.go +++ b/tests/e2e/isbservice.go @@ -164,7 +164,11 @@ func watchISBServiceRollout() { } bytes, _ := yaml.Marshal(rl) updateLog := fmt.Sprintf("ISBServiceRollout update time: %v\n%s\n", time.Now().Format(time.RFC3339), string(bytes)) - file.WriteString(updateLog) + _, err = file.WriteString(updateLog) + if err != nil { + fmt.Printf("Failed to write to log file: %v\n", err) + return + } } } case <-stopCh: @@ -211,7 +215,11 @@ func watchISBService() { } bytes, _ := yaml.Marshal(output) updateLog := fmt.Sprintf("ISBService update time: %v\nSpec: %s\n", time.Now().Format(time.RFC3339), string(bytes)) - file.WriteString(updateLog) + _, err = file.WriteString(updateLog) + if err != nil { + fmt.Printf("Failed to write to log file: %v\n", err) + return + } } } case <-stopCh: diff --git a/tests/e2e/monovertex.go b/tests/e2e/monovertex.go index 4b284e8b..c513780c 100644 --- a/tests/e2e/monovertex.go +++ b/tests/e2e/monovertex.go @@ -164,7 +164,11 @@ func watchMonoVertexRollout() { } bytes, _ := yaml.Marshal(rl) updateLog := fmt.Sprintf("MonoVertexRollout update time: %v\n%s\n", time.Now().Format(time.RFC3339), string(bytes)) - file.WriteString(updateLog) + _, err = file.WriteString(updateLog) + if err != nil { + fmt.Printf("Failed to write to log file: %v\n", err) + return + } } } case <-stopCh: @@ -211,7 +215,11 @@ func watchMonoVertex() { } bytes, _ := yaml.Marshal(output) updateLog := fmt.Sprintf("MonoVertex update time: %v\nSpec: %s\n", time.Now().Format(time.RFC3339), string(bytes)) - file.WriteString(updateLog) + _, err = file.WriteString(updateLog) + if err != nil { + fmt.Printf("Failed to write to log file: %v\n", err) + return + } } } case <-stopCh: diff --git a/tests/e2e/numaflowcontroller.go b/tests/e2e/numaflowcontroller.go index d7215441..2dfc3fac 100644 --- a/tests/e2e/numaflowcontroller.go +++ b/tests/e2e/numaflowcontroller.go @@ -120,7 +120,11 @@ func watchNumaflowControllerRollout() { } bytes, _ := yaml.Marshal(rl) updateLog := fmt.Sprintf("NumaflowControllerRollout update time: %v\n%s\n", time.Now().Format(time.RFC3339), string(bytes)) - file.WriteString(updateLog) + _, err = file.WriteString(updateLog) + if err != nil { + fmt.Printf("Failed to write to log file: %v\n", err) + return + } } } case <-stopCh: diff --git a/tests/e2e/pipeline.go b/tests/e2e/pipeline.go index ae354546..5bba6e73 100644 --- a/tests/e2e/pipeline.go +++ b/tests/e2e/pipeline.go @@ -211,7 +211,11 @@ func watchPipelineRollout() { } bytes, _ := yaml.Marshal(rl) updateLog := fmt.Sprintf("PipelineRollout update time: %v\n%s\n", time.Now().Format(time.RFC3339), string(bytes)) - file.WriteString(updateLog) + _, err = file.WriteString(updateLog) + if err != nil { + fmt.Printf("Failed to write to log file: %v\n", err) + return + } } } case <-stopCh: @@ -258,7 +262,11 @@ func watchPipeline() { } bytes, _ := yaml.Marshal(output) updateLog := fmt.Sprintf("Pipeline update time: %v\nSpec: %s\n", time.Now().Format(time.RFC3339), string(bytes)) - file.WriteString(updateLog) + _, err = file.WriteString(updateLog) + if err != nil { + fmt.Printf("Failed to write to log file: %v\n", err) + return + } } } case <-stopCh: From c644a348320dfd44ee4fbcae9a1517d2a5ac2c03 Mon Sep 17 00:00:00 2001 From: Dillen Padhiar Date: Thu, 19 Sep 2024 12:51:16 -0700 Subject: [PATCH 6/8] chore: remove cleanup makefile target Signed-off-by: Dillen Padhiar --- Makefile | 8 ++------ tests/e2e/suite_test.go | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 4e12a651..2c83d794 100644 --- a/Makefile +++ b/Makefile @@ -115,13 +115,9 @@ test: codegen fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -p 1 -race -short -v $$(go list ./... | grep -v /tests/e2e) .PHONY: test-e2e -test-e2e: cleanup-e2e codegen fmt vet envtest ## Run e2e tests. - GOFLAGS="-count=1" go test -v ./tests/e2e/... +test-e2e: codegen fmt vet envtest ## Run e2e tests. + GOFLAGS="-count=1" go test -v ./tests/e2e/... -.PHONY: cleanup-e2e -cleanup-e2e: - rm -r -f tests/e2e/output - GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint GOLANGCI_LINT_VERSION ?= v1.58.0 diff --git a/tests/e2e/suite_test.go b/tests/e2e/suite_test.go index f08f178c..49f2a5e6 100644 --- a/tests/e2e/suite_test.go +++ b/tests/e2e/suite_test.go @@ -56,9 +56,9 @@ var _ = BeforeSuite(func() { } err = os.Mkdir(directory, os.ModePerm) Expect(err).NotTo(HaveOccurred()) - err = os.MkdirAll("output/controllers", os.ModePerm) + err = os.MkdirAll(ControllerOutputPath, os.ModePerm) Expect(err).NotTo(HaveOccurred()) - err = os.MkdirAll("output/resources", os.ModePerm) + err = os.MkdirAll(ResourceChangesOutputPath, os.ModePerm) Expect(err).NotTo(HaveOccurred()) stopCh = make(chan struct{}) From 218e6b4300be90cc53621e77563bd8de7079f2d9 Mon Sep 17 00:00:00 2001 From: Dillen Padhiar Date: Thu, 19 Sep 2024 12:52:00 -0700 Subject: [PATCH 7/8] chore: failing test to test artifact output (REVERT) Signed-off-by: Dillen Padhiar --- tests/e2e/functional_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/functional_test.go b/tests/e2e/functional_test.go index 03dff9d6..e62e5483 100644 --- a/tests/e2e/functional_test.go +++ b/tests/e2e/functional_test.go @@ -415,7 +415,7 @@ var _ = Describe("Functional e2e", Serial, func() { } verifyISBServiceSpec(Namespace, isbServiceRolloutName, func(retrievedISBServiceSpec numaflowv1.InterStepBufferServiceSpec) bool { - return retrievedISBServiceSpec.JetStream.Version == "2.9.8" + return retrievedISBServiceSpec.JetStream.Version == "2.9.0" }) verifyISBSvcRolloutReady(isbServiceRolloutName) From 9ac98eb9ee07a5eef49d566a4c3417c646c31595 Mon Sep 17 00:00:00 2001 From: Dillen Padhiar Date: Thu, 19 Sep 2024 13:33:26 -0700 Subject: [PATCH 8/8] chore: revert Signed-off-by: Dillen Padhiar --- Makefile | 2 +- tests/e2e/functional_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2c83d794..172cd15e 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,7 @@ test: codegen fmt vet envtest ## Run tests. .PHONY: test-e2e test-e2e: codegen fmt vet envtest ## Run e2e tests. - GOFLAGS="-count=1" go test -v ./tests/e2e/... + GOFLAGS="-count=1" go test -v ./tests/e2e/... GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint diff --git a/tests/e2e/functional_test.go b/tests/e2e/functional_test.go index e62e5483..03dff9d6 100644 --- a/tests/e2e/functional_test.go +++ b/tests/e2e/functional_test.go @@ -415,7 +415,7 @@ var _ = Describe("Functional e2e", Serial, func() { } verifyISBServiceSpec(Namespace, isbServiceRolloutName, func(retrievedISBServiceSpec numaflowv1.InterStepBufferServiceSpec) bool { - return retrievedISBServiceSpec.JetStream.Version == "2.9.0" + return retrievedISBServiceSpec.JetStream.Version == "2.9.8" }) verifyISBSvcRolloutReady(isbServiceRolloutName)