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
d7ba5b9f
Commit
d7ba5b9f
authored
Nov 07, 2018
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add e2e test for file exec
parent
3a5c57cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
9 deletions
+69
-9
volumes.go
test/e2e/storage/testsuites/volumes.go
+69
-9
No files found.
test/e2e/storage/testsuites/volumes.go
View file @
d7ba5b9f
...
...
@@ -23,11 +23,17 @@ package testsuites
import
(
"fmt"
"path/filepath"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/storage/drivers"
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
imageutils
"k8s.io/kubernetes/test/utils/image"
)
type
volumesTestSuite
struct
{
...
...
@@ -91,10 +97,11 @@ func createVolumesTestInput(pattern testpatterns.TestPattern, resource genericVo
}
return
volumesTestInput
{
f
:
f
,
name
:
dInfo
.
Name
,
config
:
dInfo
.
Config
,
fsGroup
:
fsGroup
,
f
:
f
,
name
:
dInfo
.
Name
,
config
:
dInfo
.
Config
,
fsGroup
:
fsGroup
,
resource
:
resource
,
tests
:
[]
framework
.
VolumeTest
{
{
Volume
:
*
volSource
,
...
...
@@ -140,11 +147,12 @@ func (t *volumesTestSuite) execTest(driver drivers.TestDriver, pattern testpatte
}
type
volumesTestInput
struct
{
f
*
framework
.
Framework
name
string
config
framework
.
VolumeTestConfig
fsGroup
*
int64
tests
[]
framework
.
VolumeTest
f
*
framework
.
Framework
name
string
config
framework
.
VolumeTestConfig
fsGroup
*
int64
tests
[]
framework
.
VolumeTest
resource
genericVolumeTestResource
}
func
testVolumes
(
input
*
volumesTestInput
)
{
...
...
@@ -157,4 +165,56 @@ func testVolumes(input *volumesTestInput) {
framework
.
InjectHtml
(
cs
,
input
.
config
,
volumeTest
[
0
]
.
Volume
,
volumeTest
[
0
]
.
ExpectedContent
)
framework
.
TestVolumeClient
(
cs
,
input
.
config
,
input
.
fsGroup
,
input
.
tests
)
})
It
(
"should allow exec of files on the volume"
,
func
()
{
f
:=
input
.
f
defer
framework
.
VolumeTestCleanup
(
f
,
input
.
config
)
testScriptInPod
(
f
,
input
.
resource
.
volType
,
input
.
resource
.
volSource
)
})
}
func
testScriptInPod
(
f
*
framework
.
Framework
,
volumeType
string
,
source
*
v1
.
VolumeSource
)
{
const
(
volPath
=
"/vol1"
volName
=
"vol1"
)
suffix
:=
generateSuffixForPodName
(
volumeType
)
scriptName
:=
fmt
.
Sprintf
(
"test-%s.sh"
,
suffix
)
fullPath
:=
filepath
.
Join
(
volPath
,
scriptName
)
cmd
:=
fmt
.
Sprintf
(
"echo
\"
ls %s
\"
> %s; chmod u+x %s; %s"
,
volPath
,
fullPath
,
fullPath
,
fullPath
)
pod
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
fmt
.
Sprintf
(
"exec-volume-test-%s"
,
suffix
),
Namespace
:
f
.
Namespace
.
Name
,
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
fmt
.
Sprintf
(
"exec-container-%s"
,
suffix
),
Image
:
imageutils
.
GetE2EImage
(
imageutils
.
Nginx
),
Command
:
[]
string
{
"/bin/sh"
,
"-ec"
,
cmd
},
VolumeMounts
:
[]
v1
.
VolumeMount
{
{
Name
:
volName
,
MountPath
:
volPath
,
},
},
},
},
Volumes
:
[]
v1
.
Volume
{
{
Name
:
volName
,
VolumeSource
:
*
source
,
},
},
RestartPolicy
:
v1
.
RestartPolicyNever
,
},
}
By
(
fmt
.
Sprintf
(
"Creating pod %s"
,
pod
.
Name
))
f
.
TestContainerOutput
(
"exec-volume-test"
,
pod
,
0
,
[]
string
{
scriptName
})
By
(
fmt
.
Sprintf
(
"Deleting pod %s"
,
pod
.
Name
))
err
:=
framework
.
DeletePodWithWait
(
f
,
f
.
ClientSet
,
pod
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"while deleting pod"
)
}
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