Skip to content

Commit 26e3401

Browse files
authored
CLOUDP-140883: Check unset conditions (#728)
* Add CheckConditionsNotSet func which checks unset conditions * Fix the test for Integrations
1 parent 40ec19a commit 26e3401

File tree

5 files changed

+42
-8
lines changed

5 files changed

+42
-8
lines changed

test/e2e/actions/conditions.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ func WaitForConditionsToBecomeTrue(userData *model.TestDataProvider, conditonTyp
2222
Should(BeTrue(), fmt.Sprintf("Status conditions %v are not all 'True'", conditonTypes))
2323
}
2424

25+
// CheckConditionsNotSet wait for Ready condition to become true and checks that input conditions are unset
26+
func CheckConditionsNotSet(userData *model.TestDataProvider, conditonTypes ...status.ConditionType) {
27+
Eventually(conditionsAreUnset(userData, conditonTypes...)).
28+
WithTimeout(15*time.Minute).WithPolling(20*time.Second).
29+
Should(BeTrue(), fmt.Sprintf("Status conditions %v should be unset", conditonTypes))
30+
}
31+
2532
func allConditionsAreTrueFunc(userData *model.TestDataProvider, conditonTypes ...status.ConditionType) func(g types.Gomega) bool {
2633
return func(g Gomega) bool {
2734
conditions, err := kube.GetAllProjectConditions(userData)
@@ -44,3 +51,32 @@ func allConditionsAreTrueFunc(userData *model.TestDataProvider, conditonTypes ..
4451
return true
4552
}
4653
}
54+
55+
func conditionsAreUnset(userData *model.TestDataProvider, unsetConditonTypes ...status.ConditionType) func(g types.Gomega) bool {
56+
return func(g Gomega) bool {
57+
conditions, err := kube.GetAllProjectConditions(userData)
58+
g.Expect(err).ShouldNot(HaveOccurred())
59+
60+
isReady := false
61+
for _, condition := range conditions {
62+
if condition.Type == status.ReadyType && condition.Status == v1.ConditionTrue {
63+
isReady = true
64+
break
65+
}
66+
}
67+
68+
if !isReady {
69+
return false
70+
}
71+
72+
for _, condition := range conditions {
73+
for _, unsetConditionType := range unsetConditonTypes {
74+
if condition.Type == unsetConditionType {
75+
return false
76+
}
77+
}
78+
}
79+
80+
return true
81+
}
82+
}

test/e2e/auditing_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func auditingFlow(userData *model.TestDataProvider, auditing *v1.Auditing) {
6868
By("Remove Auditing from the project", func() {
6969
userData.Project.Spec.Auditing = nil
7070
Expect(userData.K8SClient.Update(userData.Context, userData.Project)).Should(Succeed())
71-
actions.WaitForConditionsToBecomeTrue(userData, status.ReadyType)
71+
actions.CheckConditionsNotSet(userData, status.AuditingReadyType)
7272
})
7373
}
7474

test/e2e/encryption_at_rest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func encryptionAtRestFlow(userData *model.TestDataProvider, encAtRest v1.Encrypt
132132
})
133133

134134
By("Check if project returned back to the initial state", func() {
135-
actions.WaitForConditionsToBecomeTrue(userData, status.ReadyType)
135+
actions.CheckConditionsNotSet(userData, status.EncryptionAtRestReadyType)
136136

137137
Expect(userData.K8SClient.Get(userData.Context, types.NamespacedName{Name: userData.Project.Name,
138138
Namespace: userData.Resources.Namespace}, userData.Project)).Should(Succeed())

test/e2e/integration_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package e2e_test
22

33
import (
4-
"fmt"
54
"os"
65
"strings"
76

@@ -114,14 +113,13 @@ func integrationCycle(data *model.TestDataProvider, key string) {
114113
Namespace: data.Resources.Namespace}, data.Project)).Should(Succeed())
115114
data.Project.Spec.Integrations = []project.Integration{}
116115
Expect(data.K8SClient.Update(data.Context, data.Project)).Should(Succeed())
117-
actions.WaitForConditionsToBecomeTrue(data, status.ReadyType)
116+
actions.CheckConditionsNotSet(data, status.IntegrationReadyType)
118117
})
119118

120119
By("Delete integration check", func() {
121120
integration, err := atlasClient.GetIntegrationbyType(data.Project.ID(), integrationType)
122-
By(fmt.Sprintf("Integration %v", integration))
123-
Expect(err).ShouldNot(HaveOccurred())
124-
Expect(integration.Enabled).To(BeFalse())
121+
Expect(err).Should(HaveOccurred())
122+
Expect(integration).To(BeNil())
125123

126124
// TODO uncomment with
127125
// status := kubecli.GetStatusCondition(string(status.IntegrationReadyType), data.Resources.Namespace, data.Resources.GetAtlasProjectFullKubeName())

test/e2e/project_settings_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ func projectSettingsFlow(userData *model.TestDataProvider, settings *v1.ProjectS
7070
By("Remove Project Settings from the project", func() {
7171
userData.Project.Spec.Settings = nil
7272
Expect(userData.K8SClient.Update(userData.Context, userData.Project)).Should(Succeed())
73-
actions.WaitForConditionsToBecomeTrue(userData, status.ReadyType)
73+
actions.CheckConditionsNotSet(userData, status.ProjectSettingsReadyType)
7474
})
7575
}

0 commit comments

Comments
 (0)