Fix 1634 (#1635)
This commit is contained in:
@@ -77,12 +77,19 @@ class Fabric8IstioIT {
|
||||
processExecResult(
|
||||
K3S.execInContainer("sh", "-c", "kubectl label namespace istio-test istio-injection=enabled"));
|
||||
|
||||
util.setUpIstioctl(NAMESPACE, Phase.CREATE);
|
||||
|
||||
String istioctlPodName = istioctlPodName();
|
||||
K3S.execInContainer("sh", "-c",
|
||||
"kubectl cp istio-test/" + istioctlPodName + ":/usr/local/bin/istioctl /tmp/istioctl");
|
||||
K3S.execInContainer("sh", "-c", "chmod +x /tmp/istioctl");
|
||||
|
||||
processExecResult(K3S.execInContainer("sh", "-c",
|
||||
"/tmp/istioctl" + " --kubeconfig=/etc/rancher/k3s/k3s.yaml install --set profile=minimal -y"));
|
||||
|
||||
util.setUpIstio(NAMESPACE);
|
||||
|
||||
manifests(Phase.CREATE);
|
||||
appManifests(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@@ -94,7 +101,8 @@ class Fabric8IstioIT {
|
||||
|
||||
@AfterAll
|
||||
static void after() {
|
||||
manifests(Phase.DELETE);
|
||||
appManifests(Phase.DELETE);
|
||||
util.setUpIstioctl(NAMESPACE, Phase.DELETE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,7 +117,7 @@ class Fabric8IstioIT {
|
||||
Assertions.assertTrue(result.contains("istio"));
|
||||
}
|
||||
|
||||
private static void manifests(Phase phase) {
|
||||
private static void appManifests(Phase phase) {
|
||||
|
||||
InputStream deploymentStream = util.inputStream("istio-deployment.yaml");
|
||||
InputStream serviceStream = util.inputStream("istio-service.yaml");
|
||||
@@ -136,4 +144,16 @@ class Fabric8IstioIT {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
private static String istioctlPodName() {
|
||||
try {
|
||||
return K3S
|
||||
.execInContainer("sh", "-c",
|
||||
"kubectl get pods -n istio-test -l app=istio-ctl -o=name --no-headers | tr -d '\n'")
|
||||
.getStdout().split("/")[1];
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.containers.Container;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import org.testcontainers.utility.DockerImageName;
|
||||
import org.testcontainers.utility.MountableFile;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -93,8 +92,6 @@ public final class Commons {
|
||||
|
||||
private static final K3sContainer CONTAINER = new FixedPortsK3sContainer(DockerImageName.parse(Commons.RANCHER))
|
||||
.configureFixedPorts(EXPOSED_PORTS).withFileSystemBind(TEMP_FOLDER, TEMP_FOLDER)
|
||||
.withCopyFileToContainer(MountableFile.forClasspathResource(LOCAL_ISTIO_BIN_PATH + "/istioctl", 0744),
|
||||
"/tmp/istioctl")
|
||||
.withCommand(Commons.RANCHER_COMMAND).withReuse(true);
|
||||
|
||||
public static K3sContainer container() {
|
||||
|
||||
@@ -42,6 +42,7 @@ import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
|
||||
import io.fabric8.kubernetes.client.dsl.base.PatchContext;
|
||||
import io.fabric8.kubernetes.client.dsl.base.PatchType;
|
||||
import io.fabric8.kubernetes.client.utils.Serialization;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -79,7 +80,7 @@ public final class Util {
|
||||
* tight as possible, providing reasonable defaults.
|
||||
*
|
||||
*/
|
||||
public void createAndWait(String namespace, String name, @Nullable Deployment deployment, Service service,
|
||||
public void createAndWait(String namespace, String name, @Nullable Deployment deployment, @Nullable Service service,
|
||||
@Nullable Ingress ingress, boolean changeVersion) {
|
||||
try {
|
||||
|
||||
@@ -100,7 +101,9 @@ public final class Util {
|
||||
waitForDeployment(namespace, deployment);
|
||||
}
|
||||
|
||||
client.services().inNamespace(namespace).resource(service).create();
|
||||
if (service != null) {
|
||||
client.services().inNamespace(namespace).resource(service).create();
|
||||
}
|
||||
|
||||
if (ingress != null) {
|
||||
client.network().v1().ingresses().inNamespace(namespace).resource(ingress).create();
|
||||
@@ -248,6 +251,18 @@ public final class Util {
|
||||
innerSetup(namespace, serviceAccountAsStream, roleBindingAsStream, roleAsStream);
|
||||
}
|
||||
|
||||
public void setUpIstioctl(String namespace, Phase phase) {
|
||||
InputStream istioctlDeploymentStream = inputStream("istio/istioctl-deployment.yaml");
|
||||
Deployment istioctlDeployment = Serialization.unmarshal(istioctlDeploymentStream, Deployment.class);
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
createAndWait(namespace, null, istioctlDeployment, null, null, false);
|
||||
}
|
||||
else {
|
||||
deleteAndWait(namespace, istioctlDeployment, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void waitForConfigMap(String namespace, ConfigMap configMap, Phase phase) {
|
||||
String configMapName = configMapName(configMap);
|
||||
await().pollInterval(Duration.ofSeconds(1)).atMost(600, TimeUnit.SECONDS).until(() -> {
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: istio-ctl
|
||||
labels:
|
||||
app: istio-ctl
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: istio-ctl
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: istio-ctl
|
||||
spec:
|
||||
containers:
|
||||
- name: istio-ctl
|
||||
image: istio/istioctl:1.20.5
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: [ "/bin/bash" ]
|
||||
args: [ "-c", "trap : TERM INT; sleep infinity & wait" ]
|
||||
Reference in New Issue
Block a user