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
f150874e
Commit
f150874e
authored
Feb 26, 2019
by
Vy Ta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Requested changes and refactor
parent
2869c670
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
47 deletions
+35
-47
hybrid_network.go
test/e2e/windows/hybrid_network.go
+35
-47
No files found.
test/e2e/windows/hybrid_network.go
View file @
f150874e
...
@@ -30,9 +30,8 @@ import (
...
@@ -30,9 +30,8 @@ import (
)
)
const
(
const
(
LinuxOS
=
"linux"
linuxOS
=
"linux"
WindowsOS
=
"windows"
windowsOS
=
"windows"
Iterations
=
5
)
)
var
(
var
(
...
@@ -49,66 +48,55 @@ var _ = SIGDescribe("Hybrid cluster network", func() {
...
@@ -49,66 +48,55 @@ var _ = SIGDescribe("Hybrid cluster network", func() {
Context
(
"for all supported CNIs"
,
func
()
{
Context
(
"for all supported CNIs"
,
func
()
{
It
(
"should have stable networking for
linux and w
indows pods"
,
func
()
{
It
(
"should have stable networking for
Linux and W
indows pods"
,
func
()
{
By
(
"creating linux and windows pods"
)
By
(
"creating linux and windows pods"
)
linuxPod
:=
CreateTestPod
(
f
,
linuxBusyBoxImage
,
L
inuxOS
)
linuxPod
:=
createTestPod
(
f
,
linuxBusyBoxImage
,
l
inuxOS
)
windowsPod
:=
CreateTestPod
(
f
,
windowsBusyBoximage
,
W
indowsOS
)
windowsPod
:=
createTestPod
(
f
,
windowsBusyBoximage
,
w
indowsOS
)
By
(
"checking connectivity to 8.8.8.8 53 (google.com) from
l
inux"
)
By
(
"checking connectivity to 8.8.8.8 53 (google.com) from
L
inux"
)
CheckLinuxConnectivity
(
f
,
linuxPod
.
ObjectMeta
.
Name
,
"8.8.8.8"
,
"53"
)
assertConsistentConnectivity
(
f
,
linuxPod
.
ObjectMeta
.
Name
,
linuxOS
,
linuxCheck
(
"8.8.8.8"
,
53
)
)
By
(
"checkin
connectivity to www.google.com from w
indows"
)
By
(
"checkin
g connectivity to www.google.com from W
indows"
)
CheckWindowsConnectivity
(
f
,
windowsPod
.
ObjectMeta
.
Name
,
"www.google.com"
)
assertConsistentConnectivity
(
f
,
windowsPod
.
ObjectMeta
.
Name
,
windowsOS
,
windowsCheck
(
"www.google.com"
)
)
By
(
"checking connectivity from
linux to w
indows"
)
By
(
"checking connectivity from
Linux to W
indows"
)
CheckLinuxConnectivity
(
f
,
linuxPod
.
ObjectMeta
.
Name
,
windowsPod
.
Status
.
PodIP
,
"80"
)
assertConsistentConnectivity
(
f
,
linuxPod
.
ObjectMeta
.
Name
,
linuxOS
,
linuxCheck
(
windowsPod
.
Status
.
PodIP
,
80
)
)
By
(
"checking connectivity from
windows to l
inux"
)
By
(
"checking connectivity from
Windows to L
inux"
)
CheckWindowsConnectivity
(
f
,
windowsPod
.
ObjectMeta
.
Name
,
linuxPod
.
Status
.
PodIP
)
assertConsistentConnectivity
(
f
,
windowsPod
.
ObjectMeta
.
Name
,
windowsOS
,
windowsCheck
(
linuxPod
.
Status
.
PodIP
)
)
})
})
})
})
})
})
func
CheckContainerOutput
(
f
*
framework
.
Framework
,
podName
string
,
os
string
,
cmd
[]
string
)
(
string
,
string
,
error
)
{
var
(
By
(
fmt
.
Sprintf
(
"checking connectivity of %s-container in %s"
,
os
,
podName
))
duration
=
"10s"
out
,
stderr
,
err
:=
f
.
ExecCommandInContainerWithFullOutput
(
podName
,
os
+
"-container"
,
cmd
...
)
poll_interval
=
"1s"
msg
:=
fmt
.
Sprintf
(
"cmd: %v, stdout: %q, stderr: %q"
,
cmd
,
out
,
stderr
)
timeout
=
10
// seconds
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
msg
)
)
return
out
,
msg
,
err
func
assertConsistentConnectivity
(
f
*
framework
.
Framework
,
podName
string
,
os
string
,
cmd
[]
string
)
{
Consistently
(
func
()
error
{
By
(
fmt
.
Sprintf
(
"checking connectivity of %s-container in %s"
,
os
,
podName
))
_
,
_
,
err
:=
f
.
ExecCommandInContainerWithFullOutput
(
podName
,
os
+
"-container"
,
cmd
...
)
return
err
},
duration
,
poll_interval
)
.
ShouldNot
(
HaveOccurred
())
}
}
func
CheckLinuxConnectivity
(
f
*
framework
.
Framework
,
podName
string
,
address
string
,
port
string
)
{
func
linuxCheck
(
address
string
,
port
int
)
[]
string
{
successes
:=
0
nc
:=
fmt
.
Sprintf
(
"nc -vz %s %v -w %v"
,
address
,
port
,
timeout
)
for
i
:=
0
;
i
<
Iterations
;
i
++
{
cmd
:=
[]
string
{
"/bin/sh"
,
"-c"
,
nc
}
nc
:=
fmt
.
Sprintf
(
"nc -vz %s %s"
,
address
,
port
)
return
cmd
cmd
:=
[]
string
{
"/bin/sh"
,
"-c"
,
nc
}
_
,
_
,
err
:=
CheckContainerOutput
(
f
,
podName
,
LinuxOS
,
cmd
)
if
err
!=
nil
{
break
}
successes
++
}
Expect
(
successes
)
.
To
(
Equal
(
Iterations
))
}
}
func
CheckWindowsConnectivity
(
f
*
framework
.
Framework
,
podName
string
,
address
string
)
{
func
windowsCheck
(
address
string
)
[]
string
{
successes
:=
0
curl
:=
fmt
.
Sprintf
(
"curl.exe %s --connect-timeout %v --fail"
,
address
,
timeout
)
for
i
:=
0
;
i
<
Iterations
;
i
++
{
cmd
:=
[]
string
{
"cmd"
,
"/c"
,
curl
}
ps
:=
fmt
.
Sprintf
(
"$r=invoke-webrequest %s -usebasicparsing; echo $r.StatusCode"
,
address
)
return
cmd
cmd
:=
[]
string
{
"powershell"
,
"-command"
,
ps
}
out
,
msg
,
err
:=
CheckContainerOutput
(
f
,
podName
,
WindowsOS
,
cmd
)
if
err
!=
nil
||
out
!=
"200"
{
framework
.
Logf
(
msg
)
break
}
successes
++
}
Expect
(
successes
)
.
To
(
Equal
(
Iterations
))
}
}
func
C
reateTestPod
(
f
*
framework
.
Framework
,
image
string
,
os
string
)
*
v1
.
Pod
{
func
c
reateTestPod
(
f
*
framework
.
Framework
,
image
string
,
os
string
)
*
v1
.
Pod
{
containerName
:=
fmt
.
Sprintf
(
"%s-container"
,
os
)
containerName
:=
fmt
.
Sprintf
(
"%s-container"
,
os
)
podName
:=
"pod-"
+
string
(
uuid
.
NewUUID
())
podName
:=
"pod-"
+
string
(
uuid
.
NewUUID
())
pod
:=
&
v1
.
Pod
{
pod
:=
&
v1
.
Pod
{
...
@@ -132,7 +120,7 @@ func CreateTestPod(f *framework.Framework, image string, os string) *v1.Pod {
...
@@ -132,7 +120,7 @@ func CreateTestPod(f *framework.Framework, image string, os string) *v1.Pod {
},
},
},
},
}
}
if
os
==
L
inuxOS
{
if
os
==
l
inuxOS
{
pod
.
Spec
.
Tolerations
=
[]
v1
.
Toleration
{
pod
.
Spec
.
Tolerations
=
[]
v1
.
Toleration
{
{
{
Key
:
"key"
,
Key
:
"key"
,
...
...
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