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
f988a01a
Commit
f988a01a
authored
Jan 23, 2015
by
Filipe Brandenburger
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3780 from satnam6502/network
Change TestNetwork to allow parallel execution
parents
9dfbf46b
2d1ee816
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
9 deletions
+62
-9
network.go
test/e2e/network.go
+51
-9
util.go
test/e2e/util.go
+11
-0
No files found.
test/e2e/network.go
View file @
f988a01a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -31,11 +32,27 @@ func TestNetwork(c *client.Client) bool {
...
@@ -31,11 +32,27 @@ func TestNetwork(c *client.Client) bool {
}
}
ns
:=
api
.
NamespaceDefault
ns
:=
api
.
NamespaceDefault
svc
,
err
:=
c
.
Services
(
ns
)
.
Create
(
loadObjectOrDie
(
assetPath
(
// TODO(satnam6502): Replace call of randomSuffix with call to NewUUID when service
"contrib"
,
"for-tests"
,
"network-tester"
,
"service.json"
,
// names have the same form as pod and replication controller names.
))
.
(
*
api
.
Service
))
name
:=
"nettest-"
+
randomSuffix
()
svc
,
err
:=
c
.
Services
(
ns
)
.
Create
(
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Labels
:
map
[
string
]
string
{
"name"
:
name
,
},
},
Spec
:
api
.
ServiceSpec
{
Port
:
8080
,
ContainerPort
:
util
.
NewIntOrStringFromInt
(
8080
),
Selector
:
map
[
string
]
string
{
"name"
:
name
,
},
},
})
glog
.
Infof
(
"Creating service with name %s"
,
svc
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"unable to create test service
: %v"
,
err
)
glog
.
Errorf
(
"unable to create test service
%s: %v"
,
svc
.
Name
,
err
)
return
false
return
false
}
}
// Clean up service
// Clean up service
...
@@ -44,10 +61,35 @@ func TestNetwork(c *client.Client) bool {
...
@@ -44,10 +61,35 @@ func TestNetwork(c *client.Client) bool {
glog
.
Errorf
(
"unable to delete svc %v: %v"
,
svc
.
Name
,
err
)
glog
.
Errorf
(
"unable to delete svc %v: %v"
,
svc
.
Name
,
err
)
}
}
}()
}()
rc
,
err
:=
c
.
ReplicationControllers
(
ns
)
.
Create
(
&
api
.
ReplicationController
{
rc
,
err
:=
c
.
ReplicationControllers
(
ns
)
.
Create
(
loadObjectOrDie
(
assetPath
(
ObjectMeta
:
api
.
ObjectMeta
{
"contrib"
,
"for-tests"
,
"network-tester"
,
"rc.json"
,
Name
:
name
,
))
.
(
*
api
.
ReplicationController
))
Labels
:
map
[
string
]
string
{
"name"
:
name
,
},
},
Spec
:
api
.
ReplicationControllerSpec
{
Replicas
:
8
,
Selector
:
map
[
string
]
string
{
"name"
:
name
,
},
Template
:
&
api
.
PodTemplateSpec
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"name"
:
name
},
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"webserver"
,
Image
:
"kubernetes/nettest:latest"
,
Command
:
[]
string
{
"-service="
+
name
},
Ports
:
[]
api
.
Port
{{
ContainerPort
:
8080
}},
},
},
},
},
},
})
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"unable to create test rc: %v"
,
err
)
glog
.
Errorf
(
"unable to create test rc: %v"
,
err
)
return
false
return
false
...
@@ -66,7 +108,7 @@ func TestNetwork(c *client.Client) bool {
...
@@ -66,7 +108,7 @@ func TestNetwork(c *client.Client) bool {
}()
}()
const
maxAttempts
=
60
const
maxAttempts
=
60
for
i
:=
0
;
i
<
maxAttempts
;
i
++
{
for
i
:=
0
;
i
<
maxAttempts
;
i
++
{
time
.
Sleep
(
time
.
Second
)
time
.
Sleep
(
2
*
time
.
Second
)
body
,
err
:=
c
.
Get
()
.
Prefix
(
"proxy"
)
.
Resource
(
"services"
)
.
Name
(
svc
.
Name
)
.
Suffix
(
"status"
)
.
Do
()
.
Raw
()
body
,
err
:=
c
.
Get
()
.
Prefix
(
"proxy"
)
.
Resource
(
"services"
)
.
Name
(
svc
.
Name
)
.
Suffix
(
"status"
)
.
Do
()
.
Raw
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Infof
(
"Attempt %v/%v: service/pod still starting. (error: '%v')"
,
i
,
maxAttempts
,
err
)
glog
.
Infof
(
"Attempt %v/%v: service/pod still starting. (error: '%v')"
,
i
,
maxAttempts
,
err
)
...
...
test/e2e/util.go
View file @
f988a01a
...
@@ -18,7 +18,9 @@ package e2e
...
@@ -18,7 +18,9 @@ package e2e
import
(
import
(
"io/ioutil"
"io/ioutil"
"math/rand"
"path/filepath"
"path/filepath"
"strconv"
"time"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -183,3 +185,12 @@ func parseServiceOrDie(json string) *api.Service {
...
@@ -183,3 +185,12 @@ func parseServiceOrDie(json string) *api.Service {
}
}
return
service
return
service
}
}
// 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
// use the UUID utilty function.
func
randomSuffix
()
string
{
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
return
strconv
.
Itoa
(
r
.
Int
()
%
10000
)
}
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