Skip to content

Commit

Permalink
remove use of kind action that blocks multicluster
Browse files Browse the repository at this point in the history
  • Loading branch information
jrryjcksn committed Nov 12, 2021
1 parent 7f264d2 commit 002c369
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 43 deletions.
11 changes: 0 additions & 11 deletions .github/actions/run-acceptance-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ runs:
sudo mv -f chromedriver /usr/local/bin/chromedriver
wget https://selenium-release.storage.googleapis.com/3.14/selenium-server-standalone-3.14.0.jar
xvfb-run -a --server-args="-screen 0 1280x1024x24" java -jar ./selenium-server-standalone-3.14.0.jar &
- name: Setup Kubernetes
uses: engineerd/setup-kind@v0.5.0
with:
name: "${{ format('katc-{0}', github.run_id) }}"
version: "v0.11.0"
image: kindest/node:v1.21.1
config: "./test/acceptance/test/configs/kind-config.yaml"
- name: Kind-check
shell: bash
run: |
kubectl get pods -A
- name: Download gitops binaries
uses: actions/download-artifact@v2
with:
Expand Down
37 changes: 19 additions & 18 deletions test/acceptance/test/add_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (

var clusterName string

var clusterContext string

var _ = Describe("Weave GitOps Add App Tests", func() {

deleteWegoRuntime := false
Expand All @@ -32,7 +34,7 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
By("Given I have a brand new cluster", func() {
var err error

clusterName, err = ResetOrCreateCluster(WEGO_DEFAULT_NAMESPACE, deleteWegoRuntime)
clusterName, clusterContext, err = ResetOrCreateCluster(WEGO_DEFAULT_NAMESPACE, deleteWegoRuntime)
Expect(err).ShouldNot(HaveOccurred())
})

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

FIt("Verify that gitops can deploy a single workload to multiple clusters with app manifests in config repo (Bug #810)", func() {
It("Verify that gitops can deploy a single workload to multiple clusters with app manifests in config repo (Bug #810)", func() {
var repoAbsolutePath string
tip := generateTestInputs()
appRepoName := "wego-test-app-" + RandString(8)
Expand All @@ -575,26 +577,25 @@ var _ = Describe("Weave GitOps Add App Tests", func() {

addCommand := "add app . --name=" + appName + " --auto-merge=true"

cluster1 := clusterName
cluster2, err := ResetOrCreateClusterWithName(WEGO_DEFAULT_NAMESPACE, deleteWegoRuntime, "", true)
cluster1Context := clusterContext
cluster2Name, cluster2Context, err := ResetOrCreateClusterWithName(WEGO_DEFAULT_NAMESPACE, deleteWegoRuntime, "", true)
Expect(err).ShouldNot(HaveOccurred())

defer deleteRepo(appRepoName, gitproviders.GitProviderGitHub, GITHUB_ORG)
defer func() {
selectCluster(cluster1)
deleteWorkload(tip.workloadName, tip.workloadNamespace)
selectCluster(cluster2)
selectCluster(cluster1Context)
deleteWorkload(tip.workloadName, tip.workloadNamespace)
deleteCluster(cluster2Name)
}()

By("And application repos do not already exist", func() {
deleteRepo(appRepoName, gitproviders.GitProviderGitHub, GITHUB_ORG)
})

By("And application workload is not already deployed to clusters", func() {
selectCluster(cluster1)
selectCluster(cluster1Context)
deleteWorkload(tip.workloadName, tip.workloadNamespace)
selectCluster(cluster2)
selectCluster(cluster2Context)
deleteWorkload(tip.workloadName, tip.workloadNamespace)
})

Expand All @@ -607,30 +608,30 @@ var _ = Describe("Weave GitOps Add App Tests", func() {
})

By("And I install gitops to my active clusters", func() {
selectCluster(cluster1)
selectCluster(cluster1Context)
installAndVerifyWego(WEGO_DEFAULT_NAMESPACE, appRepoRemoteURL)
selectCluster(cluster2)
selectCluster(cluster2Context)
installAndVerifyWego(WEGO_DEFAULT_NAMESPACE, appRepoRemoteURL)
})

By("And I run gitops add command for app", func() {
selectCluster(cluster1)
selectCluster(cluster1Context)
runWegoAddCommand(repoAbsolutePath, addCommand, WEGO_DEFAULT_NAMESPACE)
selectCluster(cluster2)
selectCluster(cluster2Context)
runWegoAddCommand(repoAbsolutePath, addCommand, WEGO_DEFAULT_NAMESPACE)
})

By("Then I should see gitops add command linked the repo to the cluster", func() {
selectCluster(cluster1)
selectCluster(cluster1Context)
verifyWegoAddCommand(appName, WEGO_DEFAULT_NAMESPACE)
selectCluster(cluster2)
selectCluster(cluster2Context)
verifyWegoAddCommand(appName, WEGO_DEFAULT_NAMESPACE)
})

By("And I should see workload for app is deployed to the cluster", func() {
selectCluster(cluster1)
selectCluster(cluster1Context)
verifyWorkloadIsDeployed(tip.workloadName, tip.workloadNamespace)
selectCluster(cluster2)
selectCluster(cluster2Context)
verifyWorkloadIsDeployed(tip.workloadName, tip.workloadNamespace)
})
})
Expand Down Expand Up @@ -1636,7 +1637,7 @@ var _ = Describe("Weave GitOps Add Tests With Long Cluster Name", func() {
var err error

clusterName = "kind-123456789012345678901234567890"
_, err = ResetOrCreateClusterWithName(WEGO_DEFAULT_NAMESPACE, deleteWegoRuntime, clusterName, false)
_, _, err = ResetOrCreateClusterWithName(WEGO_DEFAULT_NAMESPACE, deleteWegoRuntime, clusterName, false)
Expect(err).ShouldNot(HaveOccurred())
})

Expand Down
8 changes: 4 additions & 4 deletions test/acceptance/test/install_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var _ = Describe("Weave GitOps Install Tests", func() {
defer deleteNamespace(namespace)

By("And I have a brand new cluster", func() {
_, err := ResetOrCreateCluster(WEGO_DEFAULT_NAMESPACE, true)
_, _, err := ResetOrCreateCluster(WEGO_DEFAULT_NAMESPACE, true)
Expect(err).ShouldNot(HaveOccurred())
})

Expand All @@ -85,7 +85,7 @@ var _ = Describe("Weave GitOps Install Tests", func() {
namespace := "test-namespace"

By("And I have a brand new cluster", func() {
_, err := ResetOrCreateCluster(namespace, true)
_, _, err := ResetOrCreateCluster(namespace, true)
Expect(err).ShouldNot(HaveOccurred())
})

Expand Down Expand Up @@ -120,7 +120,7 @@ var _ = Describe("Weave GitOps Install Tests", func() {
namespace := "test-namespace"

By("And I have a brand new cluster", func() {
_, err := ResetOrCreateCluster(namespace, true)
_, _, err := ResetOrCreateCluster(namespace, true)
Expect(err).ShouldNot(HaveOccurred())
})

Expand Down Expand Up @@ -165,7 +165,7 @@ var _ = Describe("Weave GitOps Install Tests", func() {
var uninstallDryRunOutput string

By("And I have a brand new cluster", func() {
_, err := ResetOrCreateCluster(WEGO_DEFAULT_NAMESPACE, true)
_, _, err := ResetOrCreateCluster(WEGO_DEFAULT_NAMESPACE, true)
Expect(err).ShouldNot(HaveOccurred())
})

Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/test/ui_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ = Describe("Weave GitOps UI Test", func() {

By("Given I have a brand new cluster", func() {

_, err = ResetOrCreateCluster(WEGO_DEFAULT_NAMESPACE, deleteWegoRuntime)
_, _, err = ResetOrCreateCluster(WEGO_DEFAULT_NAMESPACE, deleteWegoRuntime)
Expect(err).ShouldNot(HaveOccurred())

Expect(FileExists(WEGO_BIN_PATH)).To(BeTrue())
Expand Down
21 changes: 12 additions & 9 deletions test/acceptance/test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,17 @@ func FileExists(name string) bool {

func selectCluster(context string) {
_, err := exec.Command("kubectl", "config", "use-context", context).Output()
fmt.Printf("CONTEXT: %s, ERR: %v\n", context, err)
Expect(err).ShouldNot(HaveOccurred())
}

func deleteCluster(clusterName string) {
_, err := exec.Command("kind", "delete", "cluster", "--name", clusterName).Output()
Expect(err).ShouldNot(HaveOccurred())
}

func getClusterName() string {
out, err := exec.Command("kubectl", "config", "current-context").Output()
Expect(err).ShouldNot(HaveOccurred())
fmt.Printf("GOT CONTEXT: %s, ERR: %v\n", out, err)

return string(bytes.TrimSuffix(out, []byte("\n")))
}
Expand Down Expand Up @@ -166,11 +169,11 @@ func setupGitlabSSHKey(sshKeyPath string) {
}
}

func ResetOrCreateCluster(namespace string, deleteWegoRuntime bool) (string, error) {
func ResetOrCreateCluster(namespace string, deleteWegoRuntime bool) (string, string, error) {
return ResetOrCreateClusterWithName(namespace, deleteWegoRuntime, "", false)
}

func ResetOrCreateClusterWithName(namespace string, deleteWegoRuntime bool, clusterName string, keepExistingClusters bool) (string, error) {
func ResetOrCreateClusterWithName(namespace string, deleteWegoRuntime bool, clusterName string, keepExistingClusters bool) (string, string, error) {
supportedProviders := []string{"kind", "kubectl"}
supportedK8SVersions := []string{"1.19.1", "1.20.2", "1.21.1"}

Expand All @@ -186,12 +189,12 @@ func ResetOrCreateClusterWithName(namespace string, deleteWegoRuntime bool, clus

if !contains(supportedProviders, provider) {
log.Errorf("Cluster provider %s is not supported for testing", provider)
return clusterName, errors.New("Unsupported provider")
return clusterName, "", errors.New("Unsupported provider")
}

if !contains(supportedK8SVersions, k8sVersion) {
log.Errorf("Kubernetes version %s is not supported for testing", k8sVersion)
return clusterName, errors.New("Unsupported kubernetes version")
return clusterName, "", errors.New("Unsupported kubernetes version")
}

//For kubectl, point to a valid cluster, we will try to reset the namespace only
Expand Down Expand Up @@ -225,7 +228,7 @@ func ResetOrCreateClusterWithName(namespace string, deleteWegoRuntime bool, clus
log.Infof("Failed to create kind cluster")
log.Fatal(err)

return clusterName, err
return clusterName, "", err
}
}

Expand All @@ -235,10 +238,10 @@ func ResetOrCreateClusterWithName(namespace string, deleteWegoRuntime bool, clus

if err != nil {
log.Infof("Cluster system pods are not ready after waiting for 5 minutes, This can cause tests failures.")
return clusterName, err
return clusterName, "", err
}

return getClusterName(), nil
return clusterName, getClusterName(), nil
}

func initAndCreateEmptyRepo(appRepoName string, providerName gitproviders.GitProviderName, isPrivateRepo bool, org string) string {
Expand Down

0 comments on commit 002c369

Please sign in to comment.