-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#395 Upgrade IT infrastructure for JDK 17
Update it test dockerfile to use jdk17 Update it helm Tiltfile to be up to date with recent V2 chart changes Correct IT jar shading and copy Added migration to update test docker JDK
- Loading branch information
1 parent
0a0c902
commit e78342c
Showing
18 changed files
with
182 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
foundation/foundation-mda/src/main/resources/templates/integration-test/it.pipeline.spec.vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
@pipeline | ||
Feature: Run Spark Operator job | ||
Feature: Example feature file | ||
Generated sample BDD specification/feature file - PLEASE ***DO*** MODIFY. | ||
|
||
Scenario: Executes a pipeline | ||
When the job is triggered | ||
Then the pipeline is executed | ||
Scenario: Update me | ||
Given a precondition | ||
When an action occurs | ||
Then a postcondition results |
119 changes: 17 additions & 102 deletions
119
foundation/foundation-mda/src/main/resources/templates/integration-test/it.pipeline.steps.vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,42 @@ | ||
package ${basePackage}.tests; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.cucumber.java.After; | ||
import io.cucumber.java.Before; | ||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.Pod; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.KubernetesClientBuilder; | ||
import io.fabric8.kubernetes.client.informers.ResourceEventHandler; | ||
import org.junit.Assert; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class PipelineSteps { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(PipelineSteps.class); | ||
List<File> listOfFiles = new ArrayList<>(); | ||
Boolean jobRequestFailed; | ||
List<Pod> podList; | ||
List<HasMetadata> hasMetadata; | ||
|
||
@Before("@pipeline") | ||
public void setup() { | ||
this.jobRequestFailed = false; | ||
this.podList = new ArrayList<>(); | ||
this.hasMetadata = new ArrayList<>(); | ||
} | ||
|
||
@After("@pipeline") | ||
public void cleanup() { | ||
} | ||
|
||
@When("the job is triggered") | ||
public void theJobIsTriggered() throws IOException, InterruptedException { | ||
getFiles(); | ||
} | ||
|
||
@Then("the pipeline is executed") | ||
public void thePipelineIsExecuted() { | ||
Assert.assertTrue(String.format("Pod list size should be greater than %d", podList.size()), podList.size() > 0); | ||
} | ||
|
||
private void getFiles() throws IOException, InterruptedException { | ||
|
||
File dir = new File("./pipelines"); | ||
addFilesForFolder(dir); | ||
|
||
logger.info(String.format("Got %d application.yaml file(s) to process", listOfFiles.size())); | ||
|
||
for (File file : listOfFiles) { | ||
|
||
try (KubernetesClient client = new KubernetesClientBuilder().build()) { | ||
|
||
//Initializing Informer | ||
this.initializeInformer(client); | ||
|
||
List<HasMetadata> metadata = client | ||
.load(new FileInputStream(file)) | ||
.get(); | ||
|
||
this.hasMetadata.addAll(metadata); | ||
logger.info(String.format("has meta data size is %d", hasMetadata.size())); | ||
|
||
//Creating/Replacing resource here | ||
metadata.forEach(o -> logger.info("Creating resource " + o.getMetadata().getName())); | ||
client.resourceList(metadata).inNamespace("default").createOrReplace(); | ||
TimeUnit.MINUTES.sleep(2); | ||
|
||
} | ||
} | ||
} | ||
|
||
private void initializeInformer(KubernetesClient client) { | ||
|
||
client.pods().inNamespace("default").inform(new ResourceEventHandler<>() { | ||
|
||
@Override | ||
public void onAdd(Pod pod) { | ||
addToPodList(pod); | ||
} | ||
|
||
@Override | ||
public void onUpdate(Pod oldPod, Pod newPod) { | ||
addToPodList(oldPod); | ||
} | ||
|
||
@Override | ||
public void onDelete(Pod pod, boolean deletedFinalStateUnknown) { | ||
addToPodList(pod); | ||
} | ||
|
||
}, 30 * 1000L); | ||
|
||
logger.info("Informer initialized."); | ||
@Given("a precondition") | ||
public void a_precondition() { | ||
// code the items you need before performing your action | ||
} | ||
|
||
|
||
private void addFilesForFolder(final File folder) { | ||
for (final File fileEntry : Objects.requireNonNull(folder.listFiles())) { | ||
if (fileEntry.isDirectory()) { | ||
addFilesForFolder(fileEntry); | ||
} else { | ||
listOfFiles.add(fileEntry); | ||
} | ||
} | ||
@When("an action occurs") | ||
public void an_action_occurs() { | ||
// execute your action | ||
} | ||
|
||
private void addToPodList(Pod pod) { | ||
|
||
boolean anyMatch = this.hasMetadata.stream().anyMatch(o -> pod.getMetadata().getName().contains(o.getMetadata().getName())); | ||
if (anyMatch) { | ||
logger.info("Pod " + pod.getMetadata().getName() + " added to pod list"); | ||
this.podList.add(pod); | ||
} | ||
@Then("a postcondition results") | ||
public void a_postcondition_results() { | ||
// check for expected postconditions - continue to use normal assert pattern within tests | ||
assertTrue(true); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
...n/foundation-mda/src/main/resources/templates/integration-test/it.values.pipeline.yaml.vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
#set ($index = $artifactId.indexOf('-tests')) | ||
#set ($parentArtifactId = $artifactId.substring(0, $index)) | ||
|
||
deployment: | ||
command: '[ "java" ]' | ||
args: '[ "-jar", "${artifactId}.jar" ]' | ||
args: '[ "-jar", "${parentArtifactId}-tests-docker.jar" ]' | ||
initContainers: | ||
- name: wait-for-spark-operator | ||
image: busybox:latest | ||
command: [ "/bin/sh","-c" ] | ||
args: [ "until nc -vz spark-operator-webhook.default 443; do sleep 5; echo 'waiting for spark operator...'; done" ] | ||
args: [ "until nc -vz spark-operator-webhook-svc.default 443; do sleep 5; echo 'waiting for spark operator...'; done" ] | ||
- name: wait-for-spark-thrift-service | ||
image: busybox:latest | ||
command: [ "/bin/sh","-c" ] | ||
args: [ "until nc -vz thrift-server.default 10001; do sleep 5; echo 'waiting for spark thrift service...'; done" ] |
7 changes: 5 additions & 2 deletions
7
foundation/foundation-mda/src/main/resources/templates/integration-test/it.values.yaml.vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#set ($index = $artifactId.indexOf('-tests')) | ||
#set ($parentArtifactId = $artifactId.substring(0, $index)) | ||
|
||
image: | ||
name: boozallen/${artifactId} | ||
name: ${parentArtifactId}-tests-docker | ||
imagePullPolicy: IfNotPresent | ||
dockerRepo: "" | ||
dockerRepo: "" |
44 changes: 44 additions & 0 deletions
44
...m/boozallen/aissemble/upgrade/migration/v1_10_0/ItInfrastructureJavaUpgradeMigration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.boozallen.aissemble.upgrade.migration.v1_10_0; | ||
|
||
/*- | ||
* #%L | ||
* aiSSEMBLE::Foundation::Upgrade | ||
* %% | ||
* Copyright (C) 2021 Booz Allen | ||
* %% | ||
* This software package is licensed under the Booz Allen Public License. All Rights Reserved. | ||
* #L% | ||
*/ | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
import org.technologybrewery.baton.BatonException; | ||
|
||
import com.boozallen.aissemble.upgrade.migration.AbstractAissembleMigration; | ||
|
||
public class ItInfrastructureJavaUpgradeMigration extends AbstractAissembleMigration { | ||
private static final String OLD_JDK_VERSION = "FROM openjdk:11-slim"; | ||
private static final String NEW_JDK_VERSION = "FROM openjdk:17-jdk-slim"; | ||
|
||
@Override | ||
protected boolean shouldExecuteOnFile(File file) { | ||
try { | ||
return (Files.readString(file.toPath()).contains(OLD_JDK_VERSION)); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
protected boolean performMigration(File file) { | ||
try { | ||
Files.writeString(file.toPath(), Files.readString(file.toPath()) | ||
.replace(OLD_JDK_VERSION, NEW_JDK_VERSION)); | ||
return true; | ||
} catch (IOException e) { | ||
throw new BatonException("Failed to update Dockerfile parent image", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.