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

fix deploy #218

Merged
merged 4 commits into from
May 26, 2021
Merged
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
53 changes: 13 additions & 40 deletions test/acceptance/test/core_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,17 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/fluxcd/go-git-providers/github"
"github.com/fluxcd/go-git-providers/gitprovider"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/prometheus/common/log"
"github.com/weaveworks/weave-gitops/pkg/cmdimpl"
"github.com/weaveworks/weave-gitops/pkg/flux"
"github.com/weaveworks/weave-gitops/pkg/fluxops"
"github.com/weaveworks/weave-gitops/pkg/status"
"github.com/weaveworks/weave-gitops/pkg/utils"
"github.com/weaveworks/weave-gitops/pkg/version"
)

const nginxDeployment = `apiVersion: v1
Expand Down Expand Up @@ -88,8 +83,13 @@ var _ = Describe("WEGO Acceptance Tests", func() {
By("Setup test", func() {
Expect(setupTest()).Should(Succeed())
Expect(ensureWegoRepoIsAbsent()).Should(Succeed())
Expect(ensureFluxVersion()).Should(Succeed())
Expect(installWego()).Should(Succeed())

//Install wego
command := exec.Command("sh", "-c", fmt.Sprintf("%s install | kubectl apply -f -", WEGO_BIN_PATH))
session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ShouldNot(HaveOccurred())
Eventually(session).Should(gexec.Exit())

Expect(waitForFluxInstall()).Should(Succeed())
Expect(setUpTestRepo()).Should(Succeed())
})
Expand Down Expand Up @@ -119,8 +119,8 @@ var _ = Describe("WEGO Acceptance Tests", func() {
By("kubectl get pods -n wego-system should list the source and kustomize controllers", func() {
Expect(waitForNginxDeployment()).Should(Succeed())
Expect(runCommandForGinkgo("kubectl get pods -n wego-system")).Should(Succeed())
Eventually(session).Should(gbytes.Say("kustomize-controller"))
Eventually(session).Should(gbytes.Say("source-controller"))
Eventually(string(session.Wait().Out.Contents())).Should(ContainSubstring("kustomize-controller"))
Eventually(string(session.Wait().Out.Contents())).Should(ContainSubstring("source-controller"))
})
})

Expand All @@ -147,8 +147,8 @@ var _ = Describe("WEGO Acceptance Tests", func() {
By("kubectl get pods -n wego-system should list the source and kustomize controllers", func() {
Expect(waitForNginxDeployment()).Should(Succeed())
Expect(runCommandForGinkgo("kubectl get pods -n wego-system")).Should(Succeed())
Eventually(session).Should(gbytes.Say("kustomize-controller"))
Eventually(session).Should(gbytes.Say("source-controller"))
Eventually(string(session.Wait().Out.Contents())).Should(ContainSubstring("kustomize-controller"))
Eventually(string(session.Wait().Out.Contents())).Should(ContainSubstring("source-controller"))
})
})
})
Expand Down Expand Up @@ -239,25 +239,6 @@ func ensureWegoRepoAccess() (*gitprovider.RepositoryVisibility, error) {
return nil, fmt.Errorf("wepo does not exist")
}

func ensureFluxVersion() error {
if version.FluxVersion == "undefined" {
tomlpath, err := filepath.Abs("../../../tools/bin/stoml")
if err != nil {
return err
}
deppath, err := filepath.Abs("../../../tools/dependencies.toml")
if err != nil {
return err
}
out, err := utils.CallCommandSilently(fmt.Sprintf("%s %s flux.version", tomlpath, deppath))
if err != nil {
return err
}
version.FluxVersion = strings.TrimRight(string(out), "\n")
}
return nil
}

func waitForNginxDeployment() error {
for i := 1; i < 61; i++ {
log.Infof("Waiting for nginx... try: %d of 60\n", i)
Expand All @@ -273,23 +254,15 @@ func waitForNginxDeployment() error {
func waitForFluxInstall() error {
for i := 1; i < 11; i++ {
log.Infof("Waiting for flux... try: %d of 10\n", i)
if status.GetClusterStatus() == status.FluxInstalled {
err := utils.CallCommandForEffectWithDebug("kubectl get customresourcedefinition buckets.source.toolkit.fluxcd.io")
if err == nil {
return nil
}
time.Sleep(5 * time.Second)
}
return fmt.Errorf("Failed to install flux")
}

func installWego() error {
flux.SetupFluxBin()
manifests, err := cmdimpl.Install(cmdimpl.InstallParamSet{Namespace: "wego-system"})
if err != nil {
return err
}
return utils.CallCommandForEffectWithInputPipeAndDebug("kubectl apply -f -", string(manifests))
}

func getWegoRepoName() (string, error) {
return fluxops.GetRepoName()
}
Expand Down