From 3fa491afd98d7fce73df34ee986f2d74a4953b38 Mon Sep 17 00:00:00 2001 From: Alejandro Ruiz Date: Mon, 17 Jun 2024 13:23:10 +0200 Subject: [PATCH] Add integration test --- e2e/drift/drift_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/e2e/drift/drift_test.go b/e2e/drift/drift_test.go index 15be05ce7a..aac0025011 100644 --- a/e2e/drift/drift_test.go +++ b/e2e/drift/drift_test.go @@ -2,6 +2,7 @@ package examples_test import ( "encoding/json" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -18,6 +19,9 @@ var _ = Describe("Drift", func() { k kubectl.Command namespace string bundleName string + + interval = 2 * time.Second + duration = 30 * time.Second ) BeforeEach(func() { @@ -128,6 +132,32 @@ var _ = Describe("Drift", func() { }) }) + Context("Modifying status in deployment", func() { + var releaseSecretsPrevious string + JustBeforeEach(func() { + kw := k.Namespace(namespace) + out, err := kw.Patch( + "deployment", "nginx-deployment", + "--subresource=status", + "--type=json", + "-p", `[{"op": "add", "path": "/status/conditions/-", "value": {"lastTransitionTime":"2024-06-17T10:00:00Z","message":"Testing","reason":"Testing","status":"True","type":"Testing"}}]`, + ) + Expect(err).ToNot(HaveOccurred(), out) + + out, err = kw.Get("secrets", "--field-selector=type=helm.sh/release.v1", "-o=name") + Expect(err).ToNot(HaveOccurred(), out) + releaseSecretsPrevious = out + }) + + It("Does not trigger drift correction", func() { + Consistently(func() string { + kw := k.Namespace(namespace) + out, _ := kw.Get("secrets", "--field-selector=type=helm.sh/release.v1", "-o=name") + return out + }, duration, interval).Should(Equal(releaseSecretsPrevious)) + }) + }) + Context("Modifying data in configmap", func() { JustBeforeEach(func() { kw := k.Namespace(namespace)