Fix wiremock in fabric8 tests

This commit is contained in:
Ryan Baxter
2022-06-10 06:02:56 -04:00
parent e822e22393
commit 4a9fcd735e
3 changed files with 19 additions and 1 deletions

View File

@@ -157,6 +157,9 @@ class Fabric8DiscoveryIT {
try {
Deployment deployment = client.apps().deployments().load(getMockDeployment()).get();
String[] image = K8SUtils.getImageFromDeployment(deployment).split(":");
Commons.pullImage(image[0], image[1], K3S);
Commons.loadImage(image[0], image[1], "wiremock", K3S);
client.apps().deployments().inNamespace(NAMESPACE).create(deployment);
mockDeploymentName = deployment.getMetadata().getName();
mockDeploymentImage = deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage();

View File

@@ -215,6 +215,9 @@ public class Fabric8ClientLoadbalancerIT {
try {
Deployment deployment = client.apps().deployments().load(getMockDeployment()).get();
String[] image = K8SUtils.getImageFromDeployment(deployment).split(":");
Commons.pullImage(image[0], image[1], K3S);
Commons.loadImage(image[0], image[1], "wiremock", K3S);
client.apps().deployments().inNamespace(NAMESPACE).create(deployment);
mockDeploymentName = deployment.getMetadata().getName();

View File

@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
@@ -352,7 +353,7 @@ public class K8SUtils {
}
/**
* Gets the image from the deployment yaml. Assumes there is only one container
* Gets the image from a Kubernetes Client deployment yaml. Assumes there is only one container
* defined in the deployment.
* @param deployment deployment yaml
* @return An array where the first item is the mage name and the second item is the
@@ -362,6 +363,17 @@ public class K8SUtils {
return deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage();
}
/**
* Gets the image from a Fabric8 deployment yaml. Assumes there is only one container
* defined in the deployment.
* @param deployment deployment yaml
* @return An array where the first item is the mage name and the second item is the
* tag
*/
public static String getImageFromDeployment(Deployment deployment) {
return deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage();
}
private void innerDeployWiremock(String namespace, boolean rootPath, K3sContainer container) throws Exception {
V1Deployment deployment = getWiremockDeployment();
String[] image = getImageFromDeployment(deployment).split(":");