Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test (gradle-plugin/it): Add Gradle integration test for CronJob #2121

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 * * * *'
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");
}

}