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
f0b97b8f
Commit
f0b97b8f
authored
Sep 12, 2016
by
Maciej Szulik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add kubectl run ScheduledJob e2e test
parent
8f4c0bbc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
9 deletions
+52
-9
framework.go
test/e2e/framework/framework.go
+6
-0
kubectl.go
test/e2e/kubectl.go
+39
-2
scheduledjob.go
test/e2e/scheduledjob.go
+7
-7
No files found.
test/e2e/framework/framework.go
View file @
f0b97b8f
...
...
@@ -120,6 +120,12 @@ func NewDefaultFederatedFramework(baseName string) *Framework {
return
f
}
func
NewDefaultGroupVersionFramework
(
baseName
string
,
groupVersion
unversioned
.
GroupVersion
)
*
Framework
{
f
:=
NewDefaultFramework
(
baseName
)
f
.
options
.
GroupVersion
=
&
groupVersion
return
f
}
func
NewFramework
(
baseName
string
,
options
FrameworkOptions
,
client
*
client
.
Client
)
*
Framework
{
f
:=
&
Framework
{
BaseName
:
baseName
,
...
...
test/e2e/kubectl.go
View file @
f0b97b8f
...
...
@@ -171,7 +171,7 @@ func runKubectlRetryOrDie(args ...string) string {
var
_
=
framework
.
KubeDescribe
(
"Kubectl client"
,
func
()
{
defer
GinkgoRecover
()
f
:=
framework
.
NewDefault
Framework
(
"kubectl"
)
f
:=
framework
.
NewDefault
GroupVersionFramework
(
"kubectl"
,
BatchV2Alpha1GroupVersion
)
// Reustable cluster state function. This won't be adversly affected by lazy initialization of framework.
clusterState
:=
func
()
*
framework
.
ClusterVerification
{
...
...
@@ -1073,7 +1073,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
}
containers
:=
job
.
Spec
.
Template
.
Spec
.
Containers
if
containers
==
nil
||
len
(
containers
)
!=
1
||
containers
[
0
]
.
Image
!=
nginxImage
{
framework
.
Failf
(
"Failed creating job %s for 1 pod with expected image %s
"
,
jobName
,
nginxImage
)
framework
.
Failf
(
"Failed creating job %s for 1 pod with expected image %s
: %#v"
,
jobName
,
nginxImage
,
containers
)
}
if
job
.
Spec
.
Template
.
Spec
.
RestartPolicy
!=
api
.
RestartPolicyOnFailure
{
framework
.
Failf
(
"Failed creating a job with correct restart policy for --restart=OnFailure"
)
...
...
@@ -1081,6 +1081,43 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
})
})
framework
.
KubeDescribe
(
"Kubectl run ScheduledJob"
,
func
()
{
var
nsFlag
string
var
sjName
string
BeforeEach
(
func
()
{
nsFlag
=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
sjName
=
"e2e-test-echo-scheduledjob"
})
AfterEach
(
func
()
{
framework
.
RunKubectlOrDie
(
"delete"
,
"scheduledjobs"
,
sjName
,
nsFlag
)
})
It
(
"should create a ScheduledJob"
,
func
()
{
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
ScheduledJobGroupVersionResource
,
f
.
Namespace
.
Name
)
schedule
:=
"*/5 * * * ?"
framework
.
RunKubectlOrDie
(
"run"
,
sjName
,
"--restart=OnFailure"
,
"--generator=scheduledjob/v2alpha1"
,
"--schedule="
+
schedule
,
"--image="
+
busyboxImage
,
nsFlag
)
By
(
"verifying the ScheduledJob "
+
sjName
+
" was created"
)
sj
,
err
:=
c
.
Batch
()
.
ScheduledJobs
(
ns
)
.
Get
(
sjName
)
if
err
!=
nil
{
framework
.
Failf
(
"Failed getting ScheduledJob %s: %v"
,
sjName
,
err
)
}
if
sj
.
Spec
.
Schedule
!=
schedule
{
framework
.
Failf
(
"Failed creating a ScheduledJob with correct schedule %s"
,
schedule
)
}
containers
:=
sj
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
.
Containers
if
containers
==
nil
||
len
(
containers
)
!=
1
||
containers
[
0
]
.
Image
!=
busyboxImage
{
framework
.
Failf
(
"Failed creating ScheduledJob %s for 1 pod with expected image %s: %#v"
,
sjName
,
busyboxImage
,
containers
)
}
if
sj
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
.
RestartPolicy
!=
api
.
RestartPolicyOnFailure
{
framework
.
Failf
(
"Failed creating a ScheduledJob with correct restart policy for --restart=OnFailure"
)
}
})
})
framework
.
KubeDescribe
(
"Kubectl run pod"
,
func
()
{
var
nsFlag
string
var
podName
string
...
...
test/e2e/scheduledjob.go
View file @
f0b97b8f
...
...
@@ -37,16 +37,16 @@ const (
scheduledJobTimeout
=
5
*
time
.
Minute
)
var
(
ScheduledJobGroupVersionResource
=
unversioned
.
GroupVersionResource
{
Group
:
batch
.
GroupName
,
Version
:
"v2alpha1"
,
Resource
:
"scheduledjobs"
}
BatchV2Alpha1GroupVersion
=
unversioned
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v2alpha1"
}
)
var
_
=
framework
.
KubeDescribe
(
"ScheduledJob"
,
func
()
{
options
:=
framework
.
FrameworkOptions
{
ClientQPS
:
20
,
ClientBurst
:
50
,
GroupVersion
:
&
unversioned
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v2alpha1"
},
}
f
:=
framework
.
NewFramework
(
"scheduledjob"
,
options
,
nil
)
f
:=
framework
.
NewDefaultGroupVersionFramework
(
"scheduledjob"
,
BatchV2Alpha1GroupVersion
)
BeforeEach
(
func
()
{
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
unversioned
.
GroupVersionResource
{
Group
:
batch
.
GroupName
,
Version
:
"v2alpha1"
,
Resource
:
"scheduledjobs"
}
,
f
.
Namespace
.
Name
)
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
ScheduledJobGroupVersionResource
,
f
.
Namespace
.
Name
)
})
// multiple jobs running at once
...
...
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