Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
56d11a90
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 搜索 >>
未验证
提交
56d11a90
编写于
5月 26, 2020
作者:
M
Medya Gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
7ab632a0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
49 deletion
+24
-49
test/integration/fn_mount_cmd.go
test/integration/fn_mount_cmd.go
+3
-15
test/integration/functional_test.go
test/integration/functional_test.go
+5
-14
test/integration/helpers.go
test/integration/helpers.go
+16
-20
未找到文件。
test/integration/fn_mount_cmd.go
浏览文件 @
56d11a90
...
...
@@ -70,11 +70,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol
args
:=
[]
string
{
"mount"
,
"-p"
,
profile
,
fmt
.
Sprintf
(
"%s:%s"
,
tempDir
,
guestMount
),
"--alsologtostderr"
,
"-v=1"
}
var
ss
*
StartSession
if
runtime
.
GOOS
==
"windows"
{
ss
,
err
=
Start
(
t
,
exec
.
CommandContext
(
mctx
,
Target
(),
args
...
),
true
)
}
else
{
ss
,
err
=
Start
(
t
,
exec
.
CommandContext
(
mctx
,
Target
(),
args
...
))
}
ss
,
err
=
Start
(
t
,
exec
.
CommandContext
(
mctx
,
Target
(),
args
...
))
if
err
!=
nil
{
t
.
Fatalf
(
"%v failed: %v"
,
args
,
err
)
}
...
...
@@ -84,11 +80,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol
var
err
error
if
t
.
Failed
()
{
t
.
Logf
(
"%q failed, getting debug info..."
,
t
.
Name
())
if
runtime
.
GOOS
==
"windows"
{
rr
,
err
=
Run
(
t
,
exec
.
Command
(
Target
(),
"-p"
,
profile
,
"ssh"
,
"mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates"
),
true
)
}
else
{
rr
,
err
=
Run
(
t
,
exec
.
Command
(
Target
(),
"-p"
,
profile
,
"ssh"
,
"mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates"
))
}
rr
,
err
=
Run
(
t
,
exec
.
Command
(
Target
(),
"-p"
,
profile
,
"ssh"
,
"mount | grep 9p; ls -la /mount-9p; cat /mount-9p/pod-dates"
))
if
err
!=
nil
{
t
.
Logf
(
"debugging command %q failed : %v"
,
rr
.
Command
(),
err
)
}
else
{
...
...
@@ -97,11 +89,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { //nol
}
// Cleanup in advance of future tests
if
runtime
.
GOOS
==
"windows"
{
rr
,
err
=
Run
(
t
,
exec
.
Command
(
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo umount -f /mount-9p"
),
true
)
}
else
{
rr
,
err
=
Run
(
t
,
exec
.
Command
(
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo umount -f /mount-9p"
))
}
rr
,
err
=
Run
(
t
,
exec
.
Command
(
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo umount -f /mount-9p"
))
if
err
!=
nil
{
t
.
Logf
(
"%q: %v"
,
rr
.
Command
(),
err
)
}
...
...
test/integration/functional_test.go
浏览文件 @
56d11a90
...
...
@@ -161,7 +161,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) {
var
err
error
if
runtime
.
GOOS
==
"windows"
{
// golang exec powershell needs some tricks !
c
:=
exec
.
CommandContext
(
mctx
,
Target
(),
"-p "
+
profile
+
" docker-env | Invoke-Expression ;"
+
Target
()
+
" status -p "
+
profile
)
rr
,
err
=
Run
(
t
,
c
,
true
)
// golang exec powershell needs some tricks !
rr
,
err
=
Run
(
t
,
c
)
// golang exec powershell needs some tricks !
}
else
{
c
:=
exec
.
CommandContext
(
mctx
,
"/bin/bash"
,
"-c"
,
"eval $("
+
Target
()
+
" -p "
+
profile
+
" docker-env) && "
+
Target
()
+
" status -p "
+
profile
)
// we should be able to get minikube status with a bash which evaled docker-env
...
...
@@ -182,7 +182,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) {
// do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube
if
runtime
.
GOOS
==
"windows"
{
// testing docker-env eval in powershell
c
:=
exec
.
CommandContext
(
mctx
,
Target
(),
"-p "
+
profile
+
" docker-env | Invoke-Expression ; docker images"
)
rr
,
err
=
Run
(
t
,
c
,
true
)
// golang exec powershell needs some tricks !
rr
,
err
=
Run
(
t
,
c
)
// golang exec powershell needs some tricks !
}
else
{
c
:=
exec
.
CommandContext
(
mctx
,
"/bin/bash"
,
"-c"
,
"eval $("
+
Target
()
+
" -p "
+
profile
+
" docker-env) && docker images"
)
rr
,
err
=
Run
(
t
,
c
)
...
...
@@ -520,12 +520,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
var
rr
*
RunResult
var
err
error
if
runtime
.
GOOS
==
"windows"
{
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo crictl images"
),
true
)
}
else
{
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo"
,
"crictl"
,
"images"
))
}
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo"
,
"crictl"
,
"images"
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to get images by %q ssh %v"
,
rr
.
Command
(),
err
)
}
...
...
@@ -544,11 +539,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
// deleting image inside minikube node manually
var
rr
*
RunResult
var
err
error
if
runtime
.
GOOS
==
"windows"
{
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo docker rmi "
+
img
),
true
)
// for some reason crictl rmi doesn't work
}
else
{
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo"
,
"docker"
,
"rmi"
,
img
))
}
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo"
,
"docker"
,
"rmi"
,
img
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to delete inside the node %q : %v"
,
rr
.
Command
(),
err
)
...
...
@@ -864,7 +855,7 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) {
if
runtime
.
GOOS
==
"windows"
{
// golang exec powershell needs some tricks !
cmd
:=
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"
\"
cat /etc/hostname
\"
"
)
t
.
Logf
(
"about to run %s: "
,
cmd
.
Args
)
rr
,
err
=
Run
(
t
,
cmd
,
true
)
rr
,
err
=
Run
(
t
,
cmd
)
t
.
Logf
(
"rr is %+v:
\n
"
,
rr
)
t
.
Logf
(
"err is %v:
\n
"
,
err
)
}
else
{
...
...
test/integration/helpers.go
浏览文件 @
56d11a90
...
...
@@ -29,11 +29,13 @@ import (
"fmt"
"io/ioutil"
"os/exec"
"runtime"
"strings"
"testing"
"time"
"github.com/docker/machine/libmachine/state"
"github.com/pkg/errors"
"github.com/shirou/gopsutil/process"
core
"k8s.io/api/core/v1"
meta
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -86,25 +88,22 @@ func (rr RunResult) Output() string {
}
// Run is a test helper to log a command being executed \_(ツ)_/¯
func
Run
(
t
*
testing
.
T
,
cmd
*
exec
.
Cmd
,
powershell
...
bool
)
(
*
RunResult
,
error
)
{
func
Run
(
t
*
testing
.
T
,
cmd
*
exec
.
Cmd
)
(
*
RunResult
,
error
)
{
t
.
Helper
()
isPowershell
:=
false
if
len
(
powershell
)
>
0
{
isPowershell
=
powershell
[
0
]
}
newCmd
:=
c
md
if
isPowershell
{
var
newCmd
*
exec
.
C
md
if
runtime
.
GOOS
==
"windows"
{
psBin
,
err
:=
exec
.
LookPath
(
"powershell.exe"
)
if
err
!=
nil
{
return
&
RunResult
{},
err
return
&
RunResult
{},
err
ors
.
Wrapf
(
err
,
"lookup powershell"
)
}
args
:=
append
([]
string
{
"-NoProfile"
,
"-NonInteractive"
},
cmd
.
Args
...
)
newCmd
=
exec
.
Command
(
psBin
,
args
...
)
}
else
{
newCmd
=
cmd
}
rr
:=
&
RunResult
{
Args
:
newC
md
.
Args
}
rr
:=
&
RunResult
{
Args
:
c
md
.
Args
}
t
.
Logf
(
"(dbg) Run: %v"
,
rr
.
Command
())
...
...
@@ -136,30 +135,27 @@ type StartSession struct {
}
// Start starts a process in the background, streaming output
func
Start
(
t
*
testing
.
T
,
cmd
*
exec
.
Cmd
,
powershell
...
bool
)
(
*
StartSession
,
error
)
{
func
Start
(
t
*
testing
.
T
,
cmd
*
exec
.
Cmd
)
(
*
StartSession
,
error
)
{
t
.
Helper
()
t
.
Logf
(
"(dbg) daemon: %v"
,
cmd
.
Args
)
isPowershell
:=
false
if
len
(
powershell
)
>
0
{
isPowershell
=
powershell
[
0
]
}
newCmd
:=
cmd
if
isPowershell
{
var
newCmd
*
exec
.
Cmd
if
runtime
.
GOOS
==
"windows"
{
psBin
,
err
:=
exec
.
LookPath
(
"powershell.exe"
)
if
err
!=
nil
{
return
nil
,
err
return
&
StartSession
{},
errors
.
Wrapf
(
err
,
"lookup powershell"
)
}
args
:=
append
([]
string
{
"-NoProfile"
,
"-NonInteractive"
},
cmd
.
Args
...
)
newCmd
=
exec
.
Command
(
psBin
,
args
...
)
}
else
{
newCmd
=
cmd
}
stdoutPipe
,
err
:=
newCmd
.
StdoutPipe
()
if
err
!=
nil
{
t
.
Fatalf
(
"stdout pipe failed: %v %v"
,
newCmd
.
Args
,
err
)
}
stderrPipe
,
err
:=
c
md
.
StderrPipe
()
stderrPipe
,
err
:=
newC
md
.
StderrPipe
()
if
err
!=
nil
{
t
.
Fatalf
(
"stderr pipe failed: %v %v"
,
newCmd
.
Args
,
err
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录