-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(#330): add system-tests for destination
- Loading branch information
Showing
3 changed files
with
116 additions
and
1 deletion.
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
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,23 @@ | ||
apiVersion: platform.kratix.io/v1alpha1 | ||
kind: BucketStateStore | ||
metadata: | ||
name: destination-test-store | ||
spec: | ||
authMethod: accessKey | ||
bucketName: kratix | ||
endpoint: minio.kratix-platform-system.svc.cluster.local | ||
insecure: true | ||
secretRef: | ||
name: minio-credentials | ||
namespace: default | ||
--- | ||
apiVersion: platform.kratix.io/v1alpha1 | ||
kind: Destination | ||
metadata: | ||
name: worker-3 | ||
labels: | ||
environment: dev | ||
spec: | ||
stateStoreRef: | ||
name: destination-test-store | ||
kind: BucketStateStore |
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,92 @@ | ||
package system_test | ||
|
||
import ( | ||
"strings" | ||
"time" | ||
|
||
"github.com/syntasso/kratix/test/kubeutils" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Destinations", func() { | ||
Describe("status and events", func() { | ||
var destinationName string | ||
BeforeEach(func() { | ||
destinationName = "worker-3" | ||
|
||
SetDefaultEventuallyTimeout(2 * time.Minute) | ||
SetDefaultEventuallyPollingInterval(2 * time.Second) | ||
kubeutils.SetTimeoutAndInterval(2*time.Minute, 2*time.Second) | ||
|
||
platform.Kubectl("apply", "-f", "assets/destination/worker-3.yaml") | ||
}) | ||
|
||
AfterEach(func() { | ||
platform.Kubectl("delete", "-f", "assets/destination/worker-3.yaml") | ||
}) | ||
|
||
It("properly set the conditions and events", func() { | ||
By("showing `Ready` as true", func() { | ||
Eventually(func() string { | ||
return platform.Kubectl("get", "destinations", destinationName) | ||
}).Should(ContainSubstring("True")) | ||
}) | ||
|
||
By("firing the success event", func() { | ||
Eventually(func() string { | ||
describeOutput := strings.Split(platform.Kubectl("describe", "destinations", destinationName), "\n") | ||
return describeOutput[len(describeOutput)-2] | ||
}).Should(ContainSubstring(`Destination "worker-3" is ready`)) | ||
}) | ||
|
||
// set stateStoreRef to a non-existing one | ||
platform.Kubectl("patch", "destinations", destinationName, "--type=merge", "-p", `{"spec":{"stateStoreRef":{"name":"non-existing"}}}`) | ||
|
||
By("showing `Ready` as False when the State Store is wrong", func() { | ||
Eventually(func() string { | ||
return platform.Kubectl("get", "destinations", destinationName) | ||
}).Should(ContainSubstring("False")) | ||
}) | ||
|
||
By("firing a failure event", func() { | ||
Eventually(func() string { | ||
describeOutput := strings.Split(platform.Kubectl("describe", "destinations", destinationName), "\n") | ||
return describeOutput[len(describeOutput)-2] | ||
}).Should(ContainSubstring("Failed to write test documents")) | ||
}) | ||
|
||
// restore the ready condition | ||
platform.Kubectl("apply", "-f", "assets/destination/worker-3.yaml") | ||
|
||
By("showing `Ready` as true", func() { | ||
Eventually(func() string { | ||
return platform.Kubectl("get", "destinations", destinationName) | ||
}).Should(ContainSubstring("True")) | ||
}) | ||
|
||
By("firing the success event", func() { | ||
Eventually(func() string { | ||
describeOutput := strings.Split(platform.Kubectl("describe", "destinations", destinationName), "\n") | ||
return describeOutput[len(describeOutput)-2] | ||
}).Should(ContainSubstring(`Destination "worker-3" is ready`)) | ||
}) | ||
|
||
// update the underlying state store with an invalid secret | ||
platform.Kubectl("patch", "bucketstatestore", "destination-test-store", "--type=merge", "-p", `{"spec":{"secretRef":{"name":"non-existing"}}}`) | ||
By("showing `Ready` as False when the State Store is wrong", func() { | ||
Eventually(func() string { | ||
return platform.Kubectl("get", "destinations", destinationName) | ||
}).Should(ContainSubstring("False")) | ||
}) | ||
|
||
By("firing a failure event", func() { | ||
Eventually(func() string { | ||
describeOutput := strings.Split(platform.Kubectl("describe", "destinations", destinationName), "\n") | ||
return describeOutput[len(describeOutput)-2] | ||
}).Should(ContainSubstring("Failed to write test documents")) | ||
}) | ||
}) | ||
}) | ||
}) |