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
d61ed527
Commit
d61ed527
authored
Sep 24, 2015
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding an e2e test for deployment
parent
cf75b0d0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
177 additions
and
1 deletion
+177
-1
e2e.go
hack/e2e.go
+2
-0
e2e.sh
hack/jenkins/e2e.sh
+5
-0
deployment.go
test/e2e/deployment.go
+169
-0
resize_nodes.go
test/e2e/resize_nodes.go
+1
-1
No files found.
hack/e2e.go
View file @
d61ed527
...
...
@@ -178,6 +178,8 @@ func Up() bool {
}
}
// Enable deployments for e2e tests.
os
.
Setenv
(
"KUBE_ENABLE_DEPLOYMENTS"
,
"true"
)
return
finishRunning
(
"up"
,
exec
.
Command
(
path
.
Join
(
*
root
,
"hack/e2e-internal/e2e-up.sh"
)))
}
...
...
hack/jenkins/e2e.sh
View file @
d61ed527
...
...
@@ -198,6 +198,7 @@ case ${JOB_NAME} in
)
"
}
:
${
KUBE_GCE_INSTANCE_PREFIX
=
"e2e-gce"
}
:
${
PROJECT
:
=
"k8s-jkns-e2e-gce"
}
:
${
ENABLE_DEPLOYMENTS
:
=true
}
;;
# Runs only the examples tests on GCE.
...
...
@@ -265,6 +266,7 @@ case ${JOB_NAME} in
:
${
KUBE_GCE_INSTANCE_PREFIX
:
=
"pull-e2e-
${
EXECUTOR_NUMBER
}
"
}
:
${
KUBE_GCS_STAGING_PATH_SUFFIX
:
=
"-
${
EXECUTOR_NUMBER
}
"
}
:
${
PROJECT
:
=
"kubernetes-jenkins-pull"
}
:
${
ENABLE_DEPLOYMENTS
:
=true
}
# Override GCE defaults
NUM_MINIONS
=
${
NUM_MINIONS_PARALLEL
}
;;
...
...
@@ -283,6 +285,7 @@ case ${JOB_NAME} in
)
"
}
:
${
KUBE_GCE_INSTANCE_PREFIX
:
=
"e2e-test-parallel"
}
:
${
PROJECT
:
=
"kubernetes-jenkins"
}
:
${
ENABLE_DEPLOYMENTS
:
=true
}
# Override GCE defaults
NUM_MINIONS
=
${
NUM_MINIONS_PARALLEL
}
;;
...
...
@@ -298,6 +301,7 @@ case ${JOB_NAME} in
${
GCE_FLAKY_TESTS
[@]
:+
${
GCE_FLAKY_TESTS
[@]
}}
\
${
GCE_PARALLEL_FLAKY_TESTS
[@]
:+
${
GCE_PARALLEL_FLAKY_TESTS
[@]
}}
\
)
"
}
:
${
ENABLE_DEPLOYMENTS
:
=true
}
# Override AWS defaults.
NUM_MINIONS
=
"6"
;;
...
...
@@ -526,6 +530,7 @@ fi
export
E2E_MIN_STARTUP_PODS
=
${
E2E_MIN_STARTUP_PODS
:-}
export
KUBE_ENABLE_CLUSTER_MONITORING
=
${
ENABLE_CLUSTER_MONITORING
:-}
export
KUBE_ENABLE_HORIZONTAL_POD_AUTOSCALER
=
${
ENABLE_HORIZONTAL_POD_AUTOSCALER
:-}
export
KUBE_ENABLE_DEPLOYMENTS
=
${
ENABLE_DEPLOYMENTS
:-}
export
MASTER_SIZE
=
${
MASTER_SIZE
:-}
export
MINION_SIZE
=
${
MINION_SIZE
:-}
export
NUM_MINIONS
=
${
NUM_MINIONS
:-}
...
...
test/e2e/deployment.go
0 → 100644
View file @
d61ed527
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
e2e
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/experimental"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
)
var
_
=
Describe
(
"Deployment"
,
func
()
{
f
:=
NewFramework
(
"deployment"
)
It
(
"deployment should create new pods"
,
func
()
{
testNewDeployment
(
f
)
})
It
(
"deployment should delete old pods and create new ones"
,
func
()
{
testDeploymentDeletesOldPods
(
f
)
})
})
func
testNewDeployment
(
f
*
Framework
)
{
ns
:=
f
.
Namespace
.
Name
c
:=
f
.
Client
deploymentName
:=
"nginx-deployment"
podLabels
:=
map
[
string
]
string
{
"name"
:
"nginx"
}
Logf
(
"Creating simple deployment %s"
,
deploymentName
)
_
,
err
:=
c
.
Deployments
(
ns
)
.
Create
(
&
experimental
.
Deployment
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
deploymentName
,
},
Spec
:
experimental
.
DeploymentSpec
{
Replicas
:
1
,
Selector
:
podLabels
,
UniqueLabelKey
:
"deployment.kubernetes.io/podTemplateHash"
,
Template
:
&
api
.
PodTemplateSpec
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
podLabels
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"nginx"
,
Image
:
"nginx"
,
},
},
},
},
},
})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
defer
func
()
{
Logf
(
"deleting deployment %s"
,
deploymentName
)
Expect
(
c
.
Deployments
(
ns
)
.
Delete
(
deploymentName
,
nil
))
.
NotTo
(
HaveOccurred
())
}()
// Check that deployment is created fine.
deployment
,
err
:=
c
.
Deployments
(
ns
)
.
Get
(
deploymentName
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Logf
(
"Deployment: %s"
,
deployment
)
// Verify that the required pods have come up.
err
=
verifyPods
(
c
,
ns
,
"nginx"
,
false
,
1
)
if
err
!=
nil
{
Logf
(
"error in waiting for pods to come up: %s"
,
err
)
return
}
// DeploymentStatus should be appropriately updated.
deployment
,
err
=
c
.
Deployments
(
ns
)
.
Get
(
deploymentName
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
deployment
.
Status
.
Replicas
)
.
Should
(
Equal
(
1
))
Expect
(
deployment
.
Status
.
UpdatedReplicas
)
.
Should
(
Equal
(
1
))
}
func
testDeploymentDeletesOldPods
(
f
*
Framework
)
{
ns
:=
f
.
Namespace
.
Name
c
:=
f
.
Client
// Create redis pods.
podLabels
:=
map
[
string
]
string
{
"name"
:
"sample-pod"
}
rcName
:=
"redis-controller"
_
,
err
:=
c
.
ReplicationControllers
(
ns
)
.
Create
(
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
rcName
,
},
Spec
:
api
.
ReplicationControllerSpec
{
Replicas
:
1
,
Selector
:
podLabels
,
Template
:
&
api
.
PodTemplateSpec
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
podLabels
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"redis"
,
Image
:
"redis"
,
},
},
},
},
},
})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
defer
func
()
{
Logf
(
"deleting replication controller %s"
,
rcName
)
Expect
(
c
.
ReplicationControllers
(
ns
)
.
Delete
(
rcName
))
.
NotTo
(
HaveOccurred
())
}()
// Verify that the required pods have come up.
err
=
verifyPods
(
c
,
ns
,
"sample-pod"
,
false
,
1
)
if
err
!=
nil
{
Logf
(
"error in waiting for pods to come up: %s"
,
err
)
return
}
// Create a deployment to delete redis pods and instead bring up nginx pods.
deploymentName
:=
"nginx-deployment"
Logf
(
"Creating deployment %s"
,
deploymentName
)
_
,
err
=
c
.
Deployments
(
ns
)
.
Create
(
&
experimental
.
Deployment
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
deploymentName
,
},
Spec
:
experimental
.
DeploymentSpec
{
Replicas
:
1
,
Selector
:
podLabels
,
UniqueLabelKey
:
"deployment.kubernetes.io/podTemplateHash"
,
Template
:
&
api
.
PodTemplateSpec
{
ObjectMeta
:
api
.
ObjectMeta
{
Labels
:
podLabels
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"nginx"
,
Image
:
"nginx"
,
},
},
},
},
},
})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
defer
func
()
{
Logf
(
"deleting deployment %s"
,
deploymentName
)
Expect
(
c
.
Deployments
(
ns
)
.
Delete
(
deploymentName
,
nil
))
.
NotTo
(
HaveOccurred
())
}()
// Verify that the required pods have come up.
verifyPods
(
c
,
ns
,
"nginx"
,
false
,
1
)
// DeploymentStatus should be appropriately updated.
deployment
,
err
:=
c
.
Deployments
(
ns
)
.
Get
(
deploymentName
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
deployment
.
Status
.
Replicas
)
.
Should
(
Equal
(
1
))
Expect
(
deployment
.
Status
.
UpdatedReplicas
)
.
Should
(
Equal
(
1
))
}
test/e2e/resize_nodes.go
View file @
d61ed527
...
...
@@ -226,7 +226,7 @@ func resizeRC(c *client.Client, ns, name string, replicas int) error {
}
func
podsCreated
(
c
*
client
.
Client
,
ns
,
name
string
,
replicas
int
)
(
*
api
.
PodList
,
error
)
{
timeout
:=
time
.
Minute
timeout
:=
2
*
time
.
Minute
// List the pods, making sure we observe all the replicas.
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
name
}))
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
timeout
;
time
.
Sleep
(
5
*
time
.
Second
)
{
...
...
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