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
7d0ba5b5
Commit
7d0ba5b5
authored
Apr 23, 2015
by
Quinton Hoole
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6553 from jayunit100/networking-ns
E2E: Add a --namespace hint which tests can choose to honor, and implement...
parents
2532fe56
4b43a6a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
29 deletions
+34
-29
networking.go
test/e2e/networking.go
+17
-29
util.go
test/e2e/util.go
+17
-0
No files found.
test/e2e/networking.go
View file @
7d0ba5b5
...
...
@@ -23,6 +23,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
//"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
//"github.com/GoogleCloudPlatform/kubernetes/pkg/clientauth"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
...
...
@@ -77,7 +79,7 @@ func LaunchNetTestPodPerNode(nodes *api.NodeList, name string, c *client.Client,
var
_
=
Describe
(
"Networking"
,
func
()
{
//This namespace is modified throughout the course of the test.
var
namespace
Obj
*
api
.
Namespace
var
namespace
*
api
.
Namespace
var
svcname
=
"nettest"
var
c
*
client
.
Client
=
nil
...
...
@@ -94,30 +96,19 @@ var _ = Describe("Networking", func() {
Failf
(
"Unexpected error code, expected 200, got, %v (%v)"
,
resp
.
StatusCode
,
resp
)
}
By
(
"Building a namespace api object"
)
var
ns
=
svcname
+
"-"
+
randomSuffix
()
namespaceObj
=
&
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
ns
,
Namespace
:
""
,
},
Status
:
api
.
NamespaceStatus
{},
}
By
(
"Creating a kubernetes client"
)
c
,
err
=
loadClient
()
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"
Creating a namespace for this test suite
"
)
_
,
err
=
c
.
Namespaces
()
.
Create
(
namespaceObj
)
By
(
"
Building a namespace api object
"
)
namespace
,
err
=
createTestingNS
(
"nettest"
,
c
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
AfterEach
(
func
()
{
By
(
"Destroying namespace for this suite"
)
if
err
:=
c
.
Namespaces
()
.
Delete
(
namespace
Obj
.
Name
);
err
!=
nil
{
By
(
fmt
.
Sprintf
(
"Destroying namespace for this suite %v"
,
namespace
.
Name
)
)
if
err
:=
c
.
Namespaces
()
.
Delete
(
namespace
.
Name
);
err
!=
nil
{
Failf
(
"Couldn't delete ns %s"
,
err
)
}
})
...
...
@@ -134,7 +125,7 @@ var _ = Describe("Networking", func() {
for
_
,
test
:=
range
tests
{
By
(
fmt
.
Sprintf
(
"testing: %s"
,
test
.
path
))
data
,
err
:=
c
.
RESTClient
.
Get
()
.
Namespace
(
api
.
NamespaceDefault
)
.
Namespace
(
namespace
.
Name
)
.
AbsPath
(
test
.
path
)
.
DoRaw
()
if
err
!=
nil
{
...
...
@@ -143,9 +134,6 @@ var _ = Describe("Networking", func() {
}
})
// Create a unique namespace for this test.
ns
:=
"nettest-"
+
randomSuffix
()
//Now we can proceed with the test.
It
(
"should function for intra-pod communication"
,
func
()
{
...
...
@@ -154,8 +142,8 @@ var _ = Describe("Networking", func() {
return
}
By
(
fmt
.
Sprintf
(
"Creating a service named [%s] in namespace %s"
,
svcname
,
n
s
))
svc
,
err
:=
c
.
Services
(
n
s
)
.
Create
(
&
api
.
Service
{
By
(
fmt
.
Sprintf
(
"Creating a service named [%s] in namespace %s"
,
svcname
,
n
amespace
.
Name
))
svc
,
err
:=
c
.
Services
(
n
amespace
.
Name
)
.
Create
(
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
svcname
,
Labels
:
map
[
string
]
string
{
...
...
@@ -181,7 +169,7 @@ var _ = Describe("Networking", func() {
defer
func
()
{
defer
GinkgoRecover
()
By
(
"Cleaning up the service"
)
if
err
=
c
.
Services
(
n
s
)
.
Delete
(
svc
.
Name
);
err
!=
nil
{
if
err
=
c
.
Services
(
n
amespace
.
Name
)
.
Delete
(
svc
.
Name
);
err
!=
nil
{
Failf
(
"unable to delete svc %v: %v"
,
svc
.
Name
,
err
)
}
}()
...
...
@@ -193,14 +181,14 @@ var _ = Describe("Networking", func() {
Failf
(
"Failed to list nodes: %v"
,
err
)
}
podNames
:=
LaunchNetTestPodPerNode
(
nodes
,
svcname
,
c
,
n
s
)
podNames
:=
LaunchNetTestPodPerNode
(
nodes
,
svcname
,
c
,
n
amespace
.
Name
)
// Clean up the pods
defer
func
()
{
defer
GinkgoRecover
()
By
(
"Cleaning up the webserver pods"
)
for
_
,
podName
:=
range
podNames
{
if
err
=
c
.
Pods
(
n
s
)
.
Delete
(
podName
);
err
!=
nil
{
if
err
=
c
.
Pods
(
n
amespace
.
Name
)
.
Delete
(
podName
);
err
!=
nil
{
Logf
(
"Failed to delete pod %s: %v"
,
podName
,
err
)
}
}
...
...
@@ -208,7 +196,7 @@ var _ = Describe("Networking", func() {
By
(
"Waiting for the webserver pods to transition to Running state"
)
for
_
,
podName
:=
range
podNames
{
err
=
waitForPodRunningInNamespace
(
c
,
podName
,
n
s
)
err
=
waitForPodRunningInNamespace
(
c
,
podName
,
n
amespace
.
Name
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
...
...
@@ -224,7 +212,7 @@ var _ = Describe("Networking", func() {
Logf
(
"About to make a proxy status call"
)
start
:=
time
.
Now
()
body
,
err
=
c
.
Get
()
.
Namespace
(
n
s
)
.
Namespace
(
n
amespace
.
Name
)
.
Prefix
(
"proxy"
)
.
Resource
(
"services"
)
.
Name
(
svc
.
Name
)
.
...
...
@@ -246,7 +234,7 @@ var _ = Describe("Networking", func() {
break
case
"fail"
:
if
body
,
err
=
c
.
Get
()
.
Namespace
(
n
s
)
.
Prefix
(
"proxy"
)
.
Namespace
(
n
amespace
.
Name
)
.
Prefix
(
"proxy"
)
.
Resource
(
"services"
)
.
Name
(
svc
.
Name
)
.
Suffix
(
"read"
)
.
DoRaw
();
err
!=
nil
{
...
...
@@ -260,7 +248,7 @@ var _ = Describe("Networking", func() {
if
!
passed
{
if
body
,
err
=
c
.
Get
()
.
Namespace
(
n
s
)
.
Namespace
(
n
amespace
.
Name
)
.
Prefix
(
"proxy"
)
.
Resource
(
"services"
)
.
Name
(
svc
.
Name
)
.
...
...
test/e2e/util.go
View file @
7d0ba5b5
...
...
@@ -33,6 +33,8 @@ import (
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
"code.google.com/p/go-uuid/uuid"
)
const
(
...
...
@@ -93,6 +95,19 @@ func waitForPodCondition(c *client.Client, ns, podName, desc string, condition p
return
fmt
.
Errorf
(
"gave up waiting for pod %s to be %s after %.2f seconds"
,
podName
,
desc
,
podStartTimeout
.
Seconds
())
}
// createNS should be used by every test, note that we append a common prefix to the provided test name.
func
createTestingNS
(
baseName
string
,
c
*
client
.
Client
)
(
*
api
.
Namespace
,
error
)
{
namespaceObj
:=
&
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
fmt
.
Sprintf
(
"e2e-tests-%v-%v"
,
baseName
,
uuid
.
New
()),
Namespace
:
""
,
},
Status
:
api
.
NamespaceStatus
{},
}
_
,
err
:=
c
.
Namespaces
()
.
Create
(
namespaceObj
)
return
namespaceObj
,
err
}
func
waitForPodRunningInNamespace
(
c
*
client
.
Client
,
podName
string
,
namespace
string
)
error
{
return
waitForPodCondition
(
c
,
namespace
,
podName
,
"running"
,
func
(
pod
*
api
.
Pod
)
(
bool
,
error
)
{
return
(
pod
.
Status
.
Phase
==
api
.
PodRunning
),
nil
...
...
@@ -191,6 +206,7 @@ func loadClient() (*client.Client, error) {
return
c
,
nil
}
// randomSuffix provides a random string to append to pods,services,rcs.
// TODO: Allow service names to have the same form as names
// for pods and replication controllers so we don't
// need to use such a function and can instead
...
...
@@ -282,6 +298,7 @@ func validateController(c *client.Client, containerImage string, replicas int, c
}
// kubectlCmd runs the kubectl executable.
// kubectlCmd runs the kubectl executable.
func
kubectlCmd
(
args
...
string
)
*
exec
.
Cmd
{
defaultArgs
:=
[]
string
{}
...
...
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