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
d44c1d5b
Commit
d44c1d5b
authored
Feb 05, 2015
by
Robert Rati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted TestClusterDNS to native ginkgo syntax #4162
parent
de848cc3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
27 deletions
+30
-27
service.go
test/e2e/service.go
+30
-27
No files found.
test/e2e/service.go
View file @
d44c1d5b
...
@@ -23,19 +23,22 @@ import (
...
@@ -23,19 +23,22 @@ 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/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
)
)
// TestClusterDNS checks that cluster DNS works.
var
_
=
Describe
(
"Services"
,
func
()
{
func
TestClusterDNS
(
c
*
client
.
Client
)
bool
{
var
c
*
client
.
Client
if
testContext
.
provider
==
"vagrant"
{
glog
.
Infof
(
"Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)"
)
BeforeEach
(
func
()
{
return
true
c
=
loadClientOrDie
()
}
}
)
It
(
"should provide DNS for the cluster"
,
func
()
{
if
testContext
.
provider
==
"vagrant"
{
By
(
"Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)"
)
}
else
{
podClient
:=
c
.
Pods
(
api
.
NamespaceDefault
)
podClient
:=
c
.
Pods
(
api
.
NamespaceDefault
)
//TODO: Wait for skyDNS
//TODO: Wait for skyDNS
...
@@ -55,6 +58,7 @@ func TestClusterDNS(c *client.Client) bool {
...
@@ -55,6 +58,7 @@ func TestClusterDNS(c *client.Client) bool {
probeCmd
+=
"sleep 1; done"
probeCmd
+=
"sleep 1; done"
// Run a pod which probes DNS and exposes the results by HTTP.
// Run a pod which probes DNS and exposes the results by HTTP.
By
(
"creating a pod to probe DNS"
)
pod
:=
&
api
.
Pod
{
pod
:=
&
api
.
Pod
{
TypeMeta
:
api
.
TypeMeta
{
TypeMeta
:
api
.
TypeMeta
{
Kind
:
"Pod"
,
Kind
:
"Pod"
,
...
@@ -97,21 +101,30 @@ func TestClusterDNS(c *client.Client) bool {
...
@@ -97,21 +101,30 @@ func TestClusterDNS(c *client.Client) bool {
},
},
},
},
}
}
By
(
"submitting the pod to kuberenetes"
)
_
,
err
:=
podClient
.
Create
(
pod
)
_
,
err
:=
podClient
.
Create
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to create %s pod: %v"
,
pod
.
Name
,
err
)
Fail
(
fmt
.
Sprintf
(
"Failed to create %s pod: %v"
,
pod
.
Name
,
err
))
return
false
}
}
defer
podClient
.
Delete
(
pod
.
Name
)
defer
func
()
{
By
(
"deleting the pod"
)
defer
GinkgoRecover
()
podClient
.
Delete
(
pod
.
Name
)
}()
By
(
"waiting for the pod to start running"
)
waitForPodRunning
(
c
,
pod
.
Name
)
waitForPodRunning
(
c
,
pod
.
Name
)
By
(
"retrieving the pod"
)
pod
,
err
=
podClient
.
Get
(
pod
.
Name
)
pod
,
err
=
podClient
.
Get
(
pod
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to get pod %s: %v"
,
pod
.
Name
,
err
)
Fail
(
fmt
.
Sprintf
(
"Failed to get pod %s: %v"
,
pod
.
Name
,
err
))
return
false
}
}
// Try to find results for each expected name.
// Try to find results for each expected name.
By
(
"looking for the results for each expected name"
)
var
failed
[]
string
var
failed
[]
string
for
try
:=
1
;
try
<
100
;
try
++
{
for
try
:=
1
;
try
<
100
;
try
++
{
failed
=
[]
string
{}
failed
=
[]
string
{}
...
@@ -125,30 +138,20 @@ func TestClusterDNS(c *client.Client) bool {
...
@@ -125,30 +138,20 @@ func TestClusterDNS(c *client.Client) bool {
Do
()
.
Raw
()
Do
()
.
Raw
()
if
err
!=
nil
{
if
err
!=
nil
{
failed
=
append
(
failed
,
name
)
failed
=
append
(
failed
,
name
)
glog
.
V
(
4
)
.
Infof
(
"Lookup using %s for %s failed: %v
"
,
pod
.
Name
,
name
,
err
)
fmt
.
Printf
(
"Lookup using %s for %s failed: %v
\n
"
,
pod
.
Name
,
name
,
err
)
}
}
}
}
if
len
(
failed
)
==
0
{
if
len
(
failed
)
==
0
{
break
break
}
}
glog
.
Infof
(
"lookups using %s failed for: %v
"
,
pod
.
Name
,
failed
)
fmt
.
Printf
(
"lookups using %s failed for: %v
\n
"
,
pod
.
Name
,
failed
)
time
.
Sleep
(
10
*
time
.
Second
)
time
.
Sleep
(
10
*
time
.
Second
)
}
}
if
len
(
failed
)
!=
0
{
Expect
(
len
(
failed
))
.
To
(
Equal
(
0
))
glog
.
Errorf
(
"DNS using %s failed for: %v"
,
pod
.
Name
,
failed
)
return
false
}
// TODO: probe from the host, too.
// TODO: probe from the host, too.
glog
.
Infof
(
"DNS probes using %s succeeded"
,
pod
.
Name
)
fmt
.
Printf
(
"DNS probes using %s succeeded
\n
"
,
pod
.
Name
)
return
true
}
}
var
_
=
Describe
(
"TestClusterDNS"
,
func
()
{
It
(
"should pass"
,
func
()
{
// TODO: Instead of OrDie, client should Fail the test if there's a problem.
// In general tests should Fail() instead of glog.Fatalf().
Expect
(
TestClusterDNS
(
loadClientOrDie
()))
.
To
(
BeTrue
())
})
})
})
})
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