-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(updates): re-run loop when update is made #110
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ vet: ## Run go vet against code. | |
.PHONY: test | ||
test: manifests generate fmt vet envtest ## Run tests. | ||
GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/[email protected] | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) -r -p -coverprofile cover.out | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) -vv -r -p -coverprofile cover.out | ||
|
||
##@ Build | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,8 +189,12 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, FlakeAttempts(3), func() | |
|
||
It("Check for connectivity", func() { | ||
stopChan := make(chan struct{}, 1) | ||
_, err := checkAndK8sPortForwardRedis(ctx, clientset, cfg, stopChan, name, namespace, password) | ||
rc, err := checkAndK8sPortForwardRedis(ctx, clientset, cfg, stopChan, name, namespace, password) | ||
Expect(err).To(BeNil()) | ||
|
||
// Insert test data | ||
Expect(rc.Set(ctx, "foo", "bar", 0).Err()).To(BeNil()) | ||
|
||
defer close(stopChan) | ||
}) | ||
|
||
|
@@ -294,23 +298,22 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, FlakeAttempts(3), func() | |
Expect(podRoles[resources.Replica]).To(HaveLen(2)) | ||
}) | ||
|
||
It("Update to image should be propagated successfully", func() { | ||
newImage := resources.DragonflyImage + ":v1.9.0" | ||
It("Updates should be propagated successfully", func() { | ||
// Update df to the latest | ||
err := k8sClient.Get(ctx, types.NamespacedName{ | ||
Name: name, | ||
Namespace: namespace, | ||
}, &df) | ||
Expect(err).To(BeNil()) | ||
|
||
df.Spec.Image = newImage | ||
df.Spec.Image = fmt.Sprintf("%s:%s", resources.DragonflyImage, "v1.9.0") | ||
err = k8sClient.Update(ctx, &df) | ||
Expect(err).To(BeNil()) | ||
}) | ||
|
||
time.Sleep(30 * time.Second) | ||
|
||
// Wait until Dragonfly object is marked resources-created | ||
err = waitForDragonflyPhase(ctx, k8sClient, name, namespace, controller.PhaseReady, 3*time.Minute) | ||
It("Check for values in statefulset", func() { | ||
// Wait until Dragonfly object is marked ready | ||
err := waitForDragonflyPhase(ctx, k8sClient, name, namespace, controller.PhaseReady, 3*time.Minute) | ||
Expect(err).To(BeNil()) | ||
err = waitForStatefulSetReady(ctx, k8sClient, name, namespace, 3*time.Minute) | ||
Expect(err).To(BeNil()) | ||
|
@@ -323,8 +326,8 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, FlakeAttempts(3), func() | |
}, &ss) | ||
Expect(err).To(BeNil()) | ||
|
||
// check for pod image | ||
Expect(ss.Spec.Template.Spec.Containers[0].Image).To(Equal(newImage)) | ||
// check for env | ||
Expect(ss.Spec.Template.Spec.Containers[0].Image).To(Equal(df.Spec.Image)) | ||
|
||
// Check if there are relevant pods with expected roles | ||
var pods corev1.PodList | ||
|
@@ -337,11 +340,13 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, FlakeAttempts(3), func() | |
// Get the pods along with their roles | ||
podRoles := make(map[string][]string) | ||
for _, pod := range pods.Items { | ||
Expect(pod.Spec.Containers[0].Image).To(Equal(df.Spec.Image)) | ||
role, ok := pod.Labels[resources.Role] | ||
// error if there is no label | ||
Expect(ok).To(BeTrue()) | ||
// verify the role to match the label | ||
podRoles[role] = append(podRoles[role], pod.Name) | ||
|
||
} | ||
|
||
// One Master & Two Replicas | ||
|
@@ -414,7 +419,7 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, FlakeAttempts(3), func() | |
err = k8sClient.Update(ctx, &df) | ||
Expect(err).To(BeNil()) | ||
|
||
// Wait until Dragonfly object is marked resources-created | ||
// Wait until Dragonfly object is marked ready | ||
err = waitForDragonflyPhase(ctx, k8sClient, name, namespace, controller.PhaseReady, 3*time.Minute) | ||
Expect(err).To(BeNil()) | ||
err = waitForStatefulSetReady(ctx, k8sClient, name, namespace, 3*time.Minute) | ||
|
@@ -446,6 +451,46 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, FlakeAttempts(3), func() | |
|
||
// check for affinity | ||
Expect(ss.Spec.Template.Spec.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution).To(Equal(newAffinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution)) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is important as it actually verifies if the statefulset update actually translated into a rollout onto the pods. |
||
// check for pods too | ||
var pods corev1.PodList | ||
err = k8sClient.List(ctx, &pods, client.InNamespace(namespace), client.MatchingLabels{ | ||
"app": name, | ||
resources.KubernetesPartOfLabelKey: "dragonfly", | ||
}) | ||
Expect(err).To(BeNil()) | ||
|
||
for _, pod := range pods.Items { | ||
// check for pod args | ||
Expect(pod.Spec.Containers[0].Args).To(Equal(expectedArgs)) | ||
|
||
// check for pod resources | ||
Expect(pod.Spec.Containers[0].Resources.Limits[corev1.ResourceCPU].Equal(newResources.Limits[corev1.ResourceCPU])).To(BeTrue()) | ||
Expect(pod.Spec.Containers[0].Resources.Limits[corev1.ResourceMemory].Equal(newResources.Limits[corev1.ResourceMemory])).To(BeTrue()) | ||
Expect(pod.Spec.Containers[0].Resources.Requests[corev1.ResourceCPU].Equal(newResources.Requests[corev1.ResourceCPU])).To(BeTrue()) | ||
Expect(pod.Spec.Containers[0].Resources.Requests[corev1.ResourceMemory].Equal(newResources.Requests[corev1.ResourceMemory])).To(BeTrue()) | ||
|
||
// check for annotations | ||
Expect(pod.ObjectMeta.Annotations).To(Equal(newAnnotations)) | ||
|
||
// check for tolerations | ||
Expect(pod.Spec.Tolerations).To(ContainElements(newTolerations)) | ||
|
||
// check for affinity | ||
Expect(pod.Spec.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution).To(Equal(newAffinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution)) | ||
} | ||
}) | ||
|
||
It("Check for data", func() { | ||
stopChan := make(chan struct{}, 1) | ||
rc, err := checkAndK8sPortForwardRedis(ctx, clientset, cfg, stopChan, name, namespace, password) | ||
Expect(err).To(BeNil()) | ||
|
||
// Check for test data | ||
data, err := rc.Get(ctx, "foo").Result() | ||
Expect(err).To(BeNil()) | ||
Expect(data).To(Equal("bar")) | ||
defer close(stopChan) | ||
}) | ||
|
||
It("Cleanup", func() { | ||
|
@@ -609,12 +654,20 @@ var _ = Describe("Dragonfly Server TLS tests", Ordered, FlakeAttempts(3), func() | |
TLSSecretRef: &corev1.SecretReference{ | ||
Name: "df-tls", | ||
}, | ||
Authentication: &resourcesv1.Authentication{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed as an auth mechanism is necessary when we pass a TLS certificate. |
||
PasswordFromSecret: &corev1.SecretKeySelector{ | ||
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: "df-password", | ||
}, | ||
Key: "password", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
Context("Dragonfly TLS creation", func() { | ||
It("Should create successfully", func() { | ||
// create the secret | ||
// create the secrets | ||
cert, key, err := generateSelfSignedCert(name) | ||
Expect(err).To(BeNil()) | ||
|
||
|
@@ -630,6 +683,17 @@ var _ = Describe("Dragonfly Server TLS tests", Ordered, FlakeAttempts(3), func() | |
}) | ||
Expect(err).To(BeNil()) | ||
|
||
err = k8sClient.Create(ctx, &corev1.Secret{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "df-password", | ||
Namespace: namespace, | ||
}, | ||
StringData: map[string]string{ | ||
"password": "df-pass-1", | ||
}, | ||
}) | ||
Expect(err).To(BeNil()) | ||
|
||
err = k8sClient.Create(ctx, &df) | ||
Expect(err).To(BeNil()) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adds more verbose logs on the tests