This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(provisioning): add ginkgo tests for volume provisioning (#28)
Signed-off-by: Payes Anand <[email protected]>
- Loading branch information
Showing
10 changed files
with
497 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright © 2020 The OpenEBS Authors | ||
# | ||
# 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 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
GOFLAGS=-mod=vendor | ||
export GOFLAGS | ||
GINKGO=$(GOPATH)/bin/ginkgo | ||
KUBECTL=/usr/local/bin/kubectl | ||
|
||
|
||
# If you want to change the Kubernetes version for e2e test, specify this variable from command line. | ||
# e.g. $ make TEST_KUBERNETES_VERSION=1.17 test | ||
TEST_KUBERNETES_VERSION=1.17 | ||
|
||
ifeq ($(TEST_KUBERNETES_VERSION),1.17) | ||
KUBERNETES_VERSION=1.17.2 | ||
endif | ||
|
||
|
||
tests: | ||
env \ | ||
PATH=$(PATH) \ | ||
GOPATH=$(GOPATH) \ | ||
GO111MODULE=on \ | ||
GOFLAGS=$(GOFLAGS) \ | ||
TEST_KUBERNETES_VERSION=$(TEST_KUBERNETES_VERSION) \ | ||
$(GINKGO) --failFast -v . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright © 2020 The OpenEBS Authors | ||
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 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package volume | ||
|
||
import ( | ||
"bytes" | ||
"os/exec" | ||
) | ||
|
||
func execAtLocal(cmd string, input []byte, args ...string) ([]byte, []byte, error) { | ||
var stdout, stderr bytes.Buffer | ||
command := exec.Command(cmd, args...) | ||
command.Stdout = &stdout | ||
command.Stderr = &stderr | ||
|
||
if len(input) != 0 { | ||
command.Stdin = bytes.NewReader(input) | ||
} | ||
|
||
err := command.Run() | ||
return stdout.Bytes(), stderr.Bytes(), err | ||
} | ||
|
||
func Kubectl(args ...string) ([]byte, []byte, error) { | ||
return execAtLocal("kubectl", nil, args...) | ||
} | ||
|
||
func KubectlWithInput(input []byte, args ...string) ([]byte, []byte, error) { | ||
return execAtLocal("kubectl", input, args...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2020 The OpenEBS Authors | ||
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 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package volume | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
) | ||
|
||
var _ = Describe("[csi] [jiva] TEST VOLUME PROVISIONING WITH APP POD RESTART", func() { | ||
BeforeEach(prepareForVolumeCreationTest) | ||
AfterEach(cleanupAfterVolumeCreationTest) | ||
|
||
Context("App is deployed and restarted on pvc with replica count 1", func() { | ||
It("Should run Volume Creation Test", volumeCreationTest) | ||
}) | ||
}) | ||
|
||
func volumeCreationTest() { | ||
By("creating and verifying PVC bound status", createAndVerifyPVC) | ||
By("Creating and deploying app pod", createDeployVerifyApp) | ||
By("Restarting app pod and verifying app pod running status", restartAppPodAndVerifyRunningStatus) | ||
By("Deleting application deployment", deleteAppDeployment) | ||
By("Deleting pvc", deletePVC) | ||
} | ||
|
||
func prepareForVolumeCreationTest() { | ||
By("Creating storage class", createStorageClass) | ||
} | ||
|
||
func cleanupAfterVolumeCreationTest() { | ||
By("Deleting storage class", deleteStorageClass) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
Copyright © 2020 The OpenEBS Authors | ||
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 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package volume | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"math/rand" | ||
"testing" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
appsv1 "k8s.io/api/apps/v1" | ||
|
||
// auth plugins | ||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" | ||
) | ||
|
||
var ( | ||
openebsNamespace = "openebs" | ||
) | ||
|
||
func TestMtest(t *testing.T) { | ||
// if os.Getenv("E2ETEST") == "" { | ||
// t.Skip("Run under e2e/") | ||
//} | ||
rand.Seed(time.Now().UnixNano()) | ||
|
||
RegisterFailHandler(Fail) | ||
|
||
SetDefaultEventuallyPollingInterval(time.Second) | ||
SetDefaultEventuallyTimeout(time.Minute) | ||
|
||
RunSpecs(t, "Test on sanity") | ||
} | ||
|
||
func waitKindnet() error { | ||
stdout, stderr, err := Kubectl("-n=kube-system", "get", "ds/kindnet", "-o", "json") | ||
if err != nil { | ||
return errors.New(string(stderr)) | ||
} | ||
|
||
var ds appsv1.DaemonSet | ||
err = json.Unmarshal(stdout, &ds) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if ds.Status.NumberReady != 4 { | ||
return fmt.Errorf("numberReady is not 4: %d", ds.Status.NumberReady) | ||
} | ||
return nil | ||
} | ||
|
||
var _ = BeforeSuite(func() { | ||
|
||
var err error | ||
|
||
By("creating namespace") | ||
stdout, stderr, err := Kubectl("create", "ns", NSName) | ||
Expect(err).ShouldNot(HaveOccurred(), "stdout=%s, stderr=%s", stdout, stderr) | ||
By("Creating JivaVolumePolicy", createJivaVolumePolicy) | ||
|
||
}) | ||
|
||
var _ = AfterSuite(func() { | ||
|
||
By("Deleting JivaVolumePolicy", deleteJivaVolumePolicy) | ||
By("Deleting namespace") | ||
stdout, stderr, err := Kubectl("delete", "ns", NSName) | ||
Expect(err).ShouldNot(HaveOccurred(), "stdout=%s, stderr=%s", stdout, stderr) | ||
}) |
Oops, something went wrong.