mirror of https://github.com/fluxcd/flux2.git
implement e2e tests for install manifests
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>pull/1605/head
parent
0ae39d5a0a
commit
ca08157ddd
@ -0,0 +1,64 @@
|
|||||||
|
// +build e2e
|
||||||
|
|
||||||
|
package e2e
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
var fluxBinary string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
fluxBinary = os.Getenv("FLUX_E2E_BINARY")
|
||||||
|
if fluxBinary == "" {
|
||||||
|
fluxBinary = "../../bin/flux"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func run(name string, args ...string) ([]string, error) {
|
||||||
|
cmd := exec.Command(name, args...)
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
lines := strings.Split(string(out), "\n")
|
||||||
|
return lines, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func runAsBytes(name string, args ...string) ([]byte, error) {
|
||||||
|
cmd := exec.Command(name, args...)
|
||||||
|
return cmd.CombinedOutput()
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAndWaitUntilObjectNotFound(args ...string) {
|
||||||
|
for ; ; {
|
||||||
|
var lines []string
|
||||||
|
var err error
|
||||||
|
|
||||||
|
lines, err = run(fluxBinary, append([]string{"get"}, args...)...)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if args[0] == "source" &&
|
||||||
|
args[1] == "git" &&
|
||||||
|
lines[0] == "✗ no GitRepository objects found in flux-system namespace" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if args[0] == "kustomization" &&
|
||||||
|
lines[0] == "✗ no Kustomization objects found in flux-system namespace" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteObject(t *testing.T, args ...string) {
|
||||||
|
_, err := run(fluxBinary, append([]string{"delete"}, args...)...)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
// +build e2e
|
||||||
|
|
||||||
|
package e2e
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"gotest.tools/golden"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFluxInstallManifests(t *testing.T) {
|
||||||
|
actual, err := runAsBytes(fluxBinary, "install")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
golden.Assert(t, string(actual), "../../../testdata/flux_install_manifests.golden")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFluxInstallManifestsExtra(t *testing.T) {
|
||||||
|
actual, err := runAsBytes(fluxBinary, "install", "--components-extra", "image-reflector-controller,image-automation-controller")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
golden.Assert(t, string(actual), "../../../testdata/flux_install_manifests_extra.golden")
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
✚ generating manifests
|
||||||
|
✔ manifests build completed
|
||||||
|
► installing components in flux-system namespace
|
||||||
|
◎ verifying installation
|
||||||
|
✔ helm-controller: deployment ready
|
||||||
|
✔ kustomize-controller: deployment ready
|
||||||
|
✔ notification-controller: deployment ready
|
||||||
|
✔ source-controller: deployment ready
|
||||||
|
✔ install finished
|
@ -0,0 +1,11 @@
|
|||||||
|
✚ generating manifests
|
||||||
|
✔ manifests build completed
|
||||||
|
► installing components in flux-system namespace
|
||||||
|
◎ verifying installation
|
||||||
|
✔ helm-controller: deployment ready
|
||||||
|
✔ image-automation-controller: deployment ready
|
||||||
|
✔ image-reflector-controller: deployment ready
|
||||||
|
✔ kustomize-controller: deployment ready
|
||||||
|
✔ notification-controller: deployment ready
|
||||||
|
✔ source-controller: deployment ready
|
||||||
|
✔ install finished
|
Loading…
Reference in New Issue