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
7778b0df
Commit
7778b0df
authored
Aug 04, 2017
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix local storage test failures
parent
f189d7f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
19 deletions
+29
-19
persistent_volumes-local.go
test/e2e/storage/persistent_volumes-local.go
+29
-19
No files found.
test/e2e/storage/persistent_volumes-local.go
View file @
7778b0df
...
@@ -50,8 +50,6 @@ type localTestVolume struct {
...
@@ -50,8 +50,6 @@ type localTestVolume struct {
node
*
v1
.
Node
node
*
v1
.
Node
// Path to the volume on the host node
// Path to the volume on the host node
hostDir
string
hostDir
string
// Path to the volume in the local util container
containerDir
string
// PVC for this volume
// PVC for this volume
pvc
*
v1
.
PersistentVolumeClaim
pvc
*
v1
.
PersistentVolumeClaim
// PV for this volume
// PV for this volume
...
@@ -322,8 +320,10 @@ var _ = SIGDescribe("PersistentVolumes-local [Feature:LocalPersistentVolumes] [S
...
@@ -322,8 +320,10 @@ var _ = SIGDescribe("PersistentVolumes-local [Feature:LocalPersistentVolumes] [S
By
(
"Creating a directory under discovery path"
)
By
(
"Creating a directory under discovery path"
)
framework
.
Logf
(
"creating local volume under path %q"
,
volumePath
)
framework
.
Logf
(
"creating local volume under path %q"
,
volumePath
)
mkdirCmd
:=
fmt
.
Sprintf
(
"mkdir %v -m 777"
,
volumePath
)
mkdirCmd
:=
fmt
.
Sprintf
(
"mkdir %v -m 777"
,
volumePath
)
_
,
err
:=
framework
.
NodeExec
(
node0
.
Name
,
mkdirCmd
)
err
:=
framework
.
IssueSSHCommand
(
mkdirCmd
,
framework
.
TestContext
.
Provider
,
node0
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Waiting for a PersitentVolume to be created"
)
oldPV
,
err
:=
waitForLocalPersistentVolume
(
config
.
client
,
volumePath
)
oldPV
,
err
:=
waitForLocalPersistentVolume
(
config
.
client
,
volumePath
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -333,22 +333,27 @@ var _ = SIGDescribe("PersistentVolumes-local [Feature:LocalPersistentVolumes] [S
...
@@ -333,22 +333,27 @@ var _ = SIGDescribe("PersistentVolumes-local [Feature:LocalPersistentVolumes] [S
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
framework
.
WaitForPersistentVolumeClaimPhase
(
err
=
framework
.
WaitForPersistentVolumeClaimPhase
(
v1
.
ClaimBound
,
config
.
client
,
claim
.
Namespace
,
claim
.
Name
,
framework
.
Poll
,
1
*
time
.
Minute
)
v1
.
ClaimBound
,
config
.
client
,
claim
.
Namespace
,
claim
.
Name
,
framework
.
Poll
,
1
*
time
.
Minute
)
Expect
(
claim
.
Spec
.
VolumeName
)
.
To
(
Equal
(
oldPV
.
Name
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
claim
,
err
=
config
.
client
.
Core
()
.
PersistentVolumeClaims
(
config
.
ns
)
.
Get
(
claim
.
Name
,
metav1
.
GetOptions
{})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
claim
.
Spec
.
VolumeName
)
.
To
(
Equal
(
oldPV
.
Name
))
// Delete the persistent volume claim: file will be cleaned up and volume be re-created.
// Delete the persistent volume claim: file will be cleaned up and volume be re-created.
By
(
"Deleting the persistent volume claim to clean up persistent volume and re-create one"
)
By
(
"Deleting the persistent volume claim to clean up persistent volume and re-create one"
)
writeCmd
,
readCmd
:=
createWriteAndReadCmds
(
volumePath
,
testFile
,
testFileContent
)
writeCmd
,
_
:=
createWriteAndReadCmds
(
volumePath
,
testFile
,
testFileContent
)
_
,
err
=
framework
.
NodeExec
(
node0
.
Name
,
writeCmd
)
err
=
framework
.
IssueSSHCommand
(
writeCmd
,
framework
.
TestContext
.
Provider
,
node0
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
config
.
client
.
Core
()
.
PersistentVolumeClaims
(
claim
.
Namespace
)
.
Delete
(
claim
.
Name
,
&
metav1
.
DeleteOptions
{})
err
=
config
.
client
.
Core
()
.
PersistentVolumeClaims
(
claim
.
Namespace
)
.
Delete
(
claim
.
Name
,
&
metav1
.
DeleteOptions
{})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Waiting for a new PersistentVolume to be re-created"
)
newPV
,
err
:=
waitForLocalPersistentVolume
(
config
.
client
,
volumePath
)
newPV
,
err
:=
waitForLocalPersistentVolume
(
config
.
client
,
volumePath
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
newPV
.
UID
)
.
NotTo
(
Equal
(
oldPV
.
UID
))
Expect
(
newPV
.
UID
)
.
NotTo
(
Equal
(
oldPV
.
UID
))
result
,
err
:=
framework
.
NodeExec
(
node0
.
Name
,
readCmd
)
fileDoesntExistCmd
:=
createFileDoesntExistCmd
(
volumePath
,
testFile
)
err
=
framework
.
IssueSSHCommand
(
fileDoesntExistCmd
,
framework
.
TestContext
.
Provider
,
node0
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
result
.
Code
)
.
NotTo
(
BeZero
(),
"file should be deleted across local pv recreation, but exists"
)
})
})
})
})
})
})
...
@@ -362,18 +367,16 @@ func podNodeName(config *localTestConfig, pod *v1.Pod) (string, error) {
...
@@ -362,18 +367,16 @@ func podNodeName(config *localTestConfig, pod *v1.Pod) (string, error) {
// setupLocalVolume setups a directory to user for local PV
// setupLocalVolume setups a directory to user for local PV
func
setupLocalVolume
(
config
*
localTestConfig
)
*
localTestVolume
{
func
setupLocalVolume
(
config
*
localTestConfig
)
*
localTestVolume
{
testDirName
:=
"local-volume-test-"
+
string
(
uuid
.
NewUUID
())
testDirName
:=
"local-volume-test-"
+
string
(
uuid
.
NewUUID
())
testDir
:=
filepath
.
Join
(
containerBase
,
testDirName
)
hostDir
:=
filepath
.
Join
(
hostBase
,
testDirName
)
hostDir
:=
filepath
.
Join
(
hostBase
,
testDirName
)
// populate volume with testFile containing testFileContent
// populate volume with testFile containing testFileContent
writeCmd
,
_
:=
createWriteAndReadCmds
(
te
stDir
,
testFile
,
testFileContent
)
writeCmd
,
_
:=
createWriteAndReadCmds
(
ho
stDir
,
testFile
,
testFileContent
)
By
(
fmt
.
Sprintf
(
"Creating local volume on node %q at path %q"
,
config
.
node0
.
Name
,
hostDir
))
By
(
fmt
.
Sprintf
(
"Creating local volume on node %q at path %q"
,
config
.
node0
.
Name
,
hostDir
))
_
,
err
:=
framework
.
NodeExec
(
config
.
node0
.
Name
,
writeCmd
)
err
:=
framework
.
IssueSSHCommand
(
writeCmd
,
framework
.
TestContext
.
Provider
,
config
.
node0
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
return
&
localTestVolume
{
return
&
localTestVolume
{
node
:
config
.
node0
,
node
:
config
.
node0
,
hostDir
:
hostDir
,
hostDir
:
hostDir
,
containerDir
:
testDir
,
}
}
}
}
...
@@ -390,8 +393,8 @@ func cleanupLocalVolume(config *localTestConfig, volume *localTestVolume) {
...
@@ -390,8 +393,8 @@ func cleanupLocalVolume(config *localTestConfig, volume *localTestVolume) {
}
}
By
(
"Removing the test directory"
)
By
(
"Removing the test directory"
)
removeCmd
:=
fmt
.
Sprintf
(
"rm -r %s"
,
volume
.
container
Dir
)
removeCmd
:=
fmt
.
Sprintf
(
"rm -r %s"
,
volume
.
host
Dir
)
_
,
err
:=
framework
.
NodeExec
(
config
.
node0
.
Name
,
removeCmd
)
err
:=
framework
.
IssueSSHCommand
(
removeCmd
,
framework
.
TestContext
.
Provider
,
config
.
node0
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
}
...
@@ -459,7 +462,7 @@ func createLocalPod(config *localTestConfig, volume *localTestVolume) (*v1.Pod,
...
@@ -459,7 +462,7 @@ func createLocalPod(config *localTestConfig, volume *localTestVolume) (*v1.Pod,
}
}
// Create corresponding write and read commands
// Create corresponding write and read commands
// to be executed
inside containers with local PV attached
// to be executed
via SSH on the node with the local PV
func
createWriteAndReadCmds
(
testFileDir
string
,
testFile
string
,
writeTestFileContent
string
)
(
writeCmd
string
,
readCmd
string
)
{
func
createWriteAndReadCmds
(
testFileDir
string
,
testFile
string
,
writeTestFileContent
string
)
(
writeCmd
string
,
readCmd
string
)
{
testFilePath
:=
filepath
.
Join
(
testFileDir
,
testFile
)
testFilePath
:=
filepath
.
Join
(
testFileDir
,
testFile
)
writeCmd
=
fmt
.
Sprintf
(
"mkdir -p %s; echo %s > %s"
,
testFileDir
,
writeTestFileContent
,
testFilePath
)
writeCmd
=
fmt
.
Sprintf
(
"mkdir -p %s; echo %s > %s"
,
testFileDir
,
writeTestFileContent
,
testFilePath
)
...
@@ -467,6 +470,13 @@ func createWriteAndReadCmds(testFileDir string, testFile string, writeTestFileCo
...
@@ -467,6 +470,13 @@ func createWriteAndReadCmds(testFileDir string, testFile string, writeTestFileCo
return
writeCmd
,
readCmd
return
writeCmd
,
readCmd
}
}
// Create command to verify that the file doesn't exist
// to be executed via SSH on the node with the local PV
func
createFileDoesntExistCmd
(
testFileDir
string
,
testFile
string
)
string
{
testFilePath
:=
filepath
.
Join
(
testFileDir
,
testFile
)
return
fmt
.
Sprintf
(
"[ ! -e %s ]"
,
testFilePath
)
}
// Execute a read or write command in a pod.
// Execute a read or write command in a pod.
// Fail on error
// Fail on error
func
podRWCmdExec
(
pod
*
v1
.
Pod
,
cmd
string
)
string
{
func
podRWCmdExec
(
pod
*
v1
.
Pod
,
cmd
string
)
string
{
...
@@ -495,7 +505,7 @@ func setupLocalVolumeProvisioner(config *localTestConfig) {
...
@@ -495,7 +505,7 @@ func setupLocalVolumeProvisioner(config *localTestConfig) {
By
(
"Initializing local volume discovery base path"
)
By
(
"Initializing local volume discovery base path"
)
mkdirCmd
:=
fmt
.
Sprintf
(
"mkdir %v -m 777"
,
path
.
Join
(
hostBase
,
discoveryDir
))
mkdirCmd
:=
fmt
.
Sprintf
(
"mkdir %v -m 777"
,
path
.
Join
(
hostBase
,
discoveryDir
))
_
,
err
:=
framework
.
NodeExec
(
config
.
node0
.
Name
,
mkdirCmd
)
err
:=
framework
.
IssueSSHCommand
(
mkdirCmd
,
framework
.
TestContext
.
Provider
,
config
.
node0
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
}
...
@@ -505,7 +515,7 @@ func cleanupLocalVolumeProvisioner(config *localTestConfig, volumePath string) {
...
@@ -505,7 +515,7 @@ func cleanupLocalVolumeProvisioner(config *localTestConfig, volumePath string) {
By
(
"Removing the test directory"
)
By
(
"Removing the test directory"
)
removeCmd
:=
fmt
.
Sprintf
(
"rm -r %s"
,
path
.
Join
(
hostBase
,
discoveryDir
))
removeCmd
:=
fmt
.
Sprintf
(
"rm -r %s"
,
path
.
Join
(
hostBase
,
discoveryDir
))
_
,
err
:=
framework
.
NodeExec
(
config
.
node0
.
Name
,
removeCmd
)
err
:=
framework
.
IssueSSHCommand
(
removeCmd
,
framework
.
TestContext
.
Provider
,
config
.
node0
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Cleaning up persistent volume"
)
By
(
"Cleaning up persistent volume"
)
...
...
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