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
84d630c1
Commit
84d630c1
authored
Feb 09, 2017
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add PV upgrade test
parent
c522b775
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
0 deletions
+100
-0
cluster_upgrade.go
test/e2e/cluster_upgrade.go
+1
-0
BUILD
test/e2e/upgrades/BUILD
+1
-0
persistent_volumes.go
test/e2e/upgrades/persistent_volumes.go
+98
-0
No files found.
test/e2e/cluster_upgrade.go
View file @
84d630c1
...
@@ -36,6 +36,7 @@ var upgradeTests = []upgrades.Test{
...
@@ -36,6 +36,7 @@ var upgradeTests = []upgrades.Test{
&
upgrades
.
DeploymentUpgradeTest
{},
&
upgrades
.
DeploymentUpgradeTest
{},
&
upgrades
.
ConfigMapUpgradeTest
{},
&
upgrades
.
ConfigMapUpgradeTest
{},
&
upgrades
.
HPAUpgradeTest
{},
&
upgrades
.
HPAUpgradeTest
{},
&
upgrades
.
PersistentVolumeUpgradeTest
{},
}
}
var
_
=
framework
.
KubeDescribe
(
"Upgrade [Feature:Upgrade]"
,
func
()
{
var
_
=
framework
.
KubeDescribe
(
"Upgrade [Feature:Upgrade]"
,
func
()
{
...
...
test/e2e/upgrades/BUILD
View file @
84d630c1
...
@@ -13,6 +13,7 @@ go_library(
...
@@ -13,6 +13,7 @@ go_library(
"configmaps.go",
"configmaps.go",
"deployments.go",
"deployments.go",
"horizontal_pod_autoscalers.go",
"horizontal_pod_autoscalers.go",
"persistent_volumes.go",
"secrets.go",
"secrets.go",
"services.go",
"services.go",
"statefulset.go",
"statefulset.go",
...
...
test/e2e/upgrades/persistent_volumes.go
0 → 100644
View file @
84d630c1
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
upgrades
import
(
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/test/e2e/framework"
.
"github.com/onsi/ginkgo"
)
// PersistentVolumeUpgradeTest test that a pv is available before and after a cluster upgrade.
type
PersistentVolumeUpgradeTest
struct
{
pvSource
*
v1
.
PersistentVolumeSource
pv
*
v1
.
PersistentVolume
pvc
*
v1
.
PersistentVolumeClaim
}
const
(
pvTestFile
string
=
"/mnt/pv_upgrade_test"
pvTestData
string
=
"keep it pv"
pvWriteCmd
string
=
"echo
\"
"
+
pvTestData
+
"
\"
> "
+
pvTestFile
pvReadCmd
string
=
"cat "
+
pvTestFile
)
func
(
t
*
PersistentVolumeUpgradeTest
)
createGCEVolume
()
*
v1
.
PersistentVolumeSource
{
diskName
,
err
:=
framework
.
CreatePDWithRetry
()
framework
.
ExpectNoError
(
err
)
return
&
v1
.
PersistentVolumeSource
{
GCEPersistentDisk
:
&
v1
.
GCEPersistentDiskVolumeSource
{
PDName
:
diskName
,
FSType
:
"ext3"
,
ReadOnly
:
false
,
},
}
}
func
(
t
*
PersistentVolumeUpgradeTest
)
deleteGCEVolume
(
pvSource
*
v1
.
PersistentVolumeSource
)
{
framework
.
DeletePDWithRetry
(
pvSource
.
GCEPersistentDisk
.
PDName
)
}
// Setup creates a pv and then verifies that a pod can consume it. The pod writes data to the volume.
func
(
t
*
PersistentVolumeUpgradeTest
)
Setup
(
f
*
framework
.
Framework
)
{
// TODO: generalize this to other providers
framework
.
SkipUnlessProviderIs
(
"gce"
,
"gke"
)
ns
:=
f
.
Namespace
.
Name
By
(
"Initializing PV source"
)
t
.
pvSource
=
t
.
createGCEVolume
()
pvConfig
:=
framework
.
PersistentVolumeConfig
{
NamePrefix
:
"pv-upgrade"
,
PVSource
:
*
t
.
pvSource
,
Prebind
:
nil
,
}
By
(
"Creating the PV and PVC"
)
t
.
pv
,
t
.
pvc
=
framework
.
CreatePVPVC
(
f
.
ClientSet
,
pvConfig
,
ns
,
true
)
framework
.
WaitOnPVandPVC
(
f
.
ClientSet
,
ns
,
t
.
pv
,
t
.
pvc
)
By
(
"Consuming the PV before upgrade"
)
t
.
testPod
(
f
,
pvWriteCmd
+
";"
+
pvReadCmd
)
}
// Test waits for the upgrade to complete, and then verifies that a pod can still consume the pv
// and that the volume data persists.
func
(
t
*
PersistentVolumeUpgradeTest
)
Test
(
f
*
framework
.
Framework
,
done
<-
chan
struct
{},
upgrade
UpgradeType
)
{
<-
done
By
(
"Consuming the PV after upgrade"
)
t
.
testPod
(
f
,
pvReadCmd
)
}
// Teardown cleans up any remaining resources.
func
(
t
*
PersistentVolumeUpgradeTest
)
Teardown
(
f
*
framework
.
Framework
)
{
framework
.
PVPVCCleanup
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
t
.
pv
,
t
.
pvc
)
t
.
deleteGCEVolume
(
t
.
pvSource
)
}
// testPod creates a pod that consumes a pv and prints it out. The output is then verified.
func
(
t
*
PersistentVolumeUpgradeTest
)
testPod
(
f
*
framework
.
Framework
,
cmd
string
)
{
pod
:=
framework
.
MakePod
(
f
.
Namespace
.
Name
,
t
.
pvc
.
Name
,
false
,
cmd
)
expectedOutput
:=
[]
string
{
pvTestData
}
f
.
TestContainerOutput
(
"pod consumes pv"
,
pod
,
0
,
expectedOutput
)
}
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