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
b466b603
Commit
b466b603
authored
Apr 08, 2015
by
jayunit100
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a ephemeral namespace to networking.go, to be generalized shortly hereafter.
parent
31b7f75c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
13 deletions
+43
-13
networking.go
test/e2e/networking.go
+43
-13
No files found.
test/e2e/networking.go
View file @
b466b603
...
@@ -25,10 +25,18 @@ import (
...
@@ -25,10 +25,18 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
)
)
//Namespace constants, implemented
var
svcname
=
"nettest"
var
ns
=
svcname
+
"-"
+
randomSuffix
()
var
c
*
client
.
Client
=
nil
var
namespaceObj
*
api
.
Namespace
var
_
=
BeforeSuite
(
func
()
{
var
_
=
BeforeSuite
(
func
()
{
//Assert basic external connectivity.
//Assert basic external connectivity.
//Since this is not really a test of kubernetes in any way, we
//Since this is not really a test of kubernetes in any way, we
...
@@ -42,6 +50,33 @@ var _ = BeforeSuite(func() {
...
@@ -42,6 +50,33 @@ var _ = BeforeSuite(func() {
if
resp
.
StatusCode
!=
http
.
StatusOK
{
if
resp
.
StatusCode
!=
http
.
StatusOK
{
Failf
(
"Unexpected error code, expected 200, got, %v (%v)"
,
resp
.
StatusCode
,
resp
)
Failf
(
"Unexpected error code, expected 200, got, %v (%v)"
,
resp
.
StatusCode
,
resp
)
}
}
By
(
"Building a namespace api object"
)
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
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
var
_
=
AfterSuite
(
func
()
{
By
(
"Destroying namespace for this suite"
)
err
:=
c
.
Namespaces
()
.
Delete
(
namespaceObj
.
ObjectMeta
.
Name
)
if
err
!=
nil
&&
!
errors
.
IsAlreadyExists
(
err
)
{
Failf
(
"Couldng make ns %s"
,
err
)
}
})
})
func
LaunchNetTestPodPerNode
(
nodes
*
api
.
NodeList
,
name
string
,
c
*
client
.
Client
,
ns
string
)
[]
string
{
func
LaunchNetTestPodPerNode
(
nodes
*
api
.
NodeList
,
name
string
,
c
*
client
.
Client
,
ns
string
)
[]
string
{
...
@@ -86,13 +121,7 @@ func LaunchNetTestPodPerNode(nodes *api.NodeList, name string, c *client.Client,
...
@@ -86,13 +121,7 @@ func LaunchNetTestPodPerNode(nodes *api.NodeList, name string, c *client.Client,
}
}
var
_
=
Describe
(
"Networking"
,
func
()
{
var
_
=
Describe
(
"Networking"
,
func
()
{
var
c
*
client
.
Client
//var c *client.Client
BeforeEach
(
func
()
{
var
err
error
c
,
err
=
loadClient
()
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
// First test because it has no dependencies on variables created later on.
// First test because it has no dependencies on variables created later on.
It
(
"should provide unchanging, static URL paths for kubernetes api services."
,
func
()
{
It
(
"should provide unchanging, static URL paths for kubernetes api services."
,
func
()
{
...
@@ -117,20 +146,21 @@ var _ = Describe("Networking", func() {
...
@@ -117,20 +146,21 @@ var _ = Describe("Networking", func() {
// Create a unique namespace for this test.
// Create a unique namespace for this test.
ns
:=
"nettest-"
+
randomSuffix
()
ns
:=
"nettest-"
+
randomSuffix
()
name
:=
"nettest"
//Now we can proceed with the test.
It
(
"should function for intra-pod communication"
,
func
()
{
It
(
"should function for intra-pod communication"
,
func
()
{
if
testContext
.
Provider
==
"vagrant"
{
if
testContext
.
Provider
==
"vagrant"
{
By
(
"Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)"
)
By
(
"Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)"
)
return
return
}
}
By
(
fmt
.
Sprintf
(
"Creating a service named [%s] in namespace %s"
,
name
,
ns
))
By
(
fmt
.
Sprintf
(
"Creating a service named [%s] in namespace %s"
,
svc
name
,
ns
))
svc
,
err
:=
c
.
Services
(
ns
)
.
Create
(
&
api
.
Service
{
svc
,
err
:=
c
.
Services
(
ns
)
.
Create
(
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Name
:
svc
name
,
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"name"
:
name
,
"name"
:
svc
name
,
},
},
},
},
Spec
:
api
.
ServiceSpec
{
Spec
:
api
.
ServiceSpec
{
...
@@ -140,7 +170,7 @@ var _ = Describe("Networking", func() {
...
@@ -140,7 +170,7 @@ var _ = Describe("Networking", func() {
TargetPort
:
util
.
NewIntOrStringFromInt
(
8080
),
TargetPort
:
util
.
NewIntOrStringFromInt
(
8080
),
}},
}},
Selector
:
map
[
string
]
string
{
Selector
:
map
[
string
]
string
{
"name"
:
name
,
"name"
:
svc
name
,
},
},
},
},
})
})
...
@@ -164,7 +194,7 @@ var _ = Describe("Networking", func() {
...
@@ -164,7 +194,7 @@ var _ = Describe("Networking", func() {
Failf
(
"Failed to list nodes: %v"
,
err
)
Failf
(
"Failed to list nodes: %v"
,
err
)
}
}
podNames
:=
LaunchNetTestPodPerNode
(
nodes
,
name
,
c
,
ns
)
podNames
:=
LaunchNetTestPodPerNode
(
nodes
,
svc
name
,
c
,
ns
)
// Clean up the pods
// Clean up the pods
defer
func
()
{
defer
func
()
{
...
...
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