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
ff2ad084
Commit
ff2ad084
authored
Sep 01, 2017
by
Cheng Xing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed volume IO e2e test to verify file hash instead of content.
parent
44c51821
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
18 deletions
+31
-18
volume_io.go
test/e2e/storage/volume_io.go
+31
-18
No files found.
test/e2e/storage/volume_io.go
View file @
ff2ad084
...
@@ -42,7 +42,22 @@ import (
...
@@ -42,7 +42,22 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
)
)
const
minFileSize
=
1
*
framework
.
MiB
const
(
minFileSize
=
1
*
framework
.
MiB
fileSizeSmall
=
1
*
framework
.
MiB
fileSizeMedium
=
100
*
framework
.
MiB
fileSizeLarge
=
1
*
framework
.
GiB
)
// MD5 hashes of the test file corresponding to each file size.
// Test files are generated in testVolumeIO()
// If test file generation algorithm changes, these must be recomputed.
var
md5hashes
=
map
[
int64
]
string
{
fileSizeSmall
:
"5c34c2813223a7ca05a3c2f38c0d1710"
,
fileSizeMedium
:
"f2fa202b1ffeedda5f3a58bd1ae81104"
,
fileSizeLarge
:
"8d763edc71bd16217664793b5a15e403"
,
}
// Return the plugin's client pod spec. Use an InitContainer to setup the file i/o test env.
// Return the plugin's client pod spec. Use an InitContainer to setup the file i/o test env.
func
makePodSpec
(
config
framework
.
VolumeTestConfig
,
dir
,
initCmd
string
,
volsrc
v1
.
VolumeSource
,
podSecContext
*
v1
.
PodSecurityContext
)
*
v1
.
Pod
{
func
makePodSpec
(
config
framework
.
VolumeTestConfig
,
dir
,
initCmd
string
,
volsrc
v1
.
VolumeSource
,
podSecContext
*
v1
.
PodSecurityContext
)
*
v1
.
Pod
{
...
@@ -131,22 +146,20 @@ func verifyFile(pod *v1.Pod, fpath string, expectSize int64, dd_input string) er
...
@@ -131,22 +146,20 @@ func verifyFile(pod *v1.Pod, fpath string, expectSize int64, dd_input string) er
return
fmt
.
Errorf
(
"size of file %s is %d, expected %d"
,
fpath
,
size
,
expectSize
)
return
fmt
.
Errorf
(
"size of file %s is %d, expected %d"
,
fpath
,
size
,
expectSize
)
}
}
By
(
"verifying file content"
)
By
(
"verifying file hash"
)
// use `grep ... -f` rather than the expected content in a variable to reduce logging
rtnstr
,
err
=
podExec
(
pod
,
fmt
.
Sprintf
(
"md5sum %s | cut -d' ' -f1"
,
fpath
))
rtnstr
,
err
=
podExec
(
pod
,
fmt
.
Sprintf
(
"grep -c -m1 -f %s %s"
,
dd_input
,
fpath
))
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to test file
content via `grep
%s`: %v"
,
fpath
,
err
)
return
fmt
.
Errorf
(
"unable to test file
hash via `md5sum
%s`: %v"
,
fpath
,
err
)
}
}
foundCnt
,
err
:=
strconv
.
Atoi
(
strings
.
TrimSuffix
(
rtnstr
,
"
\n
"
))
actualHash
:=
strings
.
TrimSuffix
(
rtnstr
,
"
\n
"
)
if
err
!=
nil
{
expectedHash
,
ok
:=
md5hashes
[
expectSize
]
return
fmt
.
Errorf
(
"unable to convert string %q to int: %v"
,
rtnstr
,
err
)
if
!
ok
{
return
fmt
.
Errorf
(
"File hash is unknown for file size %d. Was a new file size added to the test suite?"
,
expectSize
)
}
}
if
foundCnt
==
0
{
if
actualHash
!=
expectedHash
{
rtnstr
,
err
=
podExec
(
pod
,
fmt
.
Sprintf
(
"cat %s"
,
dd_input
))
return
fmt
.
Errorf
(
"MD5 hash is incorrect for file %s with size %d. Expected: `%s`; Actual: `%s`"
,
if
err
!=
nil
||
len
(
rtnstr
)
==
0
{
fpath
,
expectSize
,
expectedHash
,
actualHash
)
return
fmt
.
Errorf
(
"string not found in file %s and unable to read dd's input file %s: %v"
,
fpath
,
dd_input
,
err
)
}
return
fmt
.
Errorf
(
"string %q not found in file %s"
,
rtnstr
,
fpath
)
}
}
return
nil
return
nil
...
@@ -270,7 +283,7 @@ var _ = SIGDescribe("Volume plugin streaming [Slow]", func() {
...
@@ -270,7 +283,7 @@ var _ = SIGDescribe("Volume plugin streaming [Slow]", func() {
})
})
It
(
"should write files of various sizes, verify size, validate content"
,
func
()
{
It
(
"should write files of various sizes, verify size, validate content"
,
func
()
{
fileSizes
:=
[]
int64
{
1
*
framework
.
MiB
,
100
*
framework
.
MiB
,
1
*
framework
.
GiB
}
fileSizes
:=
[]
int64
{
fileSizeSmall
,
fileSizeMedium
,
fileSizeLarge
}
err
:=
testVolumeIO
(
f
,
cs
,
config
,
volSource
,
&
podSec
,
testFile
,
fileSizes
)
err
:=
testVolumeIO
(
f
,
cs
,
config
,
volSource
,
&
podSec
,
testFile
,
fileSizes
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
})
...
@@ -315,7 +328,7 @@ var _ = SIGDescribe("Volume plugin streaming [Slow]", func() {
...
@@ -315,7 +328,7 @@ var _ = SIGDescribe("Volume plugin streaming [Slow]", func() {
})
})
It
(
"should write files of various sizes, verify size, validate content"
,
func
()
{
It
(
"should write files of various sizes, verify size, validate content"
,
func
()
{
fileSizes
:=
[]
int64
{
1
*
framework
.
MiB
,
100
*
framework
.
MiB
}
fileSizes
:=
[]
int64
{
fileSizeSmall
,
fileSizeMedium
}
err
:=
testVolumeIO
(
f
,
cs
,
config
,
volSource
,
nil
/*no secContext*/
,
testFile
,
fileSizes
)
err
:=
testVolumeIO
(
f
,
cs
,
config
,
volSource
,
nil
/*no secContext*/
,
testFile
,
fileSizes
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
})
...
@@ -349,7 +362,7 @@ var _ = SIGDescribe("Volume plugin streaming [Slow]", func() {
...
@@ -349,7 +362,7 @@ var _ = SIGDescribe("Volume plugin streaming [Slow]", func() {
})
})
It
(
"should write files of various sizes, verify size, validate content"
,
func
()
{
It
(
"should write files of various sizes, verify size, validate content"
,
func
()
{
fileSizes
:=
[]
int64
{
1
*
framework
.
MiB
,
100
*
framework
.
MiB
}
fileSizes
:=
[]
int64
{
fileSizeSmall
,
fileSizeMedium
}
fsGroup
:=
int64
(
1234
)
fsGroup
:=
int64
(
1234
)
podSec
:=
v1
.
PodSecurityContext
{
podSec
:=
v1
.
PodSecurityContext
{
FSGroup
:
&
fsGroup
,
FSGroup
:
&
fsGroup
,
...
@@ -424,7 +437,7 @@ var _ = SIGDescribe("Volume plugin streaming [Slow]", func() {
...
@@ -424,7 +437,7 @@ var _ = SIGDescribe("Volume plugin streaming [Slow]", func() {
})
})
It
(
"should write files of various sizes, verify size, validate content"
,
func
()
{
It
(
"should write files of various sizes, verify size, validate content"
,
func
()
{
fileSizes
:=
[]
int64
{
1
*
framework
.
MiB
,
100
*
framework
.
MiB
}
fileSizes
:=
[]
int64
{
fileSizeSmall
,
fileSizeMedium
}
fsGroup
:=
int64
(
1234
)
fsGroup
:=
int64
(
1234
)
podSec
:=
v1
.
PodSecurityContext
{
podSec
:=
v1
.
PodSecurityContext
{
FSGroup
:
&
fsGroup
,
FSGroup
:
&
fsGroup
,
...
...
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