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
608638cb
Commit
608638cb
authored
Feb 13, 2017
by
divyenpatel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed common funcs to add support for new tests
added new tests to vsphere_volume_placement.go addressed jeffvance's review comments
parent
d1e6638a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
5 deletions
+80
-5
util.go
test/e2e/framework/util.go
+6
-0
vsphere_utils.go
test/e2e/vsphere_utils.go
+66
-0
vsphere_volume_diskformat.go
test/e2e/vsphere_volume_diskformat.go
+8
-5
vsphere_volume_placement.go
test/e2e/vsphere_volume_placement.go
+0
-0
No files found.
test/e2e/framework/util.go
View file @
608638cb
...
@@ -5482,3 +5482,9 @@ func (f *Framework) NewTestPod(name string, requests v1.ResourceList, limits v1.
...
@@ -5482,3 +5482,9 @@ func (f *Framework) NewTestPod(name string, requests v1.ResourceList, limits v1.
},
},
}
}
}
}
// create empty file at given path on the pod.
func
CreateEmptyFileOnPod
(
namespace
string
,
podName
string
,
filePath
string
)
error
{
_
,
err
:=
RunKubectl
(
"exec"
,
fmt
.
Sprintf
(
"--namespace=%s"
,
namespace
),
podName
,
"--"
,
"/bin/sh"
,
"-c"
,
fmt
.
Sprintf
(
"touch %s"
,
filePath
))
return
err
}
test/e2e/vsphere_utils.go
View file @
608638cb
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
storage
"k8s.io/kubernetes/pkg/apis/storage/v1beta1"
storage
"k8s.io/kubernetes/pkg/apis/storage/v1beta1"
...
@@ -223,6 +224,7 @@ func getVSphereClaimSpecWithStorageClassAnnotation(ns string, storageclass *stor
...
@@ -223,6 +224,7 @@ func getVSphereClaimSpecWithStorageClassAnnotation(ns string, storageclass *stor
return
claim
return
claim
}
}
// func to get pod spec with given volume claim, node selector labels and command
func
getVSpherePodSpecWithClaim
(
claimName
string
,
nodeSelectorKV
map
[
string
]
string
,
command
string
)
*
v1
.
Pod
{
func
getVSpherePodSpecWithClaim
(
claimName
string
,
nodeSelectorKV
map
[
string
]
string
,
command
string
)
*
v1
.
Pod
{
pod
:=
&
v1
.
Pod
{
pod
:=
&
v1
.
Pod
{
TypeMeta
:
metav1
.
TypeMeta
{
TypeMeta
:
metav1
.
TypeMeta
{
...
@@ -266,3 +268,67 @@ func getVSpherePodSpecWithClaim(claimName string, nodeSelectorKV map[string]stri
...
@@ -266,3 +268,67 @@ func getVSpherePodSpecWithClaim(claimName string, nodeSelectorKV map[string]stri
}
}
return
pod
return
pod
}
}
// func to get pod spec with given volume paths, node selector lables and container commands
func
getVSpherePodSpecWithVolumePaths
(
volumePaths
[]
string
,
keyValuelabel
map
[
string
]
string
,
commands
[]
string
)
*
v1
.
Pod
{
var
volumeMounts
[]
v1
.
VolumeMount
var
volumes
[]
v1
.
Volume
for
index
,
volumePath
:=
range
volumePaths
{
name
:=
fmt
.
Sprintf
(
"volume%v"
,
index
+
1
)
volumeMounts
=
append
(
volumeMounts
,
v1
.
VolumeMount
{
Name
:
name
,
MountPath
:
"/mnt/"
+
name
})
vsphereVolume
:=
new
(
v1
.
VsphereVirtualDiskVolumeSource
)
vsphereVolume
.
VolumePath
=
volumePath
vsphereVolume
.
FSType
=
"ext4"
volumes
=
append
(
volumes
,
v1
.
Volume
{
Name
:
name
})
volumes
[
index
]
.
VolumeSource
.
VsphereVolume
=
vsphereVolume
}
if
commands
==
nil
||
len
(
commands
)
==
0
{
commands
=
[]
string
{
"/bin/sh"
,
"-c"
,
"while true; do sleep 2; done"
,
}
}
pod
:=
&
v1
.
Pod
{
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"Pod"
,
APIVersion
:
"v1"
,
},
ObjectMeta
:
metav1
.
ObjectMeta
{
GenerateName
:
"vsphere-e2e-"
,
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
"vsphere-e2e-container-"
+
string
(
uuid
.
NewUUID
()),
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Command
:
commands
,
VolumeMounts
:
volumeMounts
,
},
},
RestartPolicy
:
v1
.
RestartPolicyNever
,
Volumes
:
volumes
,
},
}
if
keyValuelabel
!=
nil
{
pod
.
Spec
.
NodeSelector
=
keyValuelabel
}
return
pod
}
func
verifyFilesExistOnVSphereVolume
(
namespace
string
,
podName
string
,
filePaths
[]
string
)
{
for
_
,
filePath
:=
range
filePaths
{
_
,
err
:=
framework
.
RunKubectl
(
"exec"
,
fmt
.
Sprintf
(
"--namespace=%s"
,
namespace
),
podName
,
"--"
,
"/bin/ls"
,
filePath
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
fmt
.
Sprintf
(
"failed to verify file: %q on the pod: %q"
,
filePath
,
podName
))
}
}
func
createEmptyFilesOnVSphereVolume
(
namespace
string
,
podName
string
,
filePaths
[]
string
)
{
for
_
,
filePath
:=
range
filePaths
{
err
:=
framework
.
CreateEmptyFileOnPod
(
namespace
,
podName
,
filePath
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
}
test/e2e/vsphere_volume_diskformat.go
View file @
608638cb
...
@@ -88,19 +88,19 @@ var _ = framework.KubeDescribe("Volume Disk Format [Volumes]", func() {
...
@@ -88,19 +88,19 @@ var _ = framework.KubeDescribe("Volume Disk Format [Volumes]", func() {
It
(
"verify disk format type - eagerzeroedthick is honored for dynamically provisioned pv using storageclass"
,
func
()
{
It
(
"verify disk format type - eagerzeroedthick is honored for dynamically provisioned pv using storageclass"
,
func
()
{
By
(
"Invoking Test for diskformat: eagerzeroedthick"
)
By
(
"Invoking Test for diskformat: eagerzeroedthick"
)
invokeTest
(
client
,
namespace
,
nodeName
,
nodeKeyValueLabel
,
"eagerzeroedthick"
)
invokeTest
(
f
,
client
,
namespace
,
nodeName
,
nodeKeyValueLabel
,
"eagerzeroedthick"
)
})
})
It
(
"verify disk format type - zeroedthick is honored for dynamically provisioned pv using storageclass"
,
func
()
{
It
(
"verify disk format type - zeroedthick is honored for dynamically provisioned pv using storageclass"
,
func
()
{
By
(
"Invoking Test for diskformat: zeroedthick"
)
By
(
"Invoking Test for diskformat: zeroedthick"
)
invokeTest
(
client
,
namespace
,
nodeName
,
nodeKeyValueLabel
,
"zeroedthick"
)
invokeTest
(
f
,
client
,
namespace
,
nodeName
,
nodeKeyValueLabel
,
"zeroedthick"
)
})
})
It
(
"verify disk format type - thin is honored for dynamically provisioned pv using storageclass"
,
func
()
{
It
(
"verify disk format type - thin is honored for dynamically provisioned pv using storageclass"
,
func
()
{
By
(
"Invoking Test for diskformat: thin"
)
By
(
"Invoking Test for diskformat: thin"
)
invokeTest
(
client
,
namespace
,
nodeName
,
nodeKeyValueLabel
,
"thin"
)
invokeTest
(
f
,
client
,
namespace
,
nodeName
,
nodeKeyValueLabel
,
"thin"
)
})
})
})
})
func
invokeTest
(
client
clientset
.
Interface
,
namespace
string
,
nodeName
string
,
nodeKeyValueLabel
map
[
string
]
string
,
diskFormat
string
)
{
func
invokeTest
(
f
*
framework
.
Framework
,
client
clientset
.
Interface
,
namespace
string
,
nodeName
string
,
nodeKeyValueLabel
map
[
string
]
string
,
diskFormat
string
)
{
framework
.
Logf
(
"Invoking Test for DiskFomat: %s"
,
diskFormat
)
framework
.
Logf
(
"Invoking Test for DiskFomat: %s"
,
diskFormat
)
scParameters
:=
make
(
map
[
string
]
string
)
scParameters
:=
make
(
map
[
string
]
string
)
...
@@ -152,8 +152,11 @@ func invokeTest(client clientset.Interface, namespace string, nodeName string, n
...
@@ -152,8 +152,11 @@ func invokeTest(client clientset.Interface, namespace string, nodeName string, n
Expect
(
framework
.
WaitForPodNameRunningInNamespace
(
client
,
pod
.
Name
,
namespace
))
.
To
(
Succeed
())
Expect
(
framework
.
WaitForPodNameRunningInNamespace
(
client
,
pod
.
Name
,
namespace
))
.
To
(
Succeed
())
Expect
(
verifyDiskFormat
(
nodeName
,
pv
.
Spec
.
VsphereVolume
.
VolumePath
,
diskFormat
))
.
To
(
BeTrue
(),
"DiskFormat Verification Failed"
)
Expect
(
verifyDiskFormat
(
nodeName
,
pv
.
Spec
.
VsphereVolume
.
VolumePath
,
diskFormat
))
.
To
(
BeTrue
(),
"DiskFormat Verification Failed"
)
var
volumePaths
[]
string
volumePaths
=
append
(
volumePaths
,
pv
.
Spec
.
VsphereVolume
.
VolumePath
)
By
(
"Delete pod and wait for volume to be detached from node"
)
By
(
"Delete pod and wait for volume to be detached from node"
)
deletePodAndWaitForVolumeToDetach
(
client
,
namespace
,
vsp
,
nodeName
,
pod
,
pv
.
Spec
.
VsphereVolume
.
VolumePath
)
deletePodAndWaitForVolumeToDetach
(
f
,
client
,
pod
,
vsp
,
nodeName
,
volumePaths
)
}
}
...
...
test/e2e/vsphere_volume_placement.go
View file @
608638cb
This diff is collapsed.
Click to expand it.
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