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
48def74e
Unverified
Commit
48def74e
authored
Feb 27, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 27, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74550 from vyta/e2e-tests/hybrid-test
Add cross-OS test for service connectivity
parents
84dce4d1
a7a1f587
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
0 deletions
+133
-0
BUILD
test/e2e/windows/BUILD
+1
-0
hybrid_network.go
test/e2e/windows/hybrid_network.go
+132
-0
No files found.
test/e2e/windows/BUILD
View file @
48def74e
...
...
@@ -7,6 +7,7 @@ go_library(
srcs = [
"density.go",
"framework.go",
"hybrid_network.go",
"networking.go",
"volumes.go",
],
...
...
test/e2e/windows/hybrid_network.go
0 → 100644
View file @
48def74e
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
windows
import
(
"fmt"
v1
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/test/e2e/framework"
imageutils
"k8s.io/kubernetes/test/utils/image"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
)
const
(
linuxOS
=
"linux"
windowsOS
=
"windows"
)
var
(
windowsBusyBoximage
=
imageutils
.
GetE2EImage
(
imageutils
.
TestWebserver
)
linuxBusyBoxImage
=
"docker.io/library/nginx:1.15-alpine"
)
var
_
=
SIGDescribe
(
"Hybrid cluster network"
,
func
()
{
f
:=
framework
.
NewDefaultFramework
(
"hybrid-network"
)
BeforeEach
(
func
()
{
framework
.
SkipUnlessNodeOSDistroIs
(
"windows"
)
})
Context
(
"for all supported CNIs"
,
func
()
{
It
(
"should have stable networking for Linux and Windows pods"
,
func
()
{
By
(
"creating linux and windows pods"
)
linuxPod
:=
createTestPod
(
f
,
linuxBusyBoxImage
,
linuxOS
)
windowsPod
:=
createTestPod
(
f
,
windowsBusyBoximage
,
windowsOS
)
By
(
"checking connectivity to 8.8.8.8 53 (google.com) from Linux"
)
assertConsistentConnectivity
(
f
,
linuxPod
.
ObjectMeta
.
Name
,
linuxOS
,
linuxCheck
(
"8.8.8.8"
,
53
))
By
(
"checking connectivity to www.google.com from Windows"
)
assertConsistentConnectivity
(
f
,
windowsPod
.
ObjectMeta
.
Name
,
windowsOS
,
windowsCheck
(
"www.google.com"
))
By
(
"checking connectivity from Linux to Windows"
)
assertConsistentConnectivity
(
f
,
linuxPod
.
ObjectMeta
.
Name
,
linuxOS
,
linuxCheck
(
windowsPod
.
Status
.
PodIP
,
80
))
By
(
"checking connectivity from Windows to Linux"
)
assertConsistentConnectivity
(
f
,
windowsPod
.
ObjectMeta
.
Name
,
windowsOS
,
windowsCheck
(
linuxPod
.
Status
.
PodIP
))
})
})
})
var
(
duration
=
"10s"
pollInterval
=
"1s"
timeout
=
10
// seconds
)
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
,
pollInterval
)
.
ShouldNot
(
HaveOccurred
())
}
func
linuxCheck
(
address
string
,
port
int
)
[]
string
{
nc
:=
fmt
.
Sprintf
(
"nc -vz %s %v -w %v"
,
address
,
port
,
timeout
)
cmd
:=
[]
string
{
"/bin/sh"
,
"-c"
,
nc
}
return
cmd
}
func
windowsCheck
(
address
string
)
[]
string
{
curl
:=
fmt
.
Sprintf
(
"curl.exe %s --connect-timeout %v --fail"
,
address
,
timeout
)
cmd
:=
[]
string
{
"cmd"
,
"/c"
,
curl
}
return
cmd
}
func
createTestPod
(
f
*
framework
.
Framework
,
image
string
,
os
string
)
*
v1
.
Pod
{
containerName
:=
fmt
.
Sprintf
(
"%s-container"
,
os
)
podName
:=
"pod-"
+
string
(
uuid
.
NewUUID
())
pod
:=
&
v1
.
Pod
{
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"Pod"
,
APIVersion
:
"v1"
,
},
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
podName
,
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
containerName
,
Image
:
image
,
Ports
:
[]
v1
.
ContainerPort
{{
ContainerPort
:
80
}},
},
},
NodeSelector
:
map
[
string
]
string
{
"beta.kubernetes.io/os"
:
os
,
},
},
}
if
os
==
linuxOS
{
pod
.
Spec
.
Tolerations
=
[]
v1
.
Toleration
{
{
Operator
:
v1
.
TolerationOpExists
,
Effect
:
v1
.
TaintEffectNoSchedule
,
},
}
}
return
f
.
PodClient
()
.
CreateSync
(
pod
)
}
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