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
409a5eca
Unverified
Commit
409a5eca
authored
Nov 29, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #71036 from bclau/test-windows-permissions
tests: Checks for Windows permissions as well
parents
163b54dc
0df9c0ad
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
56 deletions
+51
-56
configmap_volume.go
test/e2e/common/configmap_volume.go
+6
-13
projected_configmap.go
test/e2e/common/projected_configmap.go
+6
-13
projected_secret.go
test/e2e/common/projected_secret.go
+9
-15
secrets_volume.go
test/e2e/common/secrets_volume.go
+9
-15
util.go
test/e2e/framework/util.go
+21
-0
No files found.
test/e2e/common/configmap_volume.go
View file @
409a5eca
...
...
@@ -18,7 +18,6 @@ package common
import
(
"fmt"
"os"
"path"
.
"github.com/onsi/ginkgo"
...
...
@@ -642,17 +641,14 @@ func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64, d
if
defaultMode
!=
nil
{
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
.
ConfigMap
.
DefaultMode
=
defaultMode
}
else
{
mode
:=
int32
(
0644
)
defaultMode
=
&
mode
}
modeString
:=
fmt
.
Sprintf
(
"%v"
,
os
.
FileMode
(
*
defaultMode
)
)
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/configmap-volume/data-1"
,
defaultMode
)
output
:=
[]
string
{
"content of file
\"
/etc/configmap-volume/data-1
\"
: value-1"
,
"mode of file
\"
/etc/configmap-volume/data-1
\"
: "
+
modeString
,
fileModeRegexp
,
}
f
.
TestContainerOutput
(
"consume configMaps"
,
pod
,
0
,
output
)
f
.
TestContainerOutput
Regexp
(
"consume configMaps"
,
pod
,
0
,
output
)
}
func
doConfigMapE2EWithMappings
(
f
*
framework
.
Framework
,
uid
,
fsGroup
int64
,
itemMode
*
int32
)
{
...
...
@@ -728,9 +724,6 @@ func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64, item
if
itemMode
!=
nil
{
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
.
ConfigMap
.
Items
[
0
]
.
Mode
=
itemMode
}
else
{
mode
:=
int32
(
0644
)
itemMode
=
&
mode
}
// Just check file mode if fsGroup is not set. If fsGroup is set, the
...
...
@@ -739,10 +732,10 @@ func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64, item
"content of file
\"
/etc/configmap-volume/path/to/data-2
\"
: value-2"
,
}
if
fsGroup
==
0
{
modeString
:=
fmt
.
Sprintf
(
"%v"
,
os
.
FileMode
(
*
itemMode
)
)
output
=
append
(
output
,
"mode of file
\"
/etc/configmap-volume/path/to/data-2
\"
: "
+
modeString
)
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/configmap-volume/path/to/data-2"
,
itemMode
)
output
=
append
(
output
,
fileModeRegexp
)
}
f
.
TestContainerOutput
(
"consume configMaps"
,
pod
,
0
,
output
)
f
.
TestContainerOutput
Regexp
(
"consume configMaps"
,
pod
,
0
,
output
)
}
func
createNonOptionalConfigMapPod
(
f
*
framework
.
Framework
,
volumeMountPath
,
podName
string
)
error
{
...
...
test/e2e/common/projected_configmap.go
View file @
409a5eca
...
...
@@ -18,7 +18,6 @@ package common
import
(
"fmt"
"os"
"path"
"k8s.io/api/core/v1"
...
...
@@ -574,17 +573,14 @@ func doProjectedConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup
if
defaultMode
!=
nil
{
//pod.Spec.Volumes[0].VolumeSource.Projected.Sources[0].ConfigMap.DefaultMode = defaultMode
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
.
Projected
.
DefaultMode
=
defaultMode
}
else
{
mode
:=
int32
(
0644
)
defaultMode
=
&
mode
}
modeString
:=
fmt
.
Sprintf
(
"%v"
,
os
.
FileMode
(
*
defaultMode
)
)
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/projected-configmap-volume/data-1"
,
defaultMode
)
output
:=
[]
string
{
"content of file
\"
/etc/projected-configmap-volume/data-1
\"
: value-1"
,
"mode of file
\"
/etc/projected-configmap-volume/data-1
\"
: "
+
modeString
,
fileModeRegexp
,
}
f
.
TestContainerOutput
(
"consume configMaps"
,
pod
,
0
,
output
)
f
.
TestContainerOutput
Regexp
(
"consume configMaps"
,
pod
,
0
,
output
)
}
func
doProjectedConfigMapE2EWithMappings
(
f
*
framework
.
Framework
,
uid
,
fsGroup
int64
,
itemMode
*
int32
)
{
...
...
@@ -665,9 +661,6 @@ func doProjectedConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup in
if
itemMode
!=
nil
{
//pod.Spec.Volumes[0].VolumeSource.ConfigMap.Items[0].Mode = itemMode
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
.
Projected
.
DefaultMode
=
itemMode
}
else
{
mode
:=
int32
(
0644
)
itemMode
=
&
mode
}
// Just check file mode if fsGroup is not set. If fsGroup is set, the
...
...
@@ -676,8 +669,8 @@ func doProjectedConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup in
"content of file
\"
/etc/projected-configmap-volume/path/to/data-2
\"
: value-2"
,
}
if
fsGroup
==
0
{
modeString
:=
fmt
.
Sprintf
(
"%v"
,
os
.
FileMode
(
*
itemMode
)
)
output
=
append
(
output
,
"mode of file
\"
/etc/projected-configmap-volume/path/to/data-2
\"
: "
+
modeString
)
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/projected-configmap-volume/path/to/data-2"
,
itemMode
)
output
=
append
(
output
,
fileModeRegexp
)
}
f
.
TestContainerOutput
(
"consume configMaps"
,
pod
,
0
,
output
)
f
.
TestContainerOutput
Regexp
(
"consume configMaps"
,
pod
,
0
,
output
)
}
test/e2e/common/projected_secret.go
View file @
409a5eca
...
...
@@ -18,7 +18,6 @@ package common
import
(
"fmt"
"os"
"path"
"k8s.io/api/core/v1"
...
...
@@ -193,9 +192,10 @@ var _ = Describe("[sig-storage] Projected secret", func() {
},
}
f
.
TestContainerOutput
(
"consume secrets"
,
pod
,
0
,
[]
string
{
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/projected-secret-volume/data-1"
,
nil
)
f
.
TestContainerOutputRegexp
(
"consume secrets"
,
pod
,
0
,
[]
string
{
"content of file
\"
/etc/projected-secret-volume/data-1
\"
: value-1"
,
"mode of file
\"
/etc/projected-secret-volume/data-1
\"
: -rw-r--r--"
,
fileModeRegexp
,
})
})
...
...
@@ -481,9 +481,6 @@ func doProjectedSecretE2EWithoutMapping(f *framework.Framework, defaultMode *int
if
defaultMode
!=
nil
{
//pod.Spec.Volumes[0].VolumeSource.Projected.Sources[0].Secret.DefaultMode = defaultMode
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
.
Projected
.
DefaultMode
=
defaultMode
}
else
{
mode
:=
int32
(
0644
)
defaultMode
=
&
mode
}
if
fsGroup
!=
nil
||
uid
!=
nil
{
...
...
@@ -493,13 +490,13 @@ func doProjectedSecretE2EWithoutMapping(f *framework.Framework, defaultMode *int
}
}
modeString
:=
fmt
.
Sprintf
(
"%v"
,
os
.
FileMode
(
*
defaultMode
)
)
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/projected-secret-volume/data-1"
,
defaultMode
)
expectedOutput
:=
[]
string
{
"content of file
\"
/etc/projected-secret-volume/data-1
\"
: value-1"
,
"mode of file
\"
/etc/projected-secret-volume/data-1
\"
: "
+
modeString
,
fileModeRegexp
,
}
f
.
TestContainerOutput
(
"consume secrets"
,
pod
,
0
,
expectedOutput
)
f
.
TestContainerOutput
Regexp
(
"consume secrets"
,
pod
,
0
,
expectedOutput
)
}
func
doProjectedSecretE2EWithMapping
(
f
*
framework
.
Framework
,
mode
*
int32
)
{
...
...
@@ -567,16 +564,13 @@ func doProjectedSecretE2EWithMapping(f *framework.Framework, mode *int32) {
if
mode
!=
nil
{
//pod.Spec.Volumes[0].VolumeSource.Projected.Sources[0].Secret.Items[0].Mode = mode
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
.
Projected
.
DefaultMode
=
mode
}
else
{
defaultItemMode
:=
int32
(
0644
)
mode
=
&
defaultItemMode
}
modeString
:=
fmt
.
Sprintf
(
"%v"
,
os
.
FileMode
(
*
mode
)
)
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/projected-secret-volume/new-path-data-1"
,
mode
)
expectedOutput
:=
[]
string
{
"content of file
\"
/etc/projected-secret-volume/new-path-data-1
\"
: value-1"
,
"mode of file
\"
/etc/projected-secret-volume/new-path-data-1
\"
: "
+
modeString
,
fileModeRegexp
,
}
f
.
TestContainerOutput
(
"consume secrets"
,
pod
,
0
,
expectedOutput
)
f
.
TestContainerOutput
Regexp
(
"consume secrets"
,
pod
,
0
,
expectedOutput
)
}
test/e2e/common/secrets_volume.go
View file @
409a5eca
...
...
@@ -18,7 +18,6 @@ package common
import
(
"fmt"
"os"
"path"
"k8s.io/api/core/v1"
...
...
@@ -182,9 +181,10 @@ var _ = Describe("[sig-storage] Secrets", func() {
},
}
f
.
TestContainerOutput
(
"consume secrets"
,
pod
,
0
,
[]
string
{
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/secret-volume/data-1"
,
nil
)
f
.
TestContainerOutputRegexp
(
"consume secrets"
,
pod
,
0
,
[]
string
{
"content of file
\"
/etc/secret-volume/data-1
\"
: value-1"
,
"mode of file
\"
/etc/secret-volume/data-1
\"
: -rw-r--r--"
,
fileModeRegexp
,
})
})
...
...
@@ -451,9 +451,6 @@ func doSecretE2EWithoutMapping(f *framework.Framework, defaultMode *int32, secre
if
defaultMode
!=
nil
{
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
.
Secret
.
DefaultMode
=
defaultMode
}
else
{
mode
:=
int32
(
0644
)
defaultMode
=
&
mode
}
if
fsGroup
!=
nil
||
uid
!=
nil
{
...
...
@@ -463,13 +460,13 @@ func doSecretE2EWithoutMapping(f *framework.Framework, defaultMode *int32, secre
}
}
modeString
:=
fmt
.
Sprintf
(
"%v"
,
os
.
FileMode
(
*
defaultMode
)
)
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/secret-volume/data-1"
,
defaultMode
)
expectedOutput
:=
[]
string
{
"content of file
\"
/etc/secret-volume/data-1
\"
: value-1"
,
"mode of file
\"
/etc/secret-volume/data-1
\"
: "
+
modeString
,
fileModeRegexp
,
}
f
.
TestContainerOutput
(
"consume secrets"
,
pod
,
0
,
expectedOutput
)
f
.
TestContainerOutput
Regexp
(
"consume secrets"
,
pod
,
0
,
expectedOutput
)
}
func
doSecretE2EWithMapping
(
f
*
framework
.
Framework
,
mode
*
int32
)
{
...
...
@@ -528,18 +525,15 @@ func doSecretE2EWithMapping(f *framework.Framework, mode *int32) {
if
mode
!=
nil
{
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
.
Secret
.
Items
[
0
]
.
Mode
=
mode
}
else
{
defaultItemMode
:=
int32
(
0644
)
mode
=
&
defaultItemMode
}
modeString
:=
fmt
.
Sprintf
(
"%v"
,
os
.
FileMode
(
*
mode
)
)
fileModeRegexp
:=
framework
.
GetFileModeRegex
(
"/etc/secret-volume/new-path-data-1"
,
mode
)
expectedOutput
:=
[]
string
{
"content of file
\"
/etc/secret-volume/new-path-data-1
\"
: value-1"
,
"mode of file
\"
/etc/secret-volume/new-path-data-1
\"
: "
+
modeString
,
fileModeRegexp
,
}
f
.
TestContainerOutput
(
"consume secrets"
,
pod
,
0
,
expectedOutput
)
f
.
TestContainerOutput
Regexp
(
"consume secrets"
,
pod
,
0
,
expectedOutput
)
}
func
createNonOptionalSecretPod
(
f
*
framework
.
Framework
,
volumeMountPath
,
podName
string
)
error
{
...
...
test/e2e/framework/util.go
View file @
409a5eca
...
...
@@ -5272,3 +5272,24 @@ func WaitForNodeHasTaintOrNot(c clientset.Interface, nodeName string, taint *v1.
}
return
nil
}
// GetFileModeRegex returns a file mode related regex which should be matched by the mounttest pods' output.
// If the given mask is nil, then the regex will contain the default OS file modes, which are 0644 for Linux and 0775 for Windows.
func
GetFileModeRegex
(
filePath
string
,
mask
*
int32
)
string
{
var
(
linuxMask
int32
windowsMask
int32
)
if
mask
==
nil
{
linuxMask
=
int32
(
0644
)
windowsMask
=
int32
(
0775
)
}
else
{
linuxMask
=
*
mask
windowsMask
=
*
mask
}
linuxOutput
:=
fmt
.
Sprintf
(
"mode of file
\"
%s
\"
: %v"
,
filePath
,
os
.
FileMode
(
linuxMask
))
windowsOutput
:=
fmt
.
Sprintf
(
"mode of Windows file
\"
%v
\"
: %s"
,
filePath
,
os
.
FileMode
(
windowsMask
))
return
fmt
.
Sprintf
(
"(%s|%s)"
,
linuxOutput
,
windowsOutput
)
}
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