Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test/e2e/actions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ func WaitForConditionsToBecomeTrue(userData *model.TestDataProvider, conditonTyp
Should(BeTrue(), fmt.Sprintf("Status conditions %v are not all 'True'", conditonTypes))
}

// CheckConditionsNotSet wait for Ready condition to become true and checks that input conditions are unset
func CheckConditionsNotSet(userData *model.TestDataProvider, conditonTypes ...status.ConditionType) {
Eventually(conditionsAreUnset(userData, conditonTypes...)).
WithTimeout(15*time.Minute).WithPolling(20*time.Second).
Should(BeTrue(), fmt.Sprintf("Status conditions %v should be unset", conditonTypes))
}

func allConditionsAreTrueFunc(userData *model.TestDataProvider, conditonTypes ...status.ConditionType) func(g types.Gomega) bool {
return func(g Gomega) bool {
conditions, err := kube.GetAllProjectConditions(userData)
Expand All @@ -44,3 +51,32 @@ func allConditionsAreTrueFunc(userData *model.TestDataProvider, conditonTypes ..
return true
}
}

func conditionsAreUnset(userData *model.TestDataProvider, unsetConditonTypes ...status.ConditionType) func(g types.Gomega) bool {
return func(g Gomega) bool {
conditions, err := kube.GetAllProjectConditions(userData)
g.Expect(err).ShouldNot(HaveOccurred())

isReady := false
for _, condition := range conditions {
if condition.Type == status.ReadyType && condition.Status == v1.ConditionTrue {
isReady = true
break
}
}

if !isReady {
return false
}

for _, condition := range conditions {
for _, unsetConditionType := range unsetConditonTypes {
if condition.Type == unsetConditionType {
return false
}
}
}

return true
}
}
2 changes: 1 addition & 1 deletion test/e2e/auditing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func auditingFlow(userData *model.TestDataProvider, auditing *v1.Auditing) {
By("Remove Auditing from the project", func() {
userData.Project.Spec.Auditing = nil
Expect(userData.K8SClient.Update(userData.Context, userData.Project)).Should(Succeed())
actions.WaitForConditionsToBecomeTrue(userData, status.ReadyType)
actions.CheckConditionsNotSet(userData, status.AuditingReadyType)
})
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/encryption_at_rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func encryptionAtRestFlow(userData *model.TestDataProvider, encAtRest v1.Encrypt
})

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

Expect(userData.K8SClient.Get(userData.Context, types.NamespacedName{Name: userData.Project.Name,
Namespace: userData.Resources.Namespace}, userData.Project)).Should(Succeed())
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package e2e_test

import (
"fmt"
"os"
"strings"

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

By("Delete integration check", func() {
integration, err := atlasClient.GetIntegrationbyType(data.Project.ID(), integrationType)
By(fmt.Sprintf("Integration %v", integration))
Expect(err).ShouldNot(HaveOccurred())
Expect(integration.Enabled).To(BeFalse())
Expect(err).Should(HaveOccurred())
Expect(integration).To(BeNil())

// TODO uncomment with
// status := kubecli.GetStatusCondition(string(status.IntegrationReadyType), data.Resources.Namespace, data.Resources.GetAtlasProjectFullKubeName())
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/project_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ func projectSettingsFlow(userData *model.TestDataProvider, settings *v1.ProjectS
By("Remove Project Settings from the project", func() {
userData.Project.Spec.Settings = nil
Expect(userData.K8SClient.Update(userData.Context, userData.Project)).Should(Succeed())
actions.WaitForConditionsToBecomeTrue(userData, status.ReadyType)
actions.CheckConditionsNotSet(userData, status.ProjectSettingsReadyType)
})
}