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
ff3f9f6b
Commit
ff3f9f6b
authored
Feb 05, 2016
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move "extra" namespaces into framework
Now an aborted test will delete namespaces. Hopefully this means less GCE leaks.
parent
677d4d6d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
47 deletions
+33
-47
example_cluster_dns.go
test/e2e/example_cluster_dns.go
+2
-9
framework.go
test/e2e/framework.go
+24
-11
namespace.go
test/e2e/namespace.go
+6
-7
service.go
test/e2e/service.go
+1
-20
No files found.
test/e2e/example_cluster_dns.go
View file @
ff3f9f6b
...
@@ -75,15 +75,8 @@ var _ = Describe("ClusterDns [Feature:Example]", func() {
...
@@ -75,15 +75,8 @@ var _ = Describe("ClusterDns [Feature:Example]", func() {
namespaces
:=
[]
*
api
.
Namespace
{
nil
,
nil
}
namespaces
:=
[]
*
api
.
Namespace
{
nil
,
nil
}
for
i
:=
range
namespaces
{
for
i
:=
range
namespaces
{
var
err
error
var
err
error
namespaces
[
i
],
err
=
createTestingNS
(
fmt
.
Sprintf
(
"dnsexample%d"
,
i
),
c
,
nil
)
namespaces
[
i
],
err
=
framework
.
CreateNamespace
(
fmt
.
Sprintf
(
"dnsexample%d"
,
i
),
nil
)
if
testContext
.
DeleteNamespace
{
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
if
namespaces
[
i
]
!=
nil
{
defer
deleteNS
(
c
,
namespaces
[
i
]
.
Name
,
5
*
time
.
Minute
/* namespace deletion timeout */
)
}
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
else
{
Logf
(
"Found DeleteNamespace=false, skipping namespace deletion!"
)
}
}
}
for
_
,
ns
:=
range
namespaces
{
for
_
,
ns
:=
range
namespaces
{
...
...
test/e2e/framework.go
View file @
ff3f9f6b
...
@@ -43,9 +43,11 @@ const (
...
@@ -43,9 +43,11 @@ const (
type
Framework
struct
{
type
Framework
struct
{
BaseName
string
BaseName
string
Namespace
*
api
.
Namespace
Client
*
client
.
Client
Client
*
client
.
Client
Clientset_1_2
*
release_1_2
.
Clientset
Clientset_1_2
*
release_1_2
.
Clientset
Namespace
*
api
.
Namespace
// Every test has at least one namespace
namespacesToDelete
[]
*
api
.
Namespace
// Some tests have more than one.
NamespaceDeletionTimeout
time
.
Duration
NamespaceDeletionTimeout
time
.
Duration
gatherer
containerResourceGatherer
gatherer
containerResourceGatherer
...
@@ -97,7 +99,7 @@ func (f *Framework) beforeEach() {
...
@@ -97,7 +99,7 @@ func (f *Framework) beforeEach() {
f
.
Clientset_1_2
=
release_1_2
.
FromUnversionedClient
(
c
)
f
.
Clientset_1_2
=
release_1_2
.
FromUnversionedClient
(
c
)
By
(
"Building a namespace api object"
)
By
(
"Building a namespace api object"
)
namespace
,
err
:=
createTestingNS
(
f
.
BaseName
,
f
.
Client
,
map
[
string
]
string
{
namespace
,
err
:=
f
.
CreateNamespace
(
f
.
BaseName
,
map
[
string
]
string
{
"e2e-framework"
:
f
.
BaseName
,
"e2e-framework"
:
f
.
BaseName
,
})
})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -177,15 +179,18 @@ func (f *Framework) afterEach() {
...
@@ -177,15 +179,18 @@ func (f *Framework) afterEach() {
}
}
if
testContext
.
DeleteNamespace
{
if
testContext
.
DeleteNamespace
{
By
(
fmt
.
Sprintf
(
"Destroying namespace %q for this suite."
,
f
.
Namespace
.
Name
))
for
_
,
ns
:=
range
f
.
namespacesToDelete
{
By
(
fmt
.
Sprintf
(
"Destroying namespace %q for this suite."
,
ns
.
Name
))
timeout
:=
5
*
time
.
Minute
timeout
:=
5
*
time
.
Minute
if
f
.
NamespaceDeletionTimeout
!=
0
{
if
f
.
NamespaceDeletionTimeout
!=
0
{
timeout
=
f
.
NamespaceDeletionTimeout
timeout
=
f
.
NamespaceDeletionTimeout
}
}
if
err
:=
deleteNS
(
f
.
Client
,
f
.
Namespace
.
Name
,
timeout
);
err
!=
nil
{
if
err
:=
deleteNS
(
f
.
Client
,
ns
.
Name
,
timeout
);
err
!=
nil
{
Failf
(
"Couldn't delete ns %q: %s"
,
f
.
Namespace
.
Name
,
err
)
Failf
(
"Couldn't delete ns %q: %s"
,
ns
.
Name
,
err
)
}
}
}
f
.
namespacesToDelete
=
nil
}
else
{
}
else
{
Logf
(
"Found DeleteNamespace=false, skipping namespace deletion!"
)
Logf
(
"Found DeleteNamespace=false, skipping namespace deletion!"
)
}
}
...
@@ -220,6 +225,14 @@ func (f *Framework) afterEach() {
...
@@ -220,6 +225,14 @@ func (f *Framework) afterEach() {
f
.
Client
=
nil
f
.
Client
=
nil
}
}
func
(
f
*
Framework
)
CreateNamespace
(
baseName
string
,
labels
map
[
string
]
string
)
(
*
api
.
Namespace
,
error
)
{
ns
,
err
:=
createTestingNS
(
baseName
,
f
.
Client
,
labels
)
if
err
==
nil
{
f
.
namespacesToDelete
=
append
(
f
.
namespacesToDelete
,
ns
)
}
return
ns
,
err
}
// WaitForPodTerminated waits for the pod to be terminated with the given reason.
// WaitForPodTerminated waits for the pod to be terminated with the given reason.
func
(
f
*
Framework
)
WaitForPodTerminated
(
podName
,
reason
string
)
error
{
func
(
f
*
Framework
)
WaitForPodTerminated
(
podName
,
reason
string
)
error
{
return
waitForPodTerminatedInNamespace
(
f
.
Client
,
podName
,
reason
,
f
.
Namespace
.
Name
)
return
waitForPodTerminatedInNamespace
(
f
.
Client
,
podName
,
reason
,
f
.
Namespace
.
Name
)
...
...
test/e2e/namespace.go
View file @
ff3f9f6b
...
@@ -23,14 +23,13 @@ import (
...
@@ -23,14 +23,13 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
)
)
func
extinguish
(
c
*
client
.
Client
,
totalNS
int
,
maxAllowedAfterDel
int
,
maxSeconds
int
)
{
func
extinguish
(
f
*
Framework
,
totalNS
int
,
maxAllowedAfterDel
int
,
maxSeconds
int
)
{
var
err
error
var
err
error
By
(
"Creating testing namespaces"
)
By
(
"Creating testing namespaces"
)
...
@@ -40,7 +39,7 @@ func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSecond
...
@@ -40,7 +39,7 @@ func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSecond
go
func
(
n
int
)
{
go
func
(
n
int
)
{
defer
wg
.
Done
()
defer
wg
.
Done
()
defer
GinkgoRecover
()
defer
GinkgoRecover
()
_
,
err
=
createTestingNS
(
fmt
.
Sprintf
(
"nslifetest-%v"
,
n
),
c
,
nil
)
_
,
err
=
f
.
CreateNamespace
(
fmt
.
Sprintf
(
"nslifetest-%v"
,
n
)
,
nil
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}(
n
)
}(
n
)
}
}
...
@@ -49,7 +48,7 @@ func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSecond
...
@@ -49,7 +48,7 @@ func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSecond
//Wait 10 seconds, then SEND delete requests for all the namespaces.
//Wait 10 seconds, then SEND delete requests for all the namespaces.
By
(
"Waiting 10 seconds"
)
By
(
"Waiting 10 seconds"
)
time
.
Sleep
(
time
.
Duration
(
10
*
time
.
Second
))
time
.
Sleep
(
time
.
Duration
(
10
*
time
.
Second
))
deleted
,
err
:=
deleteNamespaces
(
c
,
[]
string
{
"nslifetest"
},
nil
/* skipFilter */
)
deleted
,
err
:=
deleteNamespaces
(
f
.
Client
,
[]
string
{
"nslifetest"
},
nil
/* skipFilter */
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
len
(
deleted
))
.
To
(
Equal
(
totalNS
))
Expect
(
len
(
deleted
))
.
To
(
Equal
(
totalNS
))
...
@@ -58,7 +57,7 @@ func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSecond
...
@@ -58,7 +57,7 @@ func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSecond
expectNoError
(
wait
.
Poll
(
2
*
time
.
Second
,
time
.
Duration
(
maxSeconds
)
*
time
.
Second
,
expectNoError
(
wait
.
Poll
(
2
*
time
.
Second
,
time
.
Duration
(
maxSeconds
)
*
time
.
Second
,
func
()
(
bool
,
error
)
{
func
()
(
bool
,
error
)
{
var
cnt
=
0
var
cnt
=
0
nsList
,
err
:=
c
.
Namespaces
()
.
List
(
api
.
ListOptions
{})
nsList
,
err
:=
f
.
Client
.
Namespaces
()
.
List
(
api
.
ListOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
...
@@ -108,9 +107,9 @@ var _ = Describe("Namespaces [Serial]", func() {
...
@@ -108,9 +107,9 @@ var _ = Describe("Namespaces [Serial]", func() {
f
:=
NewFramework
(
"namespaces"
)
f
:=
NewFramework
(
"namespaces"
)
It
(
"should delete fast enough (90 percent of 100 namespaces in 150 seconds)"
,
It
(
"should delete fast enough (90 percent of 100 namespaces in 150 seconds)"
,
func
()
{
extinguish
(
f
.
Client
,
100
,
10
,
150
)
})
func
()
{
extinguish
(
f
,
100
,
10
,
150
)
})
// On hold until etcd3; see #7372
// On hold until etcd3; see #7372
It
(
"should always delete fast (ALL of 100 namespaces in 150 seconds) [Feature:ComprehensiveNamespaceDraining]"
,
It
(
"should always delete fast (ALL of 100 namespaces in 150 seconds) [Feature:ComprehensiveNamespaceDraining]"
,
func
()
{
extinguish
(
f
.
Client
,
100
,
0
,
150
)
})
func
()
{
extinguish
(
f
,
100
,
0
,
150
)
})
})
})
test/e2e/service.go
View file @
ff3f9f6b
...
@@ -54,9 +54,6 @@ const loadBalancerLagTimeout = 2 * time.Minute
...
@@ -54,9 +54,6 @@ const loadBalancerLagTimeout = 2 * time.Minute
//TODO: once support ticket 21807001 is resolved, reduce this timeout back to something reasonable
//TODO: once support ticket 21807001 is resolved, reduce this timeout back to something reasonable
const
loadBalancerCreateTimeout
=
20
*
time
.
Minute
const
loadBalancerCreateTimeout
=
20
*
time
.
Minute
// How long to wait for a namespace to be deleted.
const
namespaceDeleteTimeout
=
5
*
time
.
Minute
// This should match whatever the default/configured range is
// This should match whatever the default/configured range is
var
ServiceNodePortRange
=
utilnet
.
PortRange
{
Base
:
30000
,
Size
:
2768
}
var
ServiceNodePortRange
=
utilnet
.
PortRange
{
Base
:
30000
,
Size
:
2768
}
...
@@ -64,7 +61,6 @@ var _ = Describe("Services", func() {
...
@@ -64,7 +61,6 @@ var _ = Describe("Services", func() {
f
:=
NewFramework
(
"services"
)
f
:=
NewFramework
(
"services"
)
var
c
*
client
.
Client
var
c
*
client
.
Client
var
extraNamespaces
[]
string
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
var
err
error
var
err
error
...
@@ -72,20 +68,6 @@ var _ = Describe("Services", func() {
...
@@ -72,20 +68,6 @@ var _ = Describe("Services", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
})
AfterEach
(
func
()
{
if
testContext
.
DeleteNamespace
{
for
_
,
ns
:=
range
extraNamespaces
{
By
(
fmt
.
Sprintf
(
"Destroying namespace %v"
,
ns
))
if
err
:=
deleteNS
(
c
,
ns
,
namespaceDeleteTimeout
);
err
!=
nil
{
Failf
(
"Couldn't delete namespace %s: %s"
,
ns
,
err
)
}
}
extraNamespaces
=
nil
}
else
{
Logf
(
"Found DeleteNamespace=false, skipping namespace deletion!"
)
}
})
// TODO: We get coverage of TCP/UDP and multi-port services through the DNS test. We should have a simpler test for multi-port TCP here.
// TODO: We get coverage of TCP/UDP and multi-port services through the DNS test. We should have a simpler test for multi-port TCP here.
It
(
"should provide secure master service [Conformance]"
,
func
()
{
It
(
"should provide secure master service [Conformance]"
,
func
()
{
...
@@ -429,11 +411,10 @@ var _ = Describe("Services", func() {
...
@@ -429,11 +411,10 @@ var _ = Describe("Services", func() {
Logf
(
"namespace for TCP test: %s"
,
ns1
)
Logf
(
"namespace for TCP test: %s"
,
ns1
)
By
(
"creating a second namespace"
)
By
(
"creating a second namespace"
)
namespacePtr
,
err
:=
createTestingNS
(
"services"
,
c
,
nil
)
namespacePtr
,
err
:=
f
.
CreateNamespace
(
"services"
,
nil
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
ns2
:=
namespacePtr
.
Name
// LB2 in ns2 on UDP
ns2
:=
namespacePtr
.
Name
// LB2 in ns2 on UDP
Logf
(
"namespace for UDP test: %s"
,
ns2
)
Logf
(
"namespace for UDP test: %s"
,
ns2
)
extraNamespaces
=
append
(
extraNamespaces
,
ns2
)
jig
:=
NewServiceTestJig
(
c
,
serviceName
)
jig
:=
NewServiceTestJig
(
c
,
serviceName
)
nodeIP
:=
pickNodeIP
(
jig
.
Client
)
// for later
nodeIP
:=
pickNodeIP
(
jig
.
Client
)
// for later
...
...
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