Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
8f55fb7d
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,发现更多精彩内容 >>
未验证
提交
8f55fb7d
编写于
12月 02, 2017
作者:
M
Matt Rickard
提交者:
GitHub
12月 02, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2254 from kairen/add-ingress-test
Add integration test for ingress addon
上级
3b997ad5
e93a2f42
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
147 addition
and
0 deletion
+147
-0
hack/jenkins/common.sh
hack/jenkins/common.sh
+2
-0
test/integration/addons_test.go
test/integration/addons_test.go
+41
-0
test/integration/functional_test.go
test/integration/functional_test.go
+1
-0
test/integration/testdata/nginx-ing.yaml
test/integration/testdata/nginx-ing.yaml
+15
-0
test/integration/testdata/nginx-pod-svc.yaml
test/integration/testdata/nginx-pod-svc.yaml
+31
-0
test/integration/util/util.go
test/integration/util/util.go
+57
-0
未找到文件。
hack/jenkins/common.sh
浏览文件 @
8f55fb7d
...
...
@@ -33,6 +33,8 @@ gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH} out/
gsutil
cp
gs://minikube-builds/
${
MINIKUBE_LOCATION
}
/testdata/busybox.yaml testdata/
gsutil
cp
gs://minikube-builds/
${
MINIKUBE_LOCATION
}
/testdata/pvc.yaml testdata/
gsutil
cp
gs://minikube-builds/
${
MINIKUBE_LOCATION
}
/testdata/busybox-mount-test.yaml testdata/
gsutil
cp
gs://minikube-builds/
${
MINIKUBE_LOCATION
}
/testdata/nginx-pod-svc.yaml testdata/
gsutil
cp
gs://minikube-builds/
${
MINIKUBE_LOCATION
}
/testdata/nginx-ing.yaml testdata/
export
MINIKUBE_WANTREPORTERRORPROMPT
=
False
sudo
./out/minikube-
${
OS_ARCH
}
delete
||
true
...
...
test/integration/addons_test.go
浏览文件 @
8f55fb7d
...
...
@@ -22,6 +22,7 @@ import (
"fmt"
"net"
"net/url"
"path/filepath"
"strings"
"testing"
"time"
...
...
@@ -68,6 +69,46 @@ func testDashboard(t *testing.T) {
}
}
func
testIngressController
(
t
*
testing
.
T
)
{
t
.
Parallel
()
minikubeRunner
:=
NewMinikubeRunner
(
t
)
kubectlRunner
:=
util
.
NewKubectlRunner
(
t
)
minikubeRunner
.
RunCommand
(
"addons enable ingress"
,
true
)
if
err
:=
util
.
WaitForIngressControllerRunning
(
t
);
err
!=
nil
{
t
.
Fatalf
(
"waiting for ingress-controller to be up: %s"
,
err
)
}
if
err
:=
util
.
WaitForIngressDefaultBackendRunning
(
t
);
err
!=
nil
{
t
.
Fatalf
(
"waiting for default-http-backend to be up: %s"
,
err
)
}
ingressPath
,
_
:=
filepath
.
Abs
(
"testdata/nginx-ing.yaml"
)
if
_
,
err
:=
kubectlRunner
.
RunCommand
([]
string
{
"create"
,
"-f"
,
ingressPath
});
err
!=
nil
{
t
.
Fatalf
(
"creating nginx ingress resource: %s"
,
err
)
}
podPath
,
_
:=
filepath
.
Abs
(
"testdata/nginx-pod-svc.yaml"
)
if
_
,
err
:=
kubectlRunner
.
RunCommand
([]
string
{
"create"
,
"-f"
,
podPath
});
err
!=
nil
{
t
.
Fatalf
(
"creating nginx ingress resource: %s"
,
err
)
}
if
err
:=
util
.
WaitForNginxRunning
(
t
);
err
!=
nil
{
t
.
Fatalf
(
"waiting for nginx to be up: %s"
,
err
)
}
expectedStr
:=
"Welcome to nginx!"
runCmd
:=
fmt
.
Sprintf
(
"curl http://127.0.0.1:80 -H 'Host: nginx.example.com'"
)
sshCmdOutput
,
_
:=
minikubeRunner
.
SSH
(
runCmd
)
if
!
strings
.
Contains
(
sshCmdOutput
,
expectedStr
)
{
t
.
Fatalf
(
"ExpectedStr sshCmdOutput to be: %s. Output was: %s"
,
expectedStr
,
sshCmdOutput
)
}
defer
kubectlRunner
.
RunCommand
([]
string
{
"delete"
,
"-f"
,
podPath
})
defer
kubectlRunner
.
RunCommand
([]
string
{
"delete"
,
"-f"
,
ingressPath
})
minikubeRunner
.
RunCommand
(
"addons disable ingress"
,
true
)
}
func
testServicesList
(
t
*
testing
.
T
)
{
t
.
Parallel
()
minikubeRunner
:=
NewMinikubeRunner
(
t
)
...
...
test/integration/functional_test.go
浏览文件 @
8f55fb7d
...
...
@@ -40,6 +40,7 @@ func TestFunctional(t *testing.T) {
if
!
strings
.
Contains
(
minikubeRunner
.
StartArgs
,
"--vm-driver=none"
)
{
t
.
Run
(
"EnvVars"
,
testClusterEnv
)
t
.
Run
(
"SSH"
,
testClusterSSH
)
t
.
Run
(
"IngressController"
,
testIngressController
)
// t.Run("Mounting", testMounting)
}
}
test/integration/testdata/nginx-ing.yaml
0 → 100644
浏览文件 @
8f55fb7d
apiVersion
:
extensions/v1beta1
kind
:
Ingress
metadata
:
name
:
nginx-ingress
labels
:
integration-test
:
ingress
spec
:
rules
:
-
host
:
nginx.example.com
http
:
paths
:
-
path
:
/
backend
:
serviceName
:
nginx
servicePort
:
80
test/integration/testdata/nginx-pod-svc.yaml
0 → 100644
浏览文件 @
8f55fb7d
apiVersion
:
v1
kind
:
Pod
metadata
:
labels
:
run
:
nginx
name
:
nginx
namespace
:
default
spec
:
containers
:
-
name
:
nginx
image
:
nginx:alpine
ports
:
-
containerPort
:
80
protocol
:
TCP
---
apiVersion
:
v1
kind
:
Service
metadata
:
labels
:
run
:
nginx
name
:
nginx
namespace
:
default
spec
:
ports
:
-
port
:
80
protocol
:
TCP
targetPort
:
80
selector
:
run
:
nginx
sessionAffinity
:
None
type
:
ClusterIP
test/integration/util/util.go
浏览文件 @
8f55fb7d
...
...
@@ -263,6 +263,63 @@ func WaitForDashboardRunning(t *testing.T) error {
return
nil
}
func
WaitForIngressControllerRunning
(
t
*
testing
.
T
)
error
{
client
,
err
:=
commonutil
.
GetClient
()
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"getting kubernetes client"
)
}
if
err
:=
commonutil
.
WaitForRCToStabilize
(
client
,
"kube-system"
,
"nginx-ingress-controller"
,
time
.
Minute
*
10
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"waiting for ingress-controller RC to stabilize"
)
}
selector
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"app"
:
"nginx-ingress-controller"
}))
if
err
:=
commonutil
.
WaitForPodsWithLabelRunning
(
client
,
"kube-system"
,
selector
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"waiting for ingress-controller pods"
)
}
return
nil
}
func
WaitForIngressDefaultBackendRunning
(
t
*
testing
.
T
)
error
{
client
,
err
:=
commonutil
.
GetClient
()
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"getting kubernetes client"
)
}
if
err
:=
commonutil
.
WaitForRCToStabilize
(
client
,
"kube-system"
,
"default-http-backend"
,
time
.
Minute
*
10
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"waiting for default-http-backend RC to stabilize"
)
}
if
err
:=
commonutil
.
WaitForService
(
client
,
"kube-system"
,
"default-http-backend"
,
true
,
time
.
Millisecond
*
500
,
time
.
Minute
*
10
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"waiting for default-http-backend service to be up"
)
}
if
err
:=
commonutil
.
WaitForServiceEndpointsNum
(
client
,
"kube-system"
,
"default-http-backend"
,
1
,
time
.
Second
*
3
,
time
.
Minute
*
10
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"waiting for one default-http-backend endpoint to be up"
)
}
return
nil
}
func
WaitForNginxRunning
(
t
*
testing
.
T
)
error
{
client
,
err
:=
commonutil
.
GetClient
()
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"getting kubernetes client"
)
}
selector
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"run"
:
"nginx"
}))
if
err
:=
commonutil
.
WaitForPodsWithLabelRunning
(
client
,
"default"
,
selector
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"waiting for nginx pods"
)
}
if
err
:=
commonutil
.
WaitForService
(
client
,
"default"
,
"nginx"
,
true
,
time
.
Millisecond
*
500
,
time
.
Minute
*
10
);
err
!=
nil
{
t
.
Errorf
(
"Error waiting for nginx service to be up"
)
}
return
nil
}
func
Retry
(
t
*
testing
.
T
,
callback
func
()
error
,
d
time
.
Duration
,
attempts
int
)
(
err
error
)
{
for
i
:=
0
;
i
<
attempts
;
i
++
{
err
=
callback
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录