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
3bdde89a
Commit
3bdde89a
authored
Jun 02, 2015
by
Brian Grant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Make services e2e test more debuggable"
parent
907b83cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
47 deletions
+42
-47
services.sh
hack/e2e-suite/services.sh
+42
-47
No files found.
hack/e2e-suite/services.sh
View file @
3bdde89a
...
@@ -22,13 +22,11 @@ set -o pipefail
...
@@ -22,13 +22,11 @@ set -o pipefail
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../..
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../..
:
${
NAMESPACE
:
=
"services-test-
${
RANDOM
}
"
}
:
${
KUBE_VERSION_ROOT
:
=
${
KUBE_ROOT
}}
:
${
KUBE_VERSION_ROOT
:
=
${
KUBE_ROOT
}}
:
${
RAW_KUBECTL
:
=
"
${
KUBE_VERSION_ROOT
}
/cluster/kubectl.sh"
}
:
${
KUBECTL
:
=
"
${
KUBE_VERSION_ROOT
}
/cluster/kubectl.sh"
}
:
${
KUBECTL
:
=
"
${
RAW_KUBECTL
}
--namespace=
${
NAMESPACE
}
"
}
:
${
KUBE_CONFIG_FILE
:
=
"config-test.sh"
}
:
${
KUBE_CONFIG_FILE
:
=
"config-test.sh"
}
export
NAMESPACE RAW_KUBECTL
KUBECTL KUBE_CONFIG_FILE
export
KUBECTL KUBE_CONFIG_FILE
source
"
${
KUBE_ROOT
}
/cluster/kube-env.sh"
source
"
${
KUBE_ROOT
}
/cluster/kube-env.sh"
source
"
${
KUBE_VERSION_ROOT
}
/cluster/
${
KUBERNETES_PROVIDER
}
/util.sh"
source
"
${
KUBE_VERSION_ROOT
}
/cluster/
${
KUBERNETES_PROVIDER
}
/util.sh"
...
@@ -41,9 +39,7 @@ function error() {
...
@@ -41,9 +39,7 @@ function error() {
}
}
function
sort_args
()
{
function
sort_args
()
{
[
$#
==
0
]
&&
return
printf
"%s
\n
"
"
$@
"
|
sort
-n
|
tr
'\n\r'
' '
|
sed
's/ */ /g'
a
=(
$(
printf
"%s
\n
"
"
$@
"
|
sort
-n
)
)
echo
"
${
a
[*]
}
"
}
}
# Join args $2... with $1 between them.
# Join args $2... with $1 between them.
...
@@ -62,20 +58,10 @@ function join() {
...
@@ -62,20 +58,10 @@ function join() {
svcs_to_clean
=()
svcs_to_clean
=()
function
do_teardown
()
{
function
do_teardown
()
{
${
RAW_KUBECTL
}
delete namespace
"
${
NAMESPACE
}
"
local
svc
}
for
svc
in
"
${
svcs_to_clean
[@]
:+
${
svcs_to_clean
[@]
}}
"
;
do
stop_service
"
${
svc
}
"
function
make_namespace
()
{
done
echo
"Making namespace '
${
NAMESPACE
}
'"
${
RAW_KUBECTL
}
create
-f
-
<<
__EOF__
{
"kind": "Namespace",
"apiVersion": "v1beta3",
"metadata": {
"name": "
${
NAMESPACE
}
"
}
}
__EOF__
}
}
# Args:
# Args:
...
@@ -84,7 +70,7 @@ __EOF__
...
@@ -84,7 +70,7 @@ __EOF__
# $3: service replica count
# $3: service replica count
# $4: public IPs (optional, string e.g. "1.2.3.4 5.6.7.8")
# $4: public IPs (optional, string e.g. "1.2.3.4 5.6.7.8")
function
start_service
()
{
function
start_service
()
{
echo
"Starting service '
$
{
NAMESPACE
}
/
$
1
' on port
$2
with
$3
replicas"
echo
"Starting service '
$1
' on port
$2
with
$3
replicas"
svcs_to_clean+
=(
"
$1
"
)
svcs_to_clean+
=(
"
$1
"
)
${
KUBECTL
}
create
-f
-
<<
__EOF__
${
KUBECTL
}
create
-f
-
<<
__EOF__
{
{
...
@@ -92,7 +78,7 @@ function start_service() {
...
@@ -92,7 +78,7 @@ function start_service() {
"apiVersion": "v1beta3",
"apiVersion": "v1beta3",
"metadata": {
"metadata": {
"name": "
$1
",
"name": "
$1
",
"namespace": "
${
NAMESPACE
}
",
"namespace": "
default
",
"labels": {
"labels": {
"name": "
$1
"
"name": "
$1
"
}
}
...
@@ -138,7 +124,7 @@ __EOF__
...
@@ -138,7 +124,7 @@ __EOF__
"apiVersion": "v1beta3",
"apiVersion": "v1beta3",
"metadata": {
"metadata": {
"name": "
$1
",
"name": "
$1
",
"namespace": "
${
NAMESPACE
}
",
"namespace": "
default
",
"labels": {
"labels": {
"name": "
$1
"
"name": "
$1
"
}
}
...
@@ -232,28 +218,30 @@ function wait_for_pods() {
...
@@ -232,28 +218,30 @@ function wait_for_pods() {
# $2: service IP
# $2: service IP
# $3: service port
# $3: service port
# $4: pod count
# $4: pod count
# $5: pod IDs
(sorted)
# $5: pod IDs
function
wait_for_service_up
()
{
function
wait_for_service_up
()
{
local
i
local
i
local
found_pods
local
found_pods
echo
"waiting for
$1
at
$2
:
$3
"
for
i
in
$(
seq
1 20
)
;
do
for
i
in
$(
seq
1 5
)
;
do
results
=(
$(
ssh-to-node
"
${
test_node
}
"
"
results
=(
$(
ssh-to-node
"
${
test_node
}
"
"
set -e;
set -e;
for i in
$(
seq
-s
' '
1
$
((
$4
*
3
))
)
; do
for i in
$(
seq
-s
' '
1
$
4
)
; do
curl -s --connect-timeout 1 http://
$2
:
$3
;
curl -s --connect-timeout 1 http://
$2
:
$3
;
echo;
echo;
done | sort
-n
| uniq
done | sort | uniq
"
)
)
"
)
)
found_pods
=
$(
sort_args
"
${
results
[@]
:+
${
results
[@]
}}
"
)
found_pods
=
$(
sort_args
"
${
results
[@]
:+
${
results
[@]
}}
"
)
echo
"Checking if
${
found_pods
}
==
${
5
}
"
if
[[
"
${
found_pods
}
"
==
"
$5
"
]]
;
then
if
[[
"
${
found_pods
}
"
==
"
$5
"
]]
;
then
return
break
fi
fi
echo
"
expected '
$5
', got '
${
found_pods
}
': will try again
"
echo
"
Waiting for endpoints to propagate
"
sleep
3
# wait for endpoints to propagate
sleep
3
done
done
error
"
$1
: failed to verify portal from host"
if
[[
"
${
found_pods
}
"
!=
"
$5
"
]]
;
then
error
"Endpoints did not propagate in time"
fi
}
}
# Args:
# Args:
...
@@ -276,26 +264,35 @@ function wait_for_service_down() {
...
@@ -276,26 +264,35 @@ function wait_for_service_down() {
# $2: service IP
# $2: service IP
# $3: service port
# $3: service port
# $4: pod count
# $4: pod count
# $5: pod IDs
(sorted)
# $5: pod IDs
function
verify_from_container
()
{
function
verify_from_container
()
{
echo
"waiting for
$1
at
$2
:
$3
"
results
=(
$(
ssh-to-node
"
${
test_node
}
"
"
results
=(
$(
ssh-to-node
"
${
test_node
}
"
"
set -e;
set -e;
sudo docker pull busybox >/dev/null;
sudo docker pull busybox >/dev/null;
sudo docker run busybox sh -c '
sudo docker run busybox sh -c '
for i in
$(
seq
-s
' '
1
$((
$4
*
3
)))
; do
for i in
$(
seq
-s
' '
1
$4
)
; do
if wget -q -T 3 -O - http://
$2
:
$3
; then
ok=false
echo
for j in
$(
seq
-s
' '
1 10
)
; do
else
if wget -q -T 5 -O - http://
$2
:
$3
; then
echo
ok=true
break
fi
sleep 1
done
if [[
\$
{ok} == false ]]; then
exit 1
exit 1
fi
fi
done
done
'"
|
sort
-r
-n
|
uniq
)
)
\
'"
)
)
\
||
error
"testing
$1
VIP from container failed"
||
error
"testing
$1
VIP from container failed"
found_pods
=
$(
sort_args
"
${
results
[@]
}
"
)
found_pods
=
$(
sort_args
"
${
results
[@]
}
"
)
if
[[
"
${
found_pods
}
"
!=
"
$5
"
]]
;
then
if
[[
"
${
found_pods
}
"
!=
"
$5
"
]]
;
then
echo
"expected '
$5
', got '
${
found_pods
}
'"
error
-e
"
$1
VIP failed from container, expected:
\n
error
"
$1
: failed to verify VIP from container"
$(
printf
'\t%s\n'
$5
)
\n
got:
\n
$(
printf
'\t%s\n'
${
found_pods
})
"
fi
fi
}
}
...
@@ -306,17 +303,14 @@ detect-minions
...
@@ -306,17 +303,14 @@ detect-minions
test_node
=
"
${
MINION_NAMES
[0]
}
"
test_node
=
"
${
MINION_NAMES
[0]
}
"
master
=
"
${
MASTER_NAME
}
"
master
=
"
${
MASTER_NAME
}
"
# Make our namespace
make_namespace
# Launch some pods and services.
# Launch some pods and services.
svc1_name
=
"service
1
"
svc1_name
=
"service
-
${
RANDOM
}
"
svc1_port
=
80
svc1_port
=
80
svc1_count
=
3
svc1_count
=
3
svc1_publics
=
"192.168.1.1 192.168.1.2"
svc1_publics
=
"192.168.1.1 192.168.1.2"
start_service
"
${
svc1_name
}
"
"
${
svc1_port
}
"
"
${
svc1_count
}
"
"
${
svc1_publics
}
"
start_service
"
${
svc1_name
}
"
"
${
svc1_port
}
"
"
${
svc1_count
}
"
"
${
svc1_publics
}
"
svc2_name
=
"service
2
"
svc2_name
=
"service
-
${
RANDOM
}
"
svc2_port
=
80
svc2_port
=
80
svc2_count
=
3
svc2_count
=
3
start_service
"
${
svc2_name
}
"
"
${
svc2_port
}
"
"
${
svc2_count
}
"
start_service
"
${
svc2_name
}
"
"
${
svc2_port
}
"
"
${
svc2_count
}
"
...
@@ -420,6 +414,7 @@ echo "Manually removing iptables rules"
...
@@ -420,6 +414,7 @@ echo "Manually removing iptables rules"
# Remove both the new and old style chains, in case we're testing on an old kubelet
# Remove both the new and old style chains, in case we're testing on an old kubelet
ssh-to-node
"
${
test_node
}
"
"sudo iptables -t nat -F KUBE-PORTALS-HOST || true"
ssh-to-node
"
${
test_node
}
"
"sudo iptables -t nat -F KUBE-PORTALS-HOST || true"
ssh-to-node
"
${
test_node
}
"
"sudo iptables -t nat -F KUBE-PORTALS-CONTAINER || true"
ssh-to-node
"
${
test_node
}
"
"sudo iptables -t nat -F KUBE-PORTALS-CONTAINER || true"
ssh-to-node
"
${
test_node
}
"
"sudo iptables -t nat -F KUBE-PROXY || true"
echo
"Verifying the VIPs from the host"
echo
"Verifying the VIPs from the host"
wait_for_service_up
"
${
svc3_name
}
"
"
${
svc3_ip
}
"
"
${
svc3_port
}
"
\
wait_for_service_up
"
${
svc3_name
}
"
"
${
svc3_ip
}
"
"
${
svc3_port
}
"
\
"
${
svc3_count
}
"
"
${
svc3_pods
}
"
"
${
svc3_count
}
"
"
${
svc3_pods
}
"
...
...
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