mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
attempt to make preAllocation job deletion more certain (#5708)
fix issue with deallocate during build phase fix test report URL
This commit is contained in:
parent
deed4e9763
commit
01c1e4bc17
4
.ci/dev/smoke/Jenkinsfile
vendored
4
.ci/dev/smoke/Jenkinsfile
vendored
@ -60,7 +60,7 @@ pipeline {
|
||||
pullRequest.createStatus(status: 'success',
|
||||
context: 'continuous-integration/jenkins/pr-merge/smokeTest',
|
||||
description: 'Smoke Tests Passed',
|
||||
targetUrl: "${env.JOB_URL}testResults")
|
||||
targetUrl: "${env.BUILD_URL}testResults")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ pipeline {
|
||||
pullRequest.createStatus(status: 'failure',
|
||||
context: 'continuous-integration/jenkins/pr-merge/smokeTest',
|
||||
description: 'Smoke Tests Failed',
|
||||
targetUrl: "${env.JOB_URL}testResults")
|
||||
targetUrl: "${env.BUILD_URL}testResults")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,7 @@ class DistributedTesting implements Plugin<Project> {
|
||||
//modify the image building task to depend on the preAllocate task (if specified on the command line) - this prevents gradle running out of order
|
||||
if (preAllocateTask.name in requestedTaskNames) {
|
||||
imageBuildTask.dependsOn preAllocateTask
|
||||
imagePushTask.finalizedBy(deAllocateTask)
|
||||
}
|
||||
|
||||
def userDefinedParallelTask = project.rootProject.tasks.create("userDefined" + testGrouping.getName().capitalize(), KubesTest) {
|
||||
@ -171,7 +172,8 @@ class DistributedTesting implements Plugin<Project> {
|
||||
Task deAllocateTask = project.rootProject.tasks.create("deAllocateFor" + testGrouping.getName().capitalize()) {
|
||||
group = GRADLE_GROUP
|
||||
doFirst {
|
||||
String dockerTag = System.getProperty(ImageBuilding.PROVIDE_TAG_FOR_RUNNING_PROPERTY)
|
||||
String dockerTag = System.getProperty(ImageBuilding.PROVIDE_TAG_FOR_RUNNING_PROPERTY) ?:
|
||||
System.getProperty(ImageBuilding.PROVIDE_TAG_FOR_BUILDING_PROPERTY)
|
||||
if (dockerTag == null) {
|
||||
throw new GradleException("pre allocation cannot be used without a stable docker tag - please provide one using -D" + ImageBuilding.PROVIDE_TAG_FOR_RUNNING_PROPERTY)
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.corda.testing;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.Pod;
|
||||
import io.fabric8.kubernetes.api.model.Quantity;
|
||||
import io.fabric8.kubernetes.api.model.batch.Job;
|
||||
import io.fabric8.kubernetes.api.model.batch.JobBuilder;
|
||||
@ -39,36 +38,38 @@ public class PodAllocator {
|
||||
|
||||
public void allocatePods(Integer number, Integer coresPerPod, Integer memoryPerPod, String prefix) {
|
||||
|
||||
Config config = new ConfigBuilder()
|
||||
.withConnectionTimeout(CONNECTION_TIMEOUT)
|
||||
.withRequestTimeout(CONNECTION_TIMEOUT)
|
||||
.withRollingTimeout(CONNECTION_TIMEOUT)
|
||||
.withWebsocketTimeout(CONNECTION_TIMEOUT)
|
||||
.withWebsocketPingInterval(CONNECTION_TIMEOUT)
|
||||
.build();
|
||||
|
||||
Config config = getConfig();
|
||||
KubernetesClient client = new DefaultKubernetesClient(config);
|
||||
|
||||
List<Job> podsToRequest = IntStream.range(0, number).mapToObj(i -> buildJob("pa-" + prefix + i, coresPerPod, memoryPerPod)).collect(Collectors.toList());
|
||||
podsToRequest.forEach(requestedJob -> {
|
||||
List<Job> createdJobs = podsToRequest.stream().map(requestedJob -> {
|
||||
String msg = "PreAllocating " + requestedJob.getMetadata().getName();
|
||||
if (logger instanceof org.gradle.api.logging.Logger) {
|
||||
((org.gradle.api.logging.Logger) logger).quiet(msg);
|
||||
} else {
|
||||
logger.info(msg);
|
||||
}
|
||||
client.batch().jobs().inNamespace(KubesTest.NAMESPACE).create(requestedJob);
|
||||
});
|
||||
return client.batch().jobs().inNamespace(KubesTest.NAMESPACE).create(requestedJob);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
KubernetesClient tearDownClient = new DefaultKubernetesClient(getConfig());
|
||||
tearDownClient.batch().jobs().delete(createdJobs);
|
||||
}));
|
||||
}
|
||||
|
||||
public void tearDownPods(String prefix) {
|
||||
io.fabric8.kubernetes.client.Config config = new io.fabric8.kubernetes.client.ConfigBuilder()
|
||||
private Config getConfig() {
|
||||
return new ConfigBuilder()
|
||||
.withConnectionTimeout(CONNECTION_TIMEOUT)
|
||||
.withRequestTimeout(CONNECTION_TIMEOUT)
|
||||
.withRollingTimeout(CONNECTION_TIMEOUT)
|
||||
.withWebsocketTimeout(CONNECTION_TIMEOUT)
|
||||
.withWebsocketPingInterval(CONNECTION_TIMEOUT)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void tearDownPods(String prefix) {
|
||||
io.fabric8.kubernetes.client.Config config = getConfig();
|
||||
KubernetesClient client = new DefaultKubernetesClient(config);
|
||||
Stream<Job> jobsToDelete = client.batch().jobs().inNamespace(KubesTest.NAMESPACE).list()
|
||||
.getItems()
|
||||
|
Loading…
Reference in New Issue
Block a user