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
5b3318a0
Commit
5b3318a0
authored
Jan 29, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19612 from swagiaal/add-fsgroup-to-e2e
Auto commit by PR queue bot
parents
542a467b
c7be0a2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
17 deletions
+44
-17
volumes.go
test/e2e/volumes.go
+44
-17
No files found.
test/e2e/volumes.go
View file @
5b3318a0
...
@@ -42,6 +42,7 @@ package e2e
...
@@ -42,6 +42,7 @@ package e2e
import
(
import
(
"fmt"
"fmt"
"os/exec"
"os/exec"
"strconv"
"strings"
"strings"
"time"
"time"
...
@@ -167,16 +168,19 @@ func volumeTestCleanup(client *client.Client, config VolumeTestConfig) {
...
@@ -167,16 +168,19 @@ func volumeTestCleanup(client *client.Client, config VolumeTestConfig) {
glog
.
Warningf
(
"Failed to delete client pod: %v"
,
err
)
glog
.
Warningf
(
"Failed to delete client pod: %v"
,
err
)
expectNoError
(
err
,
"Failed to delete client pod: %v"
,
err
)
expectNoError
(
err
,
"Failed to delete client pod: %v"
,
err
)
}
}
err
=
podClient
.
Delete
(
config
.
prefix
+
"-server"
,
nil
)
if
err
!=
nil
{
if
config
.
serverImage
!=
""
{
glog
.
Warningf
(
"Failed to delete server pod: %v"
,
err
)
err
=
podClient
.
Delete
(
config
.
prefix
+
"-server"
,
nil
)
expectNoError
(
err
,
"Failed to delete server pod: %v"
,
err
)
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to delete server pod: %v"
,
err
)
expectNoError
(
err
,
"Failed to delete server pod: %v"
,
err
)
}
}
}
}
}
// Start a client pod using given VolumeSource (exported by startVolumeServer())
// Start a client pod using given VolumeSource (exported by startVolumeServer())
// and check that the pod sees the data from the server pod.
// and check that the pod sees the data from the server pod.
func
testVolumeClient
(
client
*
client
.
Client
,
config
VolumeTestConfig
,
volume
api
.
VolumeSource
,
expectedContent
string
)
{
func
testVolumeClient
(
client
*
client
.
Client
,
config
VolumeTestConfig
,
volume
api
.
VolumeSource
,
fsGroup
*
int64
,
expectedContent
string
)
{
By
(
fmt
.
Sprint
(
"starting "
,
config
.
prefix
,
" client"
))
By
(
fmt
.
Sprint
(
"starting "
,
config
.
prefix
,
" client"
))
podClient
:=
client
.
Pods
(
config
.
namespace
)
podClient
:=
client
.
Pods
(
config
.
namespace
)
...
@@ -211,6 +215,11 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api
...
@@ -211,6 +215,11 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api
},
},
},
},
},
},
SecurityContext
:
&
api
.
PodSecurityContext
{
SELinuxOptions
:
&
api
.
SELinuxOptions
{
Level
:
"s0:c0,c1"
,
},
},
Volumes
:
[]
api
.
Volume
{
Volumes
:
[]
api
.
Volume
{
{
{
Name
:
config
.
prefix
+
"-volume"
,
Name
:
config
.
prefix
+
"-volume"
,
...
@@ -219,6 +228,10 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api
...
@@ -219,6 +228,10 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api
},
},
},
},
}
}
if
fsGroup
!=
nil
{
clientPod
.
Spec
.
SecurityContext
.
FSGroup
=
fsGroup
}
if
_
,
err
:=
podClient
.
Create
(
clientPod
);
err
!=
nil
{
if
_
,
err
:=
podClient
.
Create
(
clientPod
);
err
!=
nil
{
Failf
(
"Failed to create %s pod: %v"
,
clientPod
.
Name
,
err
)
Failf
(
"Failed to create %s pod: %v"
,
clientPod
.
Name
,
err
)
}
}
...
@@ -250,6 +263,12 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api
...
@@ -250,6 +263,12 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api
By
(
"checking the page content"
)
By
(
"checking the page content"
)
Expect
(
body
)
.
To
(
ContainSubstring
(
expectedContent
))
Expect
(
body
)
.
To
(
ContainSubstring
(
expectedContent
))
if
fsGroup
!=
nil
{
By
(
"Checking fsGroup"
)
_
,
err
=
lookForStringInPodExec
(
config
.
namespace
,
clientPod
.
Name
,
[]
string
{
"ls"
,
"-ld"
,
"/usr/share/nginx/html"
},
strconv
.
Itoa
(
int
(
*
fsGroup
)),
time
.
Minute
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"waiting for output from pod exec"
)
}
}
}
// Insert index.html with given content into given volume. It does so by
// Insert index.html with given content into given volume. It does so by
...
@@ -285,6 +304,11 @@ func injectHtml(client *client.Client, config VolumeTestConfig, volume api.Volum
...
@@ -285,6 +304,11 @@ func injectHtml(client *client.Client, config VolumeTestConfig, volume api.Volum
},
},
},
},
},
},
SecurityContext
:
&
api
.
PodSecurityContext
{
SELinuxOptions
:
&
api
.
SELinuxOptions
{
Level
:
"s0:c0,c1"
,
},
},
RestartPolicy
:
api
.
RestartPolicyNever
,
RestartPolicy
:
api
.
RestartPolicyNever
,
Volumes
:
[]
api
.
Volume
{
Volumes
:
[]
api
.
Volume
{
{
{
...
@@ -373,7 +397,7 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
...
@@ -373,7 +397,7 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
},
},
}
}
// Must match content of test/images/volumes-tester/nfs/index.html
// Must match content of test/images/volumes-tester/nfs/index.html
testVolumeClient
(
c
,
config
,
volume
,
"Hello from NFS!"
)
testVolumeClient
(
c
,
config
,
volume
,
nil
,
"Hello from NFS!"
)
})
})
})
})
...
@@ -447,7 +471,7 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
...
@@ -447,7 +471,7 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
},
},
}
}
// Must match content of test/images/volumes-tester/gluster/index.html
// Must match content of test/images/volumes-tester/gluster/index.html
testVolumeClient
(
c
,
config
,
volume
,
"Hello from GlusterFS!"
)
testVolumeClient
(
c
,
config
,
volume
,
nil
,
"Hello from GlusterFS!"
)
})
})
})
})
...
@@ -486,14 +510,15 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
...
@@ -486,14 +510,15 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
ISCSI
:
&
api
.
ISCSIVolumeSource
{
ISCSI
:
&
api
.
ISCSIVolumeSource
{
TargetPortal
:
serverIP
+
":3260"
,
TargetPortal
:
serverIP
+
":3260"
,
// from test/images/volumes-tester/iscsi/initiatorname.iscsi
// from test/images/volumes-tester/iscsi/initiatorname.iscsi
IQN
:
"iqn.2003-01.org.linux-iscsi.f21.x8664:sn.4b0aae584f7c"
,
IQN
:
"iqn.2003-01.org.linux-iscsi.f21.x8664:sn.4b0aae584f7c"
,
Lun
:
0
,
Lun
:
0
,
FSType
:
"ext2"
,
FSType
:
"ext2"
,
ReadOnly
:
true
,
},
},
}
}
fsGroup
:=
int64
(
1234
)
// Must match content of test/images/volumes-tester/iscsi/block.tar.gz
// Must match content of test/images/volumes-tester/iscsi/block.tar.gz
testVolumeClient
(
c
,
config
,
volume
,
"Hello from iSCSI"
)
testVolumeClient
(
c
,
config
,
volume
,
&
fsGroup
,
"Hello from iSCSI"
)
})
})
})
})
...
@@ -560,12 +585,13 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
...
@@ -560,12 +585,13 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
SecretRef
:
&
api
.
LocalObjectReference
{
SecretRef
:
&
api
.
LocalObjectReference
{
Name
:
config
.
prefix
+
"-secret"
,
Name
:
config
.
prefix
+
"-secret"
,
},
},
FSType
:
"ext2"
,
FSType
:
"ext2"
,
ReadOnly
:
true
,
},
},
}
}
fsGroup
:=
int64
(
1234
)
// Must match content of test/images/volumes-tester/gluster/index.html
// Must match content of test/images/volumes-tester/gluster/index.html
testVolumeClient
(
c
,
config
,
volume
,
"Hello from RBD"
)
testVolumeClient
(
c
,
config
,
volume
,
&
fsGroup
,
"Hello from RBD"
)
})
})
})
})
...
@@ -631,7 +657,7 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
...
@@ -631,7 +657,7 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
},
},
}
}
// Must match content of contrib/for-tests/volumes-ceph/ceph/index.html
// Must match content of contrib/for-tests/volumes-ceph/ceph/index.html
testVolumeClient
(
c
,
config
,
volume
,
"Hello Ceph!"
)
testVolumeClient
(
c
,
config
,
volume
,
nil
,
"Hello Ceph!"
)
})
})
})
})
...
@@ -704,7 +730,8 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
...
@@ -704,7 +730,8 @@ var _ = Describe("Volumes [Feature:Volumes]", func() {
content
:=
"Hello from Cinder from namespace "
+
volumeName
content
:=
"Hello from Cinder from namespace "
+
volumeName
injectHtml
(
c
,
config
,
volume
,
content
)
injectHtml
(
c
,
config
,
volume
,
content
)
testVolumeClient
(
c
,
config
,
volume
,
content
)
fsGroup
:=
int64
(
1234
)
testVolumeClient
(
c
,
config
,
volume
,
&
fsGroup
,
content
)
})
})
})
})
})
})
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