Skip to content
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

Refactor tests to prevent nightly failures #1110

Merged
merged 4 commits into from
Nov 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 23 additions & 24 deletions test/acceptance/test/add_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ var _ = Describe("Weave GitOps Add App Tests", func() {

It("Test1 - Verify that gitops can deploy and remove a gitlab app after it is setup with an empty repo initially", func() {
var repoAbsolutePath string
var appRemoveOutput string
private := true
tip := generateTestInputs()
appName := tip.appRepoName
appRepoRemoteURL := "ssh://git@gitlab.com/" + GITLAB_ORG + "/" + tip.appRepoName + ".git"
var appRemoveOutput *gexec.Session

addCommand := "add app . --auto-merge=true"

Expand Down Expand Up @@ -250,13 +250,13 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
})

By("When I remove an app", func() {
appRemoveOutput = runCommandAndReturnSessionOutput(WEGO_BIN_PATH + " delete app " + appName)
appRemoveOutput, _ = runCommandAndReturnStringOutput(WEGO_BIN_PATH + " delete app " + appName)
})

By("Then I should see app removing message", func() {
Eventually(appRemoveOutput).Should(gbytes.Say(fmt.Sprintf("► Removing application %q from cluster %q and repository", appName, clusterContext)))
Eventually(appRemoveOutput).Should(gbytes.Say("► Committing and pushing gitops updates for application"))
Eventually(appRemoveOutput).Should(gbytes.Say("► Pushing app changes to repository"))
Eventually(appRemoveOutput).Should(MatchRegexp(`► Removing application "` + appName + `" from cluster .* and repository`))
Eventually(appRemoveOutput).Should(ContainSubstring("► Committing and pushing gitops updates for application"))
Eventually(appRemoveOutput).Should(ContainSubstring("► Pushing app changes to repository"))
})

By("And app should get deleted from the cluster", func() {
Expand Down Expand Up @@ -325,8 +325,8 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
tip := generateTestInputs()
appName := tip.appRepoName
appConfigRepoName := "wego-config-repo-" + RandString(8)
appRepoRemoteURL := "ssh://git@github.com/" + GITHUB_ORG + "/" + tip.appRepoName + ".git"
configRepoRemoteURL = "ssh://git@github.com/" + GITHUB_ORG + "/" + appConfigRepoName + ".git"
appRepoRemoteURL := "https://github.com/" + GITHUB_ORG + "/" + tip.appRepoName + ".git"
configRepoRemoteURL = "https://github.com/" + GITHUB_ORG + "/" + appConfigRepoName + ".git"

addCommand := "add app --url=" + appRepoRemoteURL + " --app-config-url=" + configRepoRemoteURL + " --auto-merge=true"

Expand Down Expand Up @@ -370,7 +370,7 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
It("Test2 - Verify that gitops can deploy and remove a gitlab app with specified config-url and app-config-url set to <url>", func() {
var repoAbsolutePath string
var configRepoRemoteURL string
var appRemoveOutput *gexec.Session
var appRemoveOutput string
private := true
tip := generateTestInputs()
appName := tip.appRepoName
Expand Down Expand Up @@ -421,13 +421,13 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
})

By("When I delete an app", func() {
appRemoveOutput = runCommandAndReturnSessionOutput(WEGO_BIN_PATH + " delete app " + appName)
appRemoveOutput, _ = runCommandAndReturnStringOutput(WEGO_BIN_PATH + " delete app " + appName)
})

By("Then I should see app removing message", func() {
Eventually(appRemoveOutput).Should(gbytes.Say(fmt.Sprintf("► Removing application %q from cluster %q and repository", appName, clusterContext)))
Eventually(appRemoveOutput).Should(gbytes.Say("► Committing and pushing gitops updates for application"))
Eventually(appRemoveOutput).Should(gbytes.Say("► Pushing app changes to repository"))
Eventually(appRemoveOutput).Should(MatchRegexp(`► Removing application "` + appName + `" from cluster .* and repository`))
Eventually(appRemoveOutput).Should(ContainSubstring("► Committing and pushing gitops updates for application"))
Eventually(appRemoveOutput).Should(ContainSubstring("► Pushing app changes to repository"))
})

By("And app should get deleted from the cluster", func() {
Expand Down Expand Up @@ -917,7 +917,7 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
var unpauseOutput string
var appStatus1 *gexec.Session
var appStatus2 *gexec.Session
var appRemoveOutput *gexec.Session
var appRemoveOutput string
var repoAbsolutePath1 string
var repoAbsolutePath2 string
var appManifestFile1 string
Expand Down Expand Up @@ -1096,13 +1096,13 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
})

By("When I delete an app", func() {
appRemoveOutput = runCommandAndReturnSessionOutput(WEGO_BIN_PATH + " delete app " + appName2)
appRemoveOutput, _ = runCommandAndReturnStringOutput(WEGO_BIN_PATH + " delete app " + appName2)
})

By("Then I should see app deleting message", func() {
Eventually(appRemoveOutput).Should(gbytes.Say(fmt.Sprintf("► Removing application %q from cluster %q and repository", appName2, clusterContext)))
Eventually(appRemoveOutput).Should(gbytes.Say("► Committing and pushing gitops updates for application"))
Eventually(appRemoveOutput).Should(gbytes.Say("► Pushing app changes to repository"))
Eventually(appRemoveOutput).Should(MatchRegexp(`► Removing application "` + appName2 + `" from cluster .* and repository`))
Eventually(appRemoveOutput).Should(ContainSubstring("► Committing and pushing gitops updates for application"))
Eventually(appRemoveOutput).Should(ContainSubstring("► Pushing app changes to repository"))
})

By("And app should get deleted from the cluster", func() {
Expand All @@ -1127,7 +1127,7 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
appName := "my-helm-app"
appManifestFilePath := "./data/helm-repo/hello-world"
appRepoName := "wego-test-app-" + RandString(8)
appRepoRemoteURL := "ssh://git@github.com/" + GITHUB_ORG + "/" + appRepoName + ".git"
appRepoRemoteURL := "https://github.com/" + GITHUB_ORG + "/" + appRepoName + ".git"

addCommand := "add app . --deployment-type=helm --path=./hello-world --name=" + appName + " --auto-merge=true"

Expand Down Expand Up @@ -1340,12 +1340,11 @@ var _ = Describe("Weave GitOps Add App Tests", func() {

It("Test3 - Verify that gitops can deploy and remove a gitlab app in a subgroup", func() {
var repoAbsolutePath string
var appRemoveOutput string
private := true
tip := generateTestInputs()
appName := tip.appRepoName

var appRemoveOutput *gexec.Session

addCommand := "add app . --auto-merge=true"

subGroup := GITLAB_ORG + "/" + GITLAB_SUBGROUP
Expand Down Expand Up @@ -1396,13 +1395,13 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
})

By("When I remove an app", func() {
appRemoveOutput = runCommandAndReturnSessionOutput(WEGO_BIN_PATH + " delete app " + appName)
appRemoveOutput, _ = runCommandAndReturnStringOutput(WEGO_BIN_PATH + " delete app " + appName)
})

By("Then I should see app removing message", func() {
Eventually(appRemoveOutput).Should(gbytes.Say(fmt.Sprintf("► Removing application %q from cluster %q and repository", appName, clusterContext)))
Eventually(appRemoveOutput).Should(gbytes.Say("► Committing and pushing gitops updates for application"))
Eventually(appRemoveOutput).Should(gbytes.Say("► Pushing app changes to repository"))
Eventually(appRemoveOutput).Should(MatchRegexp(`► Removing application "` + appName + `" from cluster .* and repository`))
Eventually(appRemoveOutput).Should(ContainSubstring("► Committing and pushing gitops updates for application"))
Eventually(appRemoveOutput).Should(ContainSubstring("► Pushing app changes to repository"))
})

By("And app should get deleted from the cluster", func() {
Expand Down