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
200eb19d
Commit
200eb19d
authored
Jul 21, 2017
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Garbage collector e2e tests create deployments with unique labels, and
unique podTemplate
parent
5d5d6ca3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
28 deletions
+45
-28
garbage_collector.go
test/e2e/apimachinery/garbage_collector.go
+45
-28
No files found.
test/e2e/apimachinery/garbage_collector.go
View file @
200eb19d
...
@@ -51,23 +51,25 @@ func getNonOrphanOptions() *metav1.DeleteOptions {
...
@@ -51,23 +51,25 @@ func getNonOrphanOptions() *metav1.DeleteOptions {
}
}
var
zero
=
int64
(
0
)
var
zero
=
int64
(
0
)
var
deploymentLabels
=
map
[
string
]
string
{
"app"
:
"gc-test"
}
var
podTemplateSpec
=
v1
.
PodTemplateSpec
{
func
getPodTemplateSpec
(
labels
map
[
string
]
string
)
v1
.
PodTemplateSpec
{
ObjectMeta
:
metav1
.
ObjectMeta
{
return
v1
.
PodTemplateSpec
{
Labels
:
deploymentLabels
,
ObjectMeta
:
metav1
.
ObjectMeta
{
},
Labels
:
labels
,
Spec
:
v1
.
PodSpec
{
},
TerminationGracePeriodSeconds
:
&
zero
,
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
TerminationGracePeriodSeconds
:
&
zero
,
{
Containers
:
[]
v1
.
Container
{
Name
:
"nginx"
,
{
Image
:
"gcr.io/google_containers/nginx-slim:0.7"
,
Name
:
"nginx"
,
Image
:
"gcr.io/google_containers/nginx-slim:0.7"
,
},
},
},
},
},
}
,
}
}
}
func
newOwnerDeployment
(
f
*
framework
.
Framework
,
deploymentName
string
)
*
v1beta1
.
Deployment
{
func
newOwnerDeployment
(
f
*
framework
.
Framework
,
deploymentName
string
,
labels
map
[
string
]
string
)
*
v1beta1
.
Deployment
{
replicas
:=
int32
(
2
)
replicas
:=
int32
(
2
)
return
&
v1beta1
.
Deployment
{
return
&
v1beta1
.
Deployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
@@ -75,11 +77,11 @@ func newOwnerDeployment(f *framework.Framework, deploymentName string) *v1beta1.
...
@@ -75,11 +77,11 @@ func newOwnerDeployment(f *framework.Framework, deploymentName string) *v1beta1.
},
},
Spec
:
v1beta1
.
DeploymentSpec
{
Spec
:
v1beta1
.
DeploymentSpec
{
Replicas
:
&
replicas
,
Replicas
:
&
replicas
,
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
deploymentL
abels
},
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
l
abels
},
Strategy
:
v1beta1
.
DeploymentStrategy
{
Strategy
:
v1beta1
.
DeploymentStrategy
{
Type
:
v1beta1
.
RollingUpdateDeploymentStrategyType
,
Type
:
v1beta1
.
RollingUpdateDeploymentStrategyType
,
},
},
Template
:
podTemplateSpec
,
Template
:
getPodTemplateSpec
(
labels
)
,
},
},
}
}
}
}
...
@@ -88,7 +90,8 @@ func getSelector() map[string]string {
...
@@ -88,7 +90,8 @@ func getSelector() map[string]string {
return
map
[
string
]
string
{
"app"
:
"gc-test"
}
return
map
[
string
]
string
{
"app"
:
"gc-test"
}
}
}
func
newOwnerRC
(
f
*
framework
.
Framework
,
name
string
,
replicas
int32
)
*
v1
.
ReplicationController
{
func
newOwnerRC
(
f
*
framework
.
Framework
,
name
string
,
replicas
int32
,
labels
map
[
string
]
string
)
*
v1
.
ReplicationController
{
template
:=
getPodTemplateSpec
(
labels
)
return
&
v1
.
ReplicationController
{
return
&
v1
.
ReplicationController
{
TypeMeta
:
metav1
.
TypeMeta
{
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"ReplicationController"
,
Kind
:
"ReplicationController"
,
...
@@ -100,8 +103,8 @@ func newOwnerRC(f *framework.Framework, name string, replicas int32) *v1.Replica
...
@@ -100,8 +103,8 @@ func newOwnerRC(f *framework.Framework, name string, replicas int32) *v1.Replica
},
},
Spec
:
v1
.
ReplicationControllerSpec
{
Spec
:
v1
.
ReplicationControllerSpec
{
Replicas
:
&
replicas
,
Replicas
:
&
replicas
,
Selector
:
map
[
string
]
string
{
"app"
:
"gc-test"
}
,
Selector
:
labels
,
Template
:
&
podTemplateSpec
,
Template
:
&
template
,
},
},
}
}
}
}
...
@@ -215,7 +218,9 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -215,7 +218,9 @@ var _ = SIGDescribe("Garbage collector", func() {
rcClient
:=
clientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
rcClient
:=
clientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
podClient
:=
clientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
podClient
:=
clientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
rcName
:=
"simpletest.rc"
rcName
:=
"simpletest.rc"
rc
:=
newOwnerRC
(
f
,
rcName
,
2
)
// TODO: find better way to keep this label unique in the test
uniqLabels
:=
map
[
string
]
string
{
"gctest"
:
"delete_pods"
}
rc
:=
newOwnerRC
(
f
,
rcName
,
2
,
uniqLabels
)
By
(
"create the rc"
)
By
(
"create the rc"
)
rc
,
err
:=
rcClient
.
Create
(
rc
)
rc
,
err
:=
rcClient
.
Create
(
rc
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -266,7 +271,9 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -266,7 +271,9 @@ var _ = SIGDescribe("Garbage collector", func() {
rcClient
:=
clientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
rcClient
:=
clientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
podClient
:=
clientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
podClient
:=
clientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
rcName
:=
"simpletest.rc"
rcName
:=
"simpletest.rc"
rc
:=
newOwnerRC
(
f
,
rcName
,
100
)
// TODO: find better way to keep this label unique in the test
uniqLabels
:=
map
[
string
]
string
{
"gctest"
:
"orphan_pods"
}
rc
:=
newOwnerRC
(
f
,
rcName
,
100
,
uniqLabels
)
By
(
"create the rc"
)
By
(
"create the rc"
)
rc
,
err
:=
rcClient
.
Create
(
rc
)
rc
,
err
:=
rcClient
.
Create
(
rc
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -332,7 +339,9 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -332,7 +339,9 @@ var _ = SIGDescribe("Garbage collector", func() {
rcClient
:=
clientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
rcClient
:=
clientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
podClient
:=
clientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
podClient
:=
clientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
rcName
:=
"simpletest.rc"
rcName
:=
"simpletest.rc"
rc
:=
newOwnerRC
(
f
,
rcName
,
2
)
// TODO: find better way to keep this label unique in the test
uniqLabels
:=
map
[
string
]
string
{
"gctest"
:
"orphan_pods_nil_option"
}
rc
:=
newOwnerRC
(
f
,
rcName
,
2
,
uniqLabels
)
By
(
"create the rc"
)
By
(
"create the rc"
)
rc
,
err
:=
rcClient
.
Create
(
rc
)
rc
,
err
:=
rcClient
.
Create
(
rc
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -379,7 +388,9 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -379,7 +388,9 @@ var _ = SIGDescribe("Garbage collector", func() {
deployClient
:=
clientSet
.
Extensions
()
.
Deployments
(
f
.
Namespace
.
Name
)
deployClient
:=
clientSet
.
Extensions
()
.
Deployments
(
f
.
Namespace
.
Name
)
rsClient
:=
clientSet
.
Extensions
()
.
ReplicaSets
(
f
.
Namespace
.
Name
)
rsClient
:=
clientSet
.
Extensions
()
.
ReplicaSets
(
f
.
Namespace
.
Name
)
deploymentName
:=
"simpletest.deployment"
deploymentName
:=
"simpletest.deployment"
deployment
:=
newOwnerDeployment
(
f
,
deploymentName
)
// TODO: find better way to keep this label unique in the test
uniqLabels
:=
map
[
string
]
string
{
"gctest"
:
"delete_rs"
}
deployment
:=
newOwnerDeployment
(
f
,
deploymentName
,
uniqLabels
)
By
(
"create the deployment"
)
By
(
"create the deployment"
)
createdDeployment
,
err
:=
deployClient
.
Create
(
deployment
)
createdDeployment
,
err
:=
deployClient
.
Create
(
deployment
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -428,7 +439,9 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -428,7 +439,9 @@ var _ = SIGDescribe("Garbage collector", func() {
deployClient
:=
clientSet
.
Extensions
()
.
Deployments
(
f
.
Namespace
.
Name
)
deployClient
:=
clientSet
.
Extensions
()
.
Deployments
(
f
.
Namespace
.
Name
)
rsClient
:=
clientSet
.
Extensions
()
.
ReplicaSets
(
f
.
Namespace
.
Name
)
rsClient
:=
clientSet
.
Extensions
()
.
ReplicaSets
(
f
.
Namespace
.
Name
)
deploymentName
:=
"simpletest.deployment"
deploymentName
:=
"simpletest.deployment"
deployment
:=
newOwnerDeployment
(
f
,
deploymentName
)
// TODO: find better way to keep this label unique in the test
uniqLabels
:=
map
[
string
]
string
{
"gctest"
:
"orphan_rs"
}
deployment
:=
newOwnerDeployment
(
f
,
deploymentName
,
uniqLabels
)
By
(
"create the deployment"
)
By
(
"create the deployment"
)
createdDeployment
,
err
:=
deployClient
.
Create
(
deployment
)
createdDeployment
,
err
:=
deployClient
.
Create
(
deployment
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -491,7 +504,9 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -491,7 +504,9 @@ var _ = SIGDescribe("Garbage collector", func() {
rcClient
:=
clientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
rcClient
:=
clientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
podClient
:=
clientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
podClient
:=
clientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
rcName
:=
"simpletest.rc"
rcName
:=
"simpletest.rc"
rc
:=
newOwnerRC
(
f
,
rcName
,
100
)
// TODO: find better way to keep this label unique in the test
uniqLabels
:=
map
[
string
]
string
{
"gctest"
:
"delete_pods_foreground"
}
rc
:=
newOwnerRC
(
f
,
rcName
,
100
,
uniqLabels
)
By
(
"create the rc"
)
By
(
"create the rc"
)
rc
,
err
:=
rcClient
.
Create
(
rc
)
rc
,
err
:=
rcClient
.
Create
(
rc
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -571,16 +586,18 @@ var _ = SIGDescribe("Garbage collector", func() {
...
@@ -571,16 +586,18 @@ var _ = SIGDescribe("Garbage collector", func() {
rc1Name
:=
"simpletest-rc-to-be-deleted"
rc1Name
:=
"simpletest-rc-to-be-deleted"
replicas
:=
int32
(
100
)
replicas
:=
int32
(
100
)
halfReplicas
:=
int
(
replicas
/
2
)
halfReplicas
:=
int
(
replicas
/
2
)
rc1
:=
newOwnerRC
(
f
,
rc1Name
,
replicas
)
// TODO: find better way to keep this label unique in the test
uniqLabels
:=
map
[
string
]
string
{
"gctest"
:
"valid_and_pending_owners"
}
rc1
:=
newOwnerRC
(
f
,
rc1Name
,
replicas
,
uniqLabels
)
By
(
"create the rc1"
)
By
(
"create the rc1"
)
rc1
,
err
:=
rcClient
.
Create
(
rc1
)
rc1
,
err
:=
rcClient
.
Create
(
rc1
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"Failed to create replication controller: %v"
,
err
)
framework
.
Failf
(
"Failed to create replication controller: %v"
,
err
)
}
}
rc2Name
:=
"simpletest-rc-to-stay"
rc2Name
:=
"simpletest-rc-to-stay"
rc2
:=
newOwnerRC
(
f
,
rc2Name
,
0
)
// TODO: find better way to keep this label unique in the test
rc2
.
Spec
.
Selector
=
nil
uniqLabels
=
map
[
string
]
string
{
"another.key"
:
"another.value"
}
rc2
.
Spec
.
Template
.
ObjectMeta
.
Labels
=
map
[
string
]
string
{
"another.key"
:
"another.value"
}
rc2
:=
newOwnerRC
(
f
,
rc2Name
,
0
,
uniqLabels
)
By
(
"create the rc2"
)
By
(
"create the rc2"
)
rc2
,
err
=
rcClient
.
Create
(
rc2
)
rc2
,
err
=
rcClient
.
Create
(
rc2
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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