Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
ae7fbaf8
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ae7fbaf8
编写于
8月 03, 2020
作者:
P
Priya Wadhwa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make sure files are actually being maintained in PVCs in our integration test
上级
5e899a81
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
6 deletion
+65
-6
test/integration/fn_pvc_test.go
test/integration/fn_pvc_test.go
+44
-3
test/integration/testdata/storage-provisioner/pod.yaml
test/integration/testdata/storage-provisioner/pod.yaml
+17
-0
test/integration/testdata/storage-provisioner/pvc.yaml
test/integration/testdata/storage-provisioner/pvc.yaml
+4
-3
未找到文件。
test/integration/fn_pvc_test.go
浏览文件 @
ae7fbaf8
...
...
@@ -24,7 +24,8 @@ import (
"encoding/json"
"fmt"
"os/exec"
"path/filepath"
"path"
"strings"
"testing"
"time"
...
...
@@ -64,13 +65,14 @@ func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile st
}
// Now create a testpvc
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"--context"
,
profile
,
"apply"
,
"-f"
,
filepath
.
Join
(
*
testdataDir
,
"pvc.yaml"
)))
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"--context"
,
profile
,
"apply"
,
"-f"
,
path
.
Join
(
*
testdataDir
,
"storage-provisioner"
,
"pvc.yaml"
)))
if
err
!=
nil
{
t
.
Fatalf
(
"kubectl apply pvc.yaml failed: args %q: %v"
,
rr
.
Command
(),
err
)
}
// make sure the pvc is Bound
checkStoragePhase
:=
func
()
error
{
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"--context"
,
profile
,
"get"
,
"pvc"
,
"
testpvc
"
,
"-o=json"
))
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"--context"
,
profile
,
"get"
,
"pvc"
,
"
myclaim
"
,
"-o=json"
))
if
err
!=
nil
{
return
err
}
...
...
@@ -88,4 +90,43 @@ func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile st
if
err
:=
retry
.
Expo
(
checkStoragePhase
,
2
*
time
.
Second
,
Minutes
(
4
));
err
!=
nil
{
t
.
Fatalf
(
"failed to check storage phase: %v"
,
err
)
}
// create a test pod that will mount the persistent volume
createPVTestPod
(
t
,
ctx
,
profile
)
// write to the persistent volume
podName
:=
"sp-pod"
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"--context"
,
profile
,
"exec"
,
podName
,
"--"
,
"touch"
,
"/tmp/mount/foo"
))
if
err
!=
nil
{
t
.
Fatalf
(
"creating file in pv: args %q: %v"
,
rr
.
Command
(),
err
)
}
// kill the pod
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"--context"
,
profile
,
"delete"
,
"-f"
,
path
.
Join
(
*
testdataDir
,
"storage-provisioner"
,
"pod.yaml"
)))
if
err
!=
nil
{
t
.
Fatalf
(
"kubectl delete pod.yaml failed: args %q: %v"
,
rr
.
Command
(),
err
)
}
// recreate the pod
createPVTestPod
(
t
,
ctx
,
profile
)
// make sure the file we previously wrote to the persistent volume is still there
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"--context"
,
profile
,
"exec"
,
podName
,
"--"
,
"ls"
,
"/tmp/mount"
))
if
err
!=
nil
{
t
.
Fatalf
(
"creating file in pv: args %q: %v"
,
rr
.
Command
(),
err
)
}
if
!
strings
.
Contains
(
rr
.
Output
(),
"foo"
)
{
t
.
Fatalf
(
"expected file foo to persist in pvc, instead got [%v] as files in pv"
,
rr
.
Output
())
}
}
func
createPVTestPod
(
t
*
testing
.
T
,
ctx
context
.
Context
,
profile
string
)
{
// Deploy a pod that will mount the PV
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"--context"
,
profile
,
"apply"
,
"-f"
,
path
.
Join
(
*
testdataDir
,
"storage-provisioner"
,
"pod.yaml"
)))
if
err
!=
nil
{
t
.
Fatalf
(
"kubectl apply pvc.yaml failed: args %q: %v"
,
rr
.
Command
(),
err
)
}
// wait for pod to be running
if
_
,
err
:=
PodWait
(
ctx
,
t
,
profile
,
"default"
,
"test=storage-provisioner"
,
Minutes
(
1
));
err
!=
nil
{
t
.
Fatalf
(
"failed waiting for pod: %v"
,
err
)
}
}
test/integration/testdata/storage-provisioner/pod.yaml
0 → 100644
浏览文件 @
ae7fbaf8
apiVersion
:
v1
kind
:
Pod
metadata
:
name
:
sp-pod
labels
:
test
:
storage-provisioner
spec
:
containers
:
-
name
:
myfrontend
image
:
nginx
volumeMounts
:
-
mountPath
:
"
/tmp/mount"
name
:
mypd
volumes
:
-
name
:
mypd
persistentVolumeClaim
:
claimName
:
myclaim
test/integration/testdata/pvc.yaml
→
test/integration/testdata/
storage-provisioner/
pvc.yaml
浏览文件 @
ae7fbaf8
kind
:
PersistentVolumeClaim
apiVersion
:
v1
kind
:
PersistentVolumeClaim
metadata
:
name
:
testpvc
name
:
myclaim
spec
:
accessModes
:
-
ReadWriteOnce
volumeMode
:
Filesystem
resources
:
requests
:
storage
:
500Mi
\ No newline at end of file
storage
:
500Mi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录