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
855f3fae
Unverified
Commit
855f3fae
authored
Nov 26, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 26, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #71235 from msau42/fix-hostpath-io
Fix io test to use unique file names and cleanup all files
parents
b493bbb2
11627ae1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
volume_io.go
test/e2e/storage/testsuites/volume_io.go
+14
-12
No files found.
test/e2e/storage/testsuites/volume_io.go
View file @
855f3fae
...
...
@@ -24,7 +24,7 @@ package testsuites
import
(
"fmt"
"math"
"path"
"path
/filepath
"
"strconv"
"strings"
"time"
...
...
@@ -49,6 +49,8 @@ var md5hashes = map[int64]string{
testpatterns
.
FileSizeLarge
:
"8d763edc71bd16217664793b5a15e403"
,
}
const
mountPath
=
"/opt"
type
volumeIOTestSuite
struct
{
tsInfo
TestSuiteInfo
}
...
...
@@ -176,10 +178,9 @@ func createFileSizes(maxFileSize int64) []int64 {
}
// 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
{
volName
:=
fmt
.
Sprintf
(
"%s-%s"
,
config
.
Prefix
,
"io-volume"
)
func
makePodSpec
(
config
framework
.
VolumeTestConfig
,
initCmd
string
,
volsrc
v1
.
VolumeSource
,
podSecContext
*
v1
.
PodSecurityContext
)
*
v1
.
Pod
{
var
gracePeriod
int64
=
1
volName
:=
fmt
.
Sprintf
(
"io-volume-%s"
,
config
.
Namespace
)
return
&
v1
.
Pod
{
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"Pod"
,
...
...
@@ -204,7 +205,7 @@ func makePodSpec(config framework.VolumeTestConfig, dir, initCmd string, volsrc
VolumeMounts
:
[]
v1
.
VolumeMount
{
{
Name
:
volName
,
MountPath
:
dir
,
MountPath
:
mountPath
,
},
},
},
...
...
@@ -221,7 +222,7 @@ func makePodSpec(config framework.VolumeTestConfig, dir, initCmd string, volsrc
VolumeMounts
:
[]
v1
.
VolumeMount
{
{
Name
:
volName
,
MountPath
:
dir
,
MountPath
:
mountPath
,
},
},
},
...
...
@@ -302,8 +303,7 @@ func deleteFile(pod *v1.Pod, fpath string) {
// Note: `fsizes` values are enforced to each be at least `MinFileSize` and a multiple of `MinFileSize`
// bytes.
func
testVolumeIO
(
f
*
framework
.
Framework
,
cs
clientset
.
Interface
,
config
framework
.
VolumeTestConfig
,
volsrc
v1
.
VolumeSource
,
podSecContext
*
v1
.
PodSecurityContext
,
file
string
,
fsizes
[]
int64
)
(
err
error
)
{
dir
:=
path
.
Join
(
"/opt"
,
config
.
Prefix
,
config
.
Namespace
)
ddInput
:=
path
.
Join
(
dir
,
"dd_if"
)
ddInput
:=
filepath
.
Join
(
mountPath
,
fmt
.
Sprintf
(
"%s-%s-dd_if"
,
config
.
Prefix
,
config
.
Namespace
))
writeBlk
:=
strings
.
Repeat
(
"abcdefghijklmnopqrstuvwxyz123456"
,
32
)
// 1KiB value
loopCnt
:=
testpatterns
.
MinFileSize
/
int64
(
len
(
writeBlk
))
// initContainer cmd to create and fill dd's input file. The initContainer is used to create
...
...
@@ -311,7 +311,7 @@ func testVolumeIO(f *framework.Framework, cs clientset.Interface, config framewo
// used to create a 1MiB file in the target directory.
initCmd
:=
fmt
.
Sprintf
(
"i=0; while [ $i -lt %d ]; do echo -n %s >>%s; let i+=1; done"
,
loopCnt
,
writeBlk
,
ddInput
)
clientPod
:=
makePodSpec
(
config
,
dir
,
initCmd
,
volsrc
,
podSecContext
)
clientPod
:=
makePodSpec
(
config
,
initCmd
,
volsrc
,
podSecContext
)
By
(
fmt
.
Sprintf
(
"starting %s"
,
clientPod
.
Name
))
podsNamespacer
:=
cs
.
CoreV1
()
.
Pods
(
config
.
Namespace
)
...
...
@@ -320,7 +320,7 @@ func testVolumeIO(f *framework.Framework, cs clientset.Interface, config framewo
return
fmt
.
Errorf
(
"failed to create client pod %q: %v"
,
clientPod
.
Name
,
err
)
}
defer
func
()
{
// note the test dir will be removed when the kubelet unmounts it
deleteFile
(
clientPod
,
ddInput
)
By
(
fmt
.
Sprintf
(
"deleting client pod %q..."
,
clientPod
.
Name
))
e
:=
framework
.
DeletePodWithWait
(
f
,
cs
,
clientPod
)
if
e
!=
nil
{
...
...
@@ -345,14 +345,16 @@ func testVolumeIO(f *framework.Framework, cs clientset.Interface, config framewo
if
math
.
Mod
(
float64
(
fsize
),
float64
(
testpatterns
.
MinFileSize
))
!=
0
{
fsize
=
fsize
/
testpatterns
.
MinFileSize
+
testpatterns
.
MinFileSize
}
fpath
:=
path
.
Join
(
dir
,
fmt
.
Sprintf
(
"%s-%d"
,
file
,
fsize
))
fpath
:=
filepath
.
Join
(
mountPath
,
fmt
.
Sprintf
(
"%s-%d"
,
file
,
fsize
))
defer
func
()
{
deleteFile
(
clientPod
,
fpath
)
}()
if
err
=
writeToFile
(
clientPod
,
fpath
,
ddInput
,
fsize
);
err
!=
nil
{
return
err
}
if
err
=
verifyFile
(
clientPod
,
fpath
,
fsize
,
ddInput
);
err
!=
nil
{
return
err
}
deleteFile
(
clientPod
,
fpath
)
}
return
...
...
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