Skip to content

Commit 892c7a8

Browse files
author
Mathusan Selvarajah
committed
add e2e test files
1 parent 575e2fe commit 892c7a8

File tree

2,254 files changed

+538848
-36774
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,254 files changed

+538848
-36774
lines changed

Gopkg.lock

Lines changed: 714 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@
4242

4343
[[constraint]]
4444
name = "k8s.io/kubernetes"
45-
version = "v1.12.0"
45+
version = "v1.14.0"
4646

4747
[[override]]
4848
name = "k8s.io/kubernetes"
49-
version = "v1.12.0"
49+
version = "v1.14.0"
5050

5151
[[override]]
52-
version = "kubernetes-1.12.0"
52+
version = "kubernetes-1.14.0"
5353
name = "k8s.io/api"
5454

5555
[[override]]
56-
version = "kubernetes-1.12.0"
56+
version = "kubernetes-1.14.0"
5757
name = "k8s.io/apiserver"
5858

5959
[[override]]
60-
version = "kubernetes-1.12.0"
60+
version = "kubernetes-1.14.0"
6161
name = "k8s.io/apiextensions-apiserver"
6262

6363
[[override]]
@@ -68,10 +68,18 @@
6868
name = "github.com/json-iterator/go"
6969
version = "1.1.4"
7070

71+
[[override]]
72+
name = "k8s.io/client-go"
73+
branch = "master"
74+
7175
[[override]]
7276
name = "gopkg.in/square/go-jose.v2"
7377
version = "2.1.7"
7478

79+
[[override]]
80+
source = "https://github.com/fsnotify/fsnotify/archive/v1.4.7.tar.gz"
81+
name = "gopkg.in/fsnotify.v1"
82+
7583
[prune]
7684
non-go = true
7785
go-tests = true

cmd/nfsplugin/nfsplugin_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package main
15+
16+
import (
17+
"flag"
18+
_ "github.com/kubernetes-csi/csi-driver-nfs/test"
19+
. "github.com/onsi/ginkgo"
20+
. "github.com/onsi/gomega"
21+
"k8s.io/kubernetes/test/e2e/framework"
22+
"testing"
23+
)
24+
25+
func init() {
26+
framework.HandleFlags()
27+
framework.AfterReadingAllFlags(&framework.TestContext)
28+
}
29+
30+
func Test(t *testing.T) {
31+
flag.Parse()
32+
RegisterFailHandler(Fail)
33+
RunSpecs(t, "CSI Suite")
34+
}

test/csi-volumes.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package test
15+
16+
import (
17+
. "github.com/onsi/ginkgo"
18+
_ "github.com/onsi/gomega"
19+
"k8s.io/kubernetes/test/e2e/framework"
20+
"k8s.io/kubernetes/test/e2e/framework/testfiles"
21+
"k8s.io/kubernetes/test/e2e/storage/testsuites"
22+
"k8s.io/kubernetes/test/e2e/storage/utils"
23+
"path"
24+
)
25+
26+
var CSITestSuites = []func() testsuites.TestSuite{
27+
testsuites.InitVolumesTestSuite,
28+
testsuites.InitVolumeIOTestSuite,
29+
testsuites.InitVolumeModeTestSuite,
30+
testsuites.InitSubPathTestSuite,
31+
testsuites.InitProvisioningTestSuite,
32+
}
33+
34+
// This executes testSuites for csi volumes.
35+
var _ = utils.SIGDescribe("CSI Volumes", func() {
36+
testfiles.AddFileSource(testfiles.RootFileSource{Root: path.Join(framework.TestContext.RepoRoot, "../../deploy/kubernetes/")})
37+
38+
curDriver := NFSdriver()
39+
Context(testsuites.GetDriverNameWithFeatureTags(curDriver), func() {
40+
testsuites.DefineTestSuite(curDriver, CSITestSuites)
41+
})
42+
43+
})

test/nfs-testdriver.go

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package test
15+
16+
import (
17+
"fmt"
18+
. "github.com/onsi/ginkgo"
19+
"k8s.io/api/core/v1"
20+
"k8s.io/apimachinery/pkg/util/sets"
21+
"k8s.io/kubernetes/test/e2e/framework"
22+
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
23+
"k8s.io/kubernetes/test/e2e/storage/testsuites"
24+
)
25+
26+
type nfsDriver struct {
27+
driverInfo testsuites.DriverInfo
28+
manifests []string
29+
}
30+
31+
var NFSdriver = InitNFSDriver
32+
33+
type nfsVolume struct {
34+
serverIP string
35+
serverPod *v1.Pod
36+
f *framework.Framework
37+
}
38+
39+
// initNFSDriver returns nfsDriver that implements TestDriver interface
40+
func initNFSDriver(name string, manifests ...string) testsuites.TestDriver {
41+
return &nfsDriver{
42+
driverInfo: testsuites.DriverInfo{
43+
Name: name,
44+
MaxFileSize: testpatterns.FileSizeLarge,
45+
SupportedFsType: sets.NewString(
46+
"", // Default fsType
47+
),
48+
Capabilities: map[testsuites.Capability]bool{
49+
testsuites.CapPersistence: true,
50+
testsuites.CapExec: true,
51+
},
52+
},
53+
manifests: manifests,
54+
}
55+
}
56+
57+
func InitNFSDriver() testsuites.TestDriver {
58+
59+
return initNFSDriver("csi-nfsplugin",
60+
"csi-attacher-nfsplugin.yaml",
61+
"csi-attacher-rbac.yaml",
62+
"csi-nodeplugin-nfsplugin.yaml",
63+
"csi-nodeplugin-rbac.yaml")
64+
65+
}
66+
67+
var _ testsuites.TestDriver = &nfsDriver{}
68+
var _ testsuites.PreprovisionedVolumeTestDriver = &nfsDriver{}
69+
var _ testsuites.PreprovisionedPVTestDriver = &nfsDriver{}
70+
71+
func (n *nfsDriver) GetDriverInfo() *testsuites.DriverInfo {
72+
return &n.driverInfo
73+
}
74+
75+
func (n *nfsDriver) SkipUnsupportedTest(pattern testpatterns.TestPattern) {
76+
if pattern.VolType == testpatterns.DynamicPV {
77+
framework.Skipf("NFS Driver does not support dynamic provisioning -- skipping")
78+
}
79+
}
80+
81+
func (n *nfsDriver) GetPersistentVolumeSource(readOnly bool, fsType string, volume testsuites.TestVolume) (*v1.PersistentVolumeSource, *v1.VolumeNodeAffinity) {
82+
nv, _ := volume.(*nfsVolume)
83+
return &v1.PersistentVolumeSource{
84+
CSI: &v1.CSIPersistentVolumeSource{
85+
Driver: n.driverInfo.Name,
86+
VolumeHandle: "nfs-vol",
87+
VolumeAttributes: map[string]string{
88+
"server": nv.serverIP,
89+
"share": "/",
90+
"readOnly": "true",
91+
},
92+
},
93+
}, nil
94+
}
95+
96+
func (n *nfsDriver) PrepareTest(f *framework.Framework) (*testsuites.PerTestConfig, func()) {
97+
config := &testsuites.PerTestConfig{
98+
Driver: n,
99+
Prefix: "nfs",
100+
Framework: f,
101+
}
102+
103+
//Install the nfs driver from the manifests
104+
cleanup, err := config.Framework.CreateFromManifests(nil, n.manifests...)
105+
106+
if err != nil {
107+
framework.Failf("deploying %s driver: %v", n.driverInfo.Name, err)
108+
}
109+
110+
return config, func() {
111+
By(fmt.Sprintf("uninstalling %s driver", n.driverInfo.Name))
112+
cleanup()
113+
}
114+
}
115+
116+
func (n *nfsDriver) CreateVolume(config *testsuites.PerTestConfig, volType testpatterns.TestVolType) testsuites.TestVolume {
117+
f := config.Framework
118+
cs := f.ClientSet
119+
ns := f.Namespace
120+
121+
switch volType {
122+
case testpatterns.InlineVolume:
123+
fallthrough
124+
case testpatterns.PreprovisionedPV:
125+
126+
//Create nfs server pod
127+
c := framework.VolumeTestConfig{
128+
Namespace: ns.Name,
129+
Prefix: "nfs",
130+
ServerImage: "gcr.io/kubernetes-e2e-test-images/volume/nfs:1.0",
131+
ServerPorts: []int{2049},
132+
ServerVolumes: map[string]string{"": "/exports"},
133+
ServerReadyMessage: "NFS started",
134+
}
135+
config.ServerConfig = &c
136+
serverPod, serverIP := framework.CreateStorageServer(cs, c)
137+
138+
return &nfsVolume{
139+
serverIP: serverIP,
140+
serverPod: serverPod,
141+
f: f,
142+
}
143+
144+
case testpatterns.DynamicPV:
145+
// Do nothing
146+
default:
147+
framework.Failf("Unsupported volType:%v is specified", volType)
148+
}
149+
return nil
150+
}
151+
152+
func (v *nfsVolume) DeleteVolume() {
153+
framework.CleanUpVolumeServer(v.f, v.serverPod)
154+
}

vendor/github.com/PuerkitoBio/purell/LICENSE

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)