Skip to content

Commit

Permalink
test (gradle-plugin/it): Add Gradle integration test for CronJob
Browse files Browse the repository at this point in the history
Signed-off-by: Anurag Rajawat <[email protected]>
  • Loading branch information
anurag-rajawat committed Apr 3, 2023
1 parent e26358a commit a040dd7
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 2 deletions.
14 changes: 14 additions & 0 deletions gradle-plugin/it/src/it/controller/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ repositories {

kubernetes {
offline = true
enricher {
config {
'jkube-controller' {
schedule = '*/2 * * * *'
}
}
}
images {
image {
name = 'repository/controller:latest'
Expand All @@ -26,6 +33,13 @@ kubernetes {

openshift {
offline = true
enricher {
config {
'jkube-controller' {
schedule = '*/2 * * * *'
}
}
}
images {
image {
name = 'repository/controller:latest'
Expand Down
41 changes: 41 additions & 0 deletions gradle-plugin/it/src/it/controller/expected/cronjob/kubernetes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: batch/v1
kind: CronJob
metadata:
labels:
app: controller
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: controller
spec:
jobTemplate:
spec:
template:
metadata:
labels:
app: controller
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
spec:
containers:
- name: repository-controller
image: repository/controller:latest
imagePullPolicy: IfNotPresent
securityContext:
privileged: false
env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
restartPolicy: OnFailure
schedule: '*/2 * * * *'
37 changes: 37 additions & 0 deletions gradle-plugin/it/src/it/controller/expected/cronjob/openshift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: batch/v1
kind: CronJob
metadata:
labels:
app: controller
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: controller
spec:
jobTemplate:
spec:
template:
metadata:
labels:
app: controller
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
spec:
containers:
- name: repository-controller
image: repository/controller:latest
imagePullPolicy: IfNotPresent
securityContext:
privileged: false
env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
restartPolicy: OnFailure
schedule: '*/2 * * * *'
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class KubernetesConfiguredControllerIT {
private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension();

@ParameterizedTest(name = "k8sResource with {0} configured controller should have {0} in generated resource list")
@ValueSource(strings = { "DaemonSet", "Deployment", "Job", "ReplicaSet", "ReplicationController", "StatefulSet" })
@ValueSource(strings = { "DaemonSet", "Deployment", "Job", "ReplicaSet", "ReplicationController", "StatefulSet", "CronJob" })
void k8sResourceTask_whenRunWithConfiguredControllerType_generatesK8sManifestWithExpectedController(String controllerType) throws IOException, ParseException {
// When
final BuildResult result = gradleRunner.withITProject("controller")
Expand All @@ -45,4 +45,5 @@ void k8sResourceTask_whenRunWithConfiguredControllerType_generatesK8sManifestWit
.contains("Adding revision history limit to 2")
.contains("validating");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OpenShiftConfiguredControllerIT {
private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension();

@ParameterizedTest(name = "ocResource with {0} configured controller should have {0} in generated resource list")
@ValueSource(strings = { "DaemonSet", "Deployment", "Job", "ReplicaSet", "ReplicationController", "StatefulSet" })
@ValueSource(strings = { "DaemonSet", "Deployment", "Job", "ReplicaSet", "ReplicationController", "StatefulSet", "CronJob" })
void ocResourceTask_whenRunWithConfiguredControllerType_generatesOpenShiftManifestWithExpectedController(String controllerType) throws IOException, ParseException {
// When
final BuildResult result = gradleRunner.withITProject("controller")
Expand All @@ -45,4 +45,5 @@ void ocResourceTask_whenRunWithConfiguredControllerType_generatesOpenShiftManife
.contains("Adding revision history limit to 2")
.contains("validating");
}

}

0 comments on commit a040dd7

Please sign in to comment.