Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b02cada1
Unverified
Commit
b02cada1
authored
Nov 28, 2018
by
Michelle Au
Committed by
GitHub
Nov 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "CSI: enhance driver tests to update the drivers."
parent
6e5176b4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
156 deletions
+7
-156
BUILD
test/e2e/storage/BUILD
+0
-1
csi_volumes.go
test/e2e/storage/csi_volumes.go
+7
-143
csi-hostpathplugin.yaml
.../storage-csi/hostpath/hostpath-v0/csi-hostpathplugin.yaml
+0
-6
csi-hostpathplugin.yaml
...sts/storage-csi/hostpath/hostpath/csi-hostpathplugin.yaml
+0
-6
No files found.
test/e2e/storage/BUILD
View file @
b02cada1
...
@@ -55,7 +55,6 @@ go_library(
...
@@ -55,7 +55,6 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/json:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
...
...
test/e2e/storage/csi_volumes.go
View file @
b02cada1
...
@@ -20,15 +20,11 @@ import (
...
@@ -20,15 +20,11 @@ import (
"context"
"context"
"fmt"
"fmt"
"regexp"
"regexp"
"time"
appsv1
"k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
storagev1
"k8s.io/api/storage/v1"
storagev1
"k8s.io/api/storage/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/json"
clientset
"k8s.io/client-go/kubernetes"
clientset
"k8s.io/client-go/kubernetes"
csiv1alpha1
"k8s.io/csi-api/pkg/apis/csi/v1alpha1"
csiv1alpha1
"k8s.io/csi-api/pkg/apis/csi/v1alpha1"
csiclient
"k8s.io/csi-api/pkg/client/clientset/versioned"
csiclient
"k8s.io/csi-api/pkg/client/clientset/versioned"
...
@@ -46,11 +42,6 @@ import (
...
@@ -46,11 +42,6 @@ import (
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
)
)
const
(
// Name of node annotation that contains JSON map of driver names to node
annotationKeyNodeID
=
"csi.volume.kubernetes.io/nodeid"
)
// List of testDrivers to be executed in below loop
// List of testDrivers to be executed in below loop
var
csiTestDrivers
=
[]
func
()
drivers
.
TestDriver
{
var
csiTestDrivers
=
[]
func
()
drivers
.
TestDriver
{
drivers
.
InitHostPathCSIDriver
,
drivers
.
InitHostPathCSIDriver
,
...
@@ -150,7 +141,6 @@ var _ = utils.SIGDescribe("CSI Volumes", func() {
...
@@ -150,7 +141,6 @@ var _ = utils.SIGDescribe("CSI Volumes", func() {
})
})
testsuites
.
RunTestSuite
(
f
,
config
,
driver
,
csiTestSuites
,
csiTunePattern
)
testsuites
.
RunTestSuite
(
f
,
config
,
driver
,
csiTestSuites
,
csiTunePattern
)
testCSIDriverUpdate
(
f
,
driver
)
})
})
}
}
...
@@ -223,8 +213,7 @@ var _ = utils.SIGDescribe("CSI Volumes", func() {
...
@@ -223,8 +213,7 @@ var _ = utils.SIGDescribe("CSI Volumes", func() {
ExpectedSize
:
"1Gi"
,
ExpectedSize
:
"1Gi"
,
NodeName
:
nodeName
,
NodeName
:
nodeName
,
}
}
// Use exec to kill the pod quickly
class
,
claim
,
pod
:=
startPausePod
(
cs
,
scTest
,
ns
.
Name
)
class
,
claim
,
pod
:=
startPod
(
cs
,
scTest
,
ns
.
Name
,
"exec sleep 6000"
)
if
class
!=
nil
{
if
class
!=
nil
{
defer
cs
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
class
.
Name
,
nil
)
defer
cs
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
class
.
Name
,
nil
)
}
}
...
@@ -300,7 +289,7 @@ func getVolumeHandle(cs clientset.Interface, claim *v1.PersistentVolumeClaim) st
...
@@ -300,7 +289,7 @@ func getVolumeHandle(cs clientset.Interface, claim *v1.PersistentVolumeClaim) st
return
pv
.
Spec
.
CSI
.
VolumeHandle
return
pv
.
Spec
.
CSI
.
VolumeHandle
}
}
func
startP
od
(
cs
clientset
.
Interface
,
t
testsuites
.
StorageClassTest
,
ns
string
,
cmdline
string
)
(
*
storagev1
.
StorageClass
,
*
v1
.
PersistentVolumeClaim
,
*
v1
.
Pod
)
{
func
startP
ausePod
(
cs
clientset
.
Interface
,
t
testsuites
.
StorageClassTest
,
ns
string
)
(
*
storagev1
.
StorageClass
,
*
v1
.
PersistentVolumeClaim
,
*
v1
.
Pod
)
{
class
:=
newStorageClass
(
t
,
ns
,
""
)
class
:=
newStorageClass
(
t
,
ns
,
""
)
class
,
err
:=
cs
.
StorageV1
()
.
StorageClasses
()
.
Create
(
class
)
class
,
err
:=
cs
.
StorageV1
()
.
StorageClasses
()
.
Create
(
class
)
framework
.
ExpectNoError
(
err
,
"Failed to create class : %v"
,
err
)
framework
.
ExpectNoError
(
err
,
"Failed to create class : %v"
,
err
)
...
@@ -309,17 +298,6 @@ func startPod(cs clientset.Interface, t testsuites.StorageClassTest, ns string,
...
@@ -309,17 +298,6 @@ func startPod(cs clientset.Interface, t testsuites.StorageClassTest, ns string,
claim
,
err
=
cs
.
CoreV1
()
.
PersistentVolumeClaims
(
ns
)
.
Create
(
claim
)
claim
,
err
=
cs
.
CoreV1
()
.
PersistentVolumeClaims
(
ns
)
.
Create
(
claim
)
framework
.
ExpectNoError
(
err
,
"Failed to create claim: %v"
,
err
)
framework
.
ExpectNoError
(
err
,
"Failed to create claim: %v"
,
err
)
pod
:=
getTestPod
(
t
,
claim
,
cmdline
)
if
len
(
t
.
NodeName
)
!=
0
{
pod
.
Spec
.
NodeName
=
t
.
NodeName
}
pod
,
err
=
cs
.
CoreV1
()
.
Pods
(
ns
)
.
Create
(
pod
)
framework
.
ExpectNoError
(
err
,
"Failed to create pod: %v"
,
err
)
return
class
,
claim
,
pod
}
func
getTestPod
(
t
testsuites
.
StorageClassTest
,
claim
*
v1
.
PersistentVolumeClaim
,
cmdline
string
)
*
v1
.
Pod
{
pod
:=
&
v1
.
Pod
{
pod
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
GenerateName
:
"pvc-volume-tester-"
,
GenerateName
:
"pvc-volume-tester-"
,
...
@@ -327,9 +305,8 @@ func getTestPod(t testsuites.StorageClassTest, claim *v1.PersistentVolumeClaim,
...
@@ -327,9 +305,8 @@ func getTestPod(t testsuites.StorageClassTest, claim *v1.PersistentVolumeClaim,
Spec
:
v1
.
PodSpec
{
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
Containers
:
[]
v1
.
Container
{
{
{
Name
:
"volume-tester"
,
Name
:
"volume-tester"
,
Image
:
imageutils
.
GetE2EImage
(
imageutils
.
BusyBox
),
Image
:
imageutils
.
GetE2EImage
(
imageutils
.
Pause
),
Command
:
[]
string
{
"/bin/sh"
,
"-c"
,
cmdline
},
VolumeMounts
:
[]
v1
.
VolumeMount
{
VolumeMounts
:
[]
v1
.
VolumeMount
{
{
{
Name
:
"my-volume"
,
Name
:
"my-volume"
,
...
@@ -356,120 +333,7 @@ func getTestPod(t testsuites.StorageClassTest, claim *v1.PersistentVolumeClaim,
...
@@ -356,120 +333,7 @@ func getTestPod(t testsuites.StorageClassTest, claim *v1.PersistentVolumeClaim,
if
len
(
t
.
NodeName
)
!=
0
{
if
len
(
t
.
NodeName
)
!=
0
{
pod
.
Spec
.
NodeName
=
t
.
NodeName
pod
.
Spec
.
NodeName
=
t
.
NodeName
}
}
return
pod
pod
,
err
=
cs
.
CoreV1
()
.
Pods
(
ns
)
.
Create
(
pod
)
}
framework
.
ExpectNoError
(
err
,
"Failed to create pod: %v"
,
err
)
return
class
,
claim
,
pod
func
testCSIDriverUpdate
(
f
*
framework
.
Framework
,
driver
drivers
.
TestDriver
)
{
// NOTE: this test assumes that all CSI drivers in csiTestDrivers deploy exactly one DaemonSet.
It
(
"should work after update"
,
func
()
{
cs
:=
f
.
ClientSet
By
(
"Checking the driver works before update"
)
var
sc
*
storagev1
.
StorageClass
if
dDriver
,
ok
:=
driver
.
(
drivers
.
DynamicPVTestDriver
);
ok
{
sc
=
dDriver
.
GetDynamicProvisionStorageClass
(
""
)
}
nodeName
:=
driver
.
GetDriverInfo
()
.
Config
.
ClientNodeName
scTest
:=
testsuites
.
StorageClassTest
{
Name
:
driver
.
GetDriverInfo
()
.
Name
,
Provisioner
:
sc
.
Provisioner
,
Parameters
:
sc
.
Parameters
,
ClaimSize
:
"1Gi"
,
ExpectedSize
:
"1Gi"
,
NodeName
:
nodeName
,
}
class
,
claim
,
pod
:=
startPod
(
cs
,
scTest
,
f
.
Namespace
.
Name
,
"echo 'test' > /mnt/test/data"
)
if
class
!=
nil
{
defer
cs
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
class
.
Name
,
nil
)
}
if
claim
!=
nil
{
defer
cs
.
CoreV1
()
.
PersistentVolumeClaims
(
f
.
Namespace
.
Name
)
.
Delete
(
claim
.
Name
,
nil
)
}
if
pod
!=
nil
{
// Fully delete (=unmount) the pod before deleting CSI driver
defer
framework
.
DeletePodWithWait
(
f
,
cs
,
pod
)
}
if
pod
==
nil
{
return
}
err
:=
framework
.
WaitForPodSuccessInNamespace
(
cs
,
pod
.
Name
,
pod
.
Namespace
)
framework
.
ExpectNoError
(
err
,
"Failed to start pod"
)
err
=
framework
.
DeletePodWithWait
(
f
,
cs
,
pod
)
By
(
"Finding CSI driver deployment"
)
ds
,
err
:=
getDriverDaemonSet
(
f
)
framework
.
ExpectNoError
(
err
,
"Failed to get driver DaemonSets"
)
By
(
"Updating the driver"
)
ds
,
err
=
cs
.
AppsV1
()
.
DaemonSets
(
f
.
Namespace
.
Name
)
.
Get
(
ds
.
Name
,
metav1
.
GetOptions
{})
framework
.
ExpectNoError
(
err
,
"Failed to get DaemonSet"
)
expectedUpdatedPods
:=
ds
.
Status
.
DesiredNumberScheduled
framework
.
Logf
(
"DaemonSet with driver has %d scheduled pods"
,
expectedUpdatedPods
)
// For debugging:
framework
.
Logf
(
"DaemonSet status: %+v"
,
ds
.
Status
)
ds
,
err
=
framework
.
UpdateDaemonSetWithRetries
(
cs
,
f
.
Namespace
.
Name
,
ds
.
Name
,
func
(
ds
*
appsv1
.
DaemonSet
)
{
// Simulate driver update by adding a new label in DaemonSet template. This issues rolling update.
if
ds
.
Spec
.
Template
.
Labels
==
nil
{
ds
.
Spec
.
Template
.
Labels
=
map
[
string
]
string
{}
}
ds
.
Spec
.
Template
.
Labels
[
f
.
UniqueName
]
=
""
})
framework
.
ExpectNoError
(
err
,
"Failed to update DaemonSet"
)
By
(
"Waiting for the update to complete"
)
selector
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
f
.
UniqueName
:
""
}))
_
,
err
=
framework
.
WaitForPodsWithLabelRunningReady
(
cs
,
f
.
Namespace
.
Name
,
selector
,
int
(
expectedUpdatedPods
),
framework
.
PodStartTimeout
)
framework
.
ExpectNoError
(
err
,
"Failed to wait for updated DaemonSet"
)
By
(
"Checking the driver works after update with the same claim"
)
pod2
:=
getTestPod
(
scTest
,
claim
,
"grep test < /mnt/test/data"
)
pod2
,
err
=
cs
.
CoreV1
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod2
)
framework
.
ExpectNoError
(
err
,
"Failed to create pod"
)
defer
framework
.
DeletePodWithWait
(
f
,
cs
,
pod2
)
err
=
framework
.
WaitForPodSuccessInNamespace
(
cs
,
pod2
.
Name
,
pod2
.
Namespace
)
framework
.
ExpectNoError
(
err
,
"Failed to start pod2"
)
pod2
,
err
=
cs
.
CoreV1
()
.
Pods
(
pod2
.
Namespace
)
.
Get
(
pod2
.
Name
,
metav1
.
GetOptions
{})
framework
.
ExpectNoError
(
err
,
"Failed to get pod"
)
nodeName
=
pod2
.
Spec
.
NodeName
err
=
framework
.
DeletePodWithWait
(
f
,
cs
,
pod2
)
framework
.
ExpectNoError
(
err
,
"Failed to delete pod2"
)
// #71424: check that NodeID annotation is set after update
node
,
err
:=
cs
.
CoreV1
()
.
Nodes
()
.
Get
(
nodeName
,
metav1
.
GetOptions
{})
framework
.
ExpectNoError
(
err
,
"Failed to read node"
)
ann
,
found
:=
node
.
Annotations
[
annotationKeyNodeID
]
Expect
(
found
)
.
To
(
BeTrue
(),
"annotation with NodeID not found"
)
var
nodeIDs
map
[
string
]
string
err
=
json
.
Unmarshal
([]
byte
(
ann
),
&
nodeIDs
)
framework
.
ExpectNoError
(
err
,
"Failed to parse NodeID json"
)
_
,
ok
:=
nodeIDs
[
class
.
Provisioner
]
Expect
(
ok
)
.
To
(
BeTrue
(),
"NodeID of driver not found"
)
// By waiting for PVC deletion we make sure that the volume is detached, since most cloud providers
// wait for detach + we have finalizer on PVC.
claim
,
err
=
cs
.
CoreV1
()
.
PersistentVolumeClaims
(
f
.
Namespace
.
Name
)
.
Get
(
claim
.
Name
,
metav1
.
GetOptions
{})
framework
.
ExpectNoError
(
err
,
"Failed to get PVC"
)
cs
.
CoreV1
()
.
PersistentVolumeClaims
(
f
.
Namespace
.
Name
)
.
Delete
(
claim
.
Name
,
nil
)
err
=
framework
.
WaitForPersistentVolumeDeleted
(
cs
,
claim
.
Spec
.
VolumeName
,
5
*
time
.
Second
,
20
*
time
.
Minute
)
framework
.
ExpectNoError
(
err
,
"Timed out waiting for PV to delete"
)
})
}
// getDriverDaemonSet finds *any* DaemonSet in framework's namespace and returns it.
// It must be called just after driver installation, where the only DaemonSet in the
// namespace must be the driver.
func
getDriverDaemonSet
(
f
*
framework
.
Framework
)
(
*
appsv1
.
DaemonSet
,
error
)
{
By
(
"Finding CSI driver DaemonSet"
)
daemonSets
,
err
:=
f
.
ClientSet
.
AppsV1
()
.
DaemonSets
(
f
.
Namespace
.
Name
)
.
List
(
metav1
.
ListOptions
{})
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
daemonSets
.
Items
)
!=
1
{
return
nil
,
fmt
.
Errorf
(
"Got %d DaemonSets in the namespace when only 1 was expected"
,
len
(
daemonSets
.
Items
))
}
return
&
daemonSets
.
Items
[
0
],
nil
}
}
test/e2e/testing-manifests/storage-csi/hostpath/hostpath-v0/csi-hostpathplugin.yaml
View file @
b02cada1
...
@@ -55,8 +55,6 @@ spec:
...
@@ -55,8 +55,6 @@ spec:
-
mountPath
:
/var/lib/kubelet/pods
-
mountPath
:
/var/lib/kubelet/pods
mountPropagation
:
Bidirectional
mountPropagation
:
Bidirectional
name
:
mountpoint-dir
name
:
mountpoint-dir
-
mountPath
:
/tmp
name
:
tmp
volumes
:
volumes
:
-
hostPath
:
-
hostPath
:
path
:
/var/lib/kubelet/plugins/csi-hostpath-v0
path
:
/var/lib/kubelet/plugins/csi-hostpath-v0
...
@@ -70,7 +68,3 @@ spec:
...
@@ -70,7 +68,3 @@ spec:
path
:
/var/lib/kubelet/plugins
path
:
/var/lib/kubelet/plugins
type
:
Directory
type
:
Directory
name
:
registration-dir
name
:
registration-dir
-
name
:
tmp
hostPath
:
path
:
/tmp
type
:
Directory
test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpathplugin.yaml
View file @
b02cada1
...
@@ -55,8 +55,6 @@ spec:
...
@@ -55,8 +55,6 @@ spec:
-
mountPath
:
/var/lib/kubelet/pods
-
mountPath
:
/var/lib/kubelet/pods
mountPropagation
:
Bidirectional
mountPropagation
:
Bidirectional
name
:
mountpoint-dir
name
:
mountpoint-dir
-
mountPath
:
/tmp
name
:
tmp
volumes
:
volumes
:
-
hostPath
:
-
hostPath
:
path
:
/var/lib/kubelet/plugins/csi-hostpath
path
:
/var/lib/kubelet/plugins/csi-hostpath
...
@@ -70,7 +68,3 @@ spec:
...
@@ -70,7 +68,3 @@ spec:
path
:
/var/lib/kubelet/plugins_registry
path
:
/var/lib/kubelet/plugins_registry
type
:
Directory
type
:
Directory
name
:
registration-dir
name
:
registration-dir
-
name
:
tmp
hostPath
:
path
:
/tmp
type
:
Directory
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment