Skip to content

Commit

Permalink
chore(e2e): reformat olm_upgrade_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
tadayosi committed Oct 25, 2022
1 parent 5275554 commit b0e8dac
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions e2e/namespace/upgrade/olm_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
// Set KAMEL_BIN only for this test - don't override the ENV variable for all tests
Expect(os.Setenv("KAMEL_BIN", kamel)).To(Succeed())

args := []string{"install", "-n", ns, "--olm=true", "--olm-source", catalogSourceName, "--olm-source-namespace", ns}
args := []string{
"install",
"-n", ns,
"--olm=true",
"--olm-source", catalogSourceName,
"--olm-source-namespace", ns,
}

if prevUpdateChannel != "" {
args = append(args, "--olm-channel", prevUpdateChannel)
Expand All @@ -96,7 +102,8 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
noAdditionalConditions := func(csv olm.ClusterServiceVersion) bool {
return true
}
Eventually(clusterServiceVersionPhase(noAdditionalConditions, ns), TestTimeoutMedium).Should(Equal(olm.CSVPhaseSucceeded))
Eventually(clusterServiceVersionPhase(noAdditionalConditions, ns), TestTimeoutMedium).
Should(Equal(olm.CSVPhaseSucceeded))

// Refresh the test client to account for the newly installed CRDs
SyncClient()
Expand All @@ -123,7 +130,8 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).
Should(Equal(corev1.ConditionTrue))

// Check the Integration version matches that of the current operator
Expect(IntegrationVersion(ns, name)()).To(ContainSubstring(prevIPVersionPrefix))
Expand All @@ -140,7 +148,9 @@ func TestOLMAutomaticUpgrade(t *testing.T) {

// Patch the Subscription to avoid conflicts with concurrent updates performed by OLM
patch := fmt.Sprintf("{\"spec\":{\"channel\":%q}}", newUpdateChannel)
Expect(TestClient().Patch(TestContext, subscription, ctrl.RawPatch(types.MergePatchType, []byte(patch)))).To(Succeed())
Expect(
TestClient().Patch(TestContext, subscription, ctrl.RawPatch(types.MergePatchType, []byte(patch))),
).To(Succeed())
// Assert the response back from the API server
Expect(subscription.Spec.Channel).To(Equal(newUpdateChannel))
}
Expand Down Expand Up @@ -177,14 +187,16 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
Expect(os.Setenv("KAMEL_BIN", "")).To(Succeed())

// Check the Integration hasn't been upgraded
Consistently(IntegrationVersion(ns, name), 5*time.Second, 1*time.Second).Should(ContainSubstring(prevIPVersionPrefix))
Consistently(IntegrationVersion(ns, name), 5*time.Second, 1*time.Second).
Should(ContainSubstring(prevIPVersionPrefix))

// Rebuild the Integration
Expect(Kamel("rebuild", name, "-n", ns).Execute()).To(Succeed())

// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).
Should(Equal(corev1.ConditionTrue))

// Check the Integration version has been upgraded
Eventually(IntegrationVersion(ns, name)).Should(ContainSubstring(newIPVersionPrefix))
Expand All @@ -207,7 +219,8 @@ func TestOLMAutomaticUpgrade(t *testing.T) {

// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name)).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).
Should(Equal(corev1.ConditionTrue))

// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Expand Down

0 comments on commit b0e8dac

Please sign in to comment.