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

Addons: add OLM support #8129

Merged
merged 2 commits into from
May 26, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Add integration test TestOlmAddon
Enable olm and install etcd operator checking successful installation
  • Loading branch information
blues-man committed May 21, 2020
commit c9227a080f7353db63af6014207362f791204a9d
105 changes: 105 additions & 0 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,108 @@ func validateHelmTillerAddon(ctx context.Context, t *testing.T, profile string)
t.Errorf("failed disabling helm-tiller addon. arg %q.s %v", rr.Command(), err)
}
}

func TestOlmAddon(t *testing.T) {
profile := UniqueProfileName("addons")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(40))
defer Cleanup(t, profile, cancel)

args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "--addons=olm"}, StartArgs()...)
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}

// Parallelized tests
t.Run("parallel", func(t *testing.T) {
tests := []struct {
name string
validator validateFunc
}{
{"Olm", validateOlmAddon},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
MaybeParallel(t)
tc.validator(ctx, t, profile)
})
}
})

// Assert that disable/enable works offline
rr, err = Run(t, exec.CommandContext(ctx, Target(), "stop", "-p", profile))
if err != nil {
t.Errorf("failed to stop minikube. args %q : %v", rr.Command(), err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "addons", "enable", "dashboard", "-p", profile))
if err != nil {
t.Errorf("failed to enable dashboard addon: args %q : %v", rr.Command(), err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "addons", "disable", "dashboard", "-p", profile))
if err != nil {
t.Errorf("failed to disable dashboard addon: args %q : %v", rr.Command(), err)
}
}

func validateOlmAddon(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)

client, err := kapi.Client(profile)
if err != nil {
t.Fatalf("failed to get Kubernetes client for %s: %v", profile, err)
}

start := time.Now()
if err := kapi.WaitForDeploymentToStabilize(client, "olm", "catalog-operator", Minutes(6)); err != nil {
t.Errorf("failed waiting for catalog-operator deployment to stabilize: %v", err)
}
t.Logf("catalog-operator stabilized in %s", time.Since(start))
if err := kapi.WaitForDeploymentToStabilize(client, "olm", "olm-operator", Minutes(6)); err != nil {
t.Errorf("failed waiting for olm-operator deployment to stabilize: %v", err)
}
t.Logf("olm-operator stabilized in %s", time.Since(start))
if err := kapi.WaitForDeploymentToStabilize(client, "olm", "packageserver", Minutes(6)); err != nil {
t.Errorf("failed waiting for packageserver deployment to stabilize: %v", err)
}
t.Logf("packageserver stabilized in %s", time.Since(start))

if _, err := PodWait(ctx, t, profile, "olm", "app=catalog-operator", Minutes(6)); err != nil {
t.Fatalf("failed waiting for pod catalog-operator: %v", err)
}
if _, err := PodWait(ctx, t, profile, "olm", "app=olm-operator", Minutes(6)); err != nil {
t.Fatalf("failed waiting for pod olm-operator: %v", err)
}
if _, err := PodWait(ctx, t, profile, "olm", "app=packageserver", Minutes(6)); err != nil {
t.Fatalf("failed waiting for pod packageserver: %v", err)
}
if _, err := PodWait(ctx, t, profile, "olm", "olm.catalogSource=operatorhubio-catalog", Minutes(6)); err != nil {
t.Fatalf("failed waiting for pod operatorhubio-catalog: %v", err)
}

// Install one sample Operator such as etcd
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "create", "-f", "https://operatorhub.io/install/etcd.yaml"))
if err != nil {
t.Logf("etcd operator installation with %s failed: %v", rr.Command(), err)
}

want := "Succeeded"
checkOperatorInstalled := func() error {
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "csv", "-n", "my-etcd"))
if err != nil {
return err
}
if rr.Stderr.String() != "" {
t.Logf("%v: unexpected stderr: %s", rr.Command(), rr.Stderr)
}
if !strings.Contains(rr.Stdout.String(), want) {
return fmt.Errorf("%v stdout = %q, want %q", rr.Command(), rr.Stdout, want)
}
return nil
}

// Operator installation takes a while
if err := retry.Expo(checkOperatorInstalled, time.Second*3, Minutes(6)); err != nil {
t.Errorf("failed checking operator installed: %v", err.Error())
}
}