Skip to content

Commit

Permalink
Added more endtoend tests (#303)
Browse files Browse the repository at this point in the history
* Added more endtoend tests

Signed-off-by: anishakj <[email protected]>

* Fixed formatting errors

Signed-off-by: anishakj <[email protected]>

* Fixed secret creation

Signed-off-by: anishakj <[email protected]>

* Added pull secrets

Signed-off-by: anishakj <[email protected]>
  • Loading branch information
anishakj authored Mar 2, 2021
1 parent 7a18be1 commit cda03d2
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
sudo kubectl cluster-info
echo "cluster info"
sudo kubectl -n kube-system get pod -o wide
sudo kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username="testanisha" --docker-password="123456789" [email protected]
- name: E2E
run: sudo make test-e2e
publish:
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw=
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk=
Expand Down
18 changes: 18 additions & 0 deletions pkg/test/e2e/e2eutil/zookeepercluster_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,21 @@ func DeletePods(t *testing.T, f *framework.Framework, ctx *framework.TestCtx, z
}
return nil
}
func CheckAdminService(t *testing.T, f *framework.Framework, ctx *framework.TestCtx, z *api.ZookeeperCluster) error {
listOptions := metav1.ListOptions{
LabelSelector: labels.SelectorFromSet(map[string]string{"app": z.GetName()}).String(),
}
serviceList, err := f.KubeClient.CoreV1().Services(z.Namespace).List(listOptions)
if err != nil {
return err
}

for _, sn := range serviceList.Items {
if sn.Name == "zookeeper-admin-server" {
t.Logf("Admin service is enabled")
t.Logf("servicenameis %v", sn.Name)
return nil
}
}
return fmt.Errorf("Admin Service is not enabled")
}
3 changes: 3 additions & 0 deletions test/e2e/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func testCreateRecreateCluster(t *testing.T) {
err = zk_e2eutil.WaitForClusterToBecomeReady(t, f, ctx, zk, podSize)
g.Expect(err).NotTo(HaveOccurred())

err = zk_e2eutil.CheckAdminService(t, f, ctx, zk)
g.Expect(err).NotTo(HaveOccurred())

err = zk_e2eutil.DeleteCluster(t, f, ctx, zk)
g.Expect(err).NotTo(HaveOccurred())

Expand Down
67 changes: 67 additions & 0 deletions test/e2e/image_pullsecret_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright (c) 2018 Dell Inc., or its subsidiaries. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

package e2e

import (
"testing"

. "github.com/onsi/gomega"
framework "github.com/operator-framework/operator-sdk/pkg/test"
zk_e2eutil "github.com/pravega/zookeeper-operator/pkg/test/e2e/e2eutil"
v1 "k8s.io/api/core/v1"
)

// Test create and recreate a Zookeeper cluster with the same name
func testImagePullSecret(t *testing.T) {
g := NewGomegaWithT(t)

doCleanup := true
ctx := framework.NewTestCtx(t)
defer func() {
if doCleanup {
ctx.Cleanup()
}
}()

namespace, err := ctx.GetNamespace()
g.Expect(err).NotTo(HaveOccurred())
f := framework.Global

defaultCluster := zk_e2eutil.NewDefaultCluster(namespace)

defaultCluster.WithDefaults()
defaultCluster.Status.Init()
defaultCluster.Spec.Persistence.VolumeReclaimPolicy = "Delete"
defaultCluster.Spec.Image.Repository = "testanisha/zookeeper"
defaultCluster.Spec.Image.Tag = "checksecret_1"
defaultCluster.Spec.Pod.ImagePullSecrets = []v1.LocalObjectReference{
{
Name: "regcred",
},
}
zk, err := zk_e2eutil.CreateCluster(t, f, ctx, defaultCluster)
g.Expect(err).NotTo(HaveOccurred())

// A default Zookeeper cluster should have 3 replicas
podSize := 3
err = zk_e2eutil.WaitForClusterToBecomeReady(t, f, ctx, zk, podSize)
g.Expect(err).NotTo(HaveOccurred())

err = zk_e2eutil.CheckAdminService(t, f, ctx, zk)
g.Expect(err).NotTo(HaveOccurred())

err = zk_e2eutil.DeleteCluster(t, f, ctx, zk)
g.Expect(err).NotTo(HaveOccurred())

err = zk_e2eutil.WaitForClusterToTerminate(t, f, ctx, zk)
g.Expect(err).NotTo(HaveOccurred())

}
4 changes: 4 additions & 0 deletions test/e2e/scale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func testScaleCluster(t *testing.T) {
err = zk_e2eutil.UpdateCluster(t, f, ctx, zk)
g.Expect(err).NotTo(HaveOccurred())

podDeleteCount := 2
err = zk_e2eutil.DeletePods(t, f, ctx, zk, podDeleteCount)
g.Expect(err).NotTo(HaveOccurred())

err = zk_e2eutil.WaitForClusterToBecomeReady(t, f, ctx, zk, podSize)
g.Expect(err).NotTo(HaveOccurred())

Expand Down
1 change: 1 addition & 0 deletions test/e2e/zookeepercluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func testZookeeperCluster(t *testing.T) {
"testMultiZKCluster": testMultiZKCluster,
"testUpgradeCluster": testUpgradeCluster,
"testCreateRecreateCluster": testCreateRecreateCluster,
"testImagePullSecret": testImagePullSecret,
"testScaleCluster": testScaleCluster,
"testEphemeralStorage": testEphemeralStorage,
}
Expand Down

0 comments on commit cda03d2

Please sign in to comment.