Skip to content

Commit 2bda3c7

Browse files
authored
refactor fabric8 test (#1379)
1 parent fc5ad17 commit 2bda3c7

File tree

6 files changed

+26
-69
lines changed
  • .github/workflows
  • spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/src/test/java/org/springframework/cloud/kubernetes/fabric8/istio
  • spring-cloud-kubernetes-test-support/src/main
    • java/org/springframework/cloud/kubernetes/integration/tests/commons
    • resources/istio-cli/istio-1.16.0/bin

6 files changed

+26
-69
lines changed

.github/workflows/composites/build-integration-tests-project/action.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ runs:
66
- name: build integration tests project without tests
77
shell: bash
88
run: |
9+
10+
cd spring-cloud-kubernetes-test-support
11+
.././mvnw clean install -U
12+
cd ..
13+
914
cd spring-cloud-kubernetes-integration-tests
1015
# build the images, but dont run the tests
1116
.././mvnw -T 1C clean install -DskipTests

.github/workflows/composites/fabric8-istio-integration-test/action.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/maven.yaml

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
env:
1313
TESTCONTAINERS_REUSE_ENABLE: false
14+
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 30
1415
steps:
1516

1617
- name: checkout project
@@ -61,44 +62,12 @@ jobs:
6162
uses: ./.github/workflows/composites/upload-docker-images
6263
if: env.BASE_BRANCH != '2.1.x'
6364

64-
# we need to run some test, so that K3s container is started and then all other instances will re-use this one.
65-
# Otherwise, (since we use static ports) there might be two instances starting at the same time, and ports might conflict
66-
# This does not run on '2.1.x' branch.
67-
fabric8_istio_integration_test:
68-
needs: build
69-
runs-on: ubuntu-latest
70-
71-
steps:
72-
- name: checkout project
73-
uses: actions/checkout@v2
74-
75-
- name: set env variables
76-
uses: ./.github/workflows/composites/env-variables
77-
78-
- name: setup project
79-
uses: ./.github/workflows/composites/setup-jdk17
80-
if: env.BASE_BRANCH == 'main' || env.BASE_BRANCH == '3.0.x'
81-
82-
- name: cache local maven repository
83-
uses: ./.github/workflows/composites/cache
84-
if: env.BASE_BRANCH != '2.1.x'
85-
86-
- name: download docker images
87-
uses: ./.github/workflows/composites/download-docker-images
88-
if: env.BASE_BRANCH != '2.1.x'
89-
90-
- name: echo saved images
91-
uses: ./.github/workflows/composites/echo-saved-images
92-
if: env.BASE_BRANCH != '2.1.x'
93-
94-
- name: integration test fabric8 istio
95-
uses: ./.github/workflows/composites/fabric8-istio-integration-test
96-
if: env.BASE_BRANCH != '2.1.x'
97-
9865
test:
99-
needs: [ build, fabric8_istio_integration_test ]
66+
needs: [ build ]
10067
runs-on: ubuntu-latest
10168
timeout-minutes: 60
69+
env:
70+
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 30
10271

10372
strategy:
10473
fail-fast: true

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/src/test/java/org/springframework/cloud/kubernetes/fabric8/istio/Fabric8IstioIT.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.cloud.kubernetes.fabric8.istio;
1818

19-
import java.io.File;
2019
import java.io.InputStream;
2120
import java.time.Duration;
2221
import java.util.List;
@@ -57,12 +56,6 @@ class Fabric8IstioIT {
5756

5857
private static final String ISTIO_PILOT = "istio/pilot";
5958

60-
private static final String ISTIO_VERSION = "1.16.0";
61-
62-
private static final String LOCAL_ISTIO_BIN_PATH = "../../istio-cli/istio-" + ISTIO_VERSION + "/bin";
63-
64-
private static final String CONTAINER_ISTIO_BIN_PATH = "/tmp/istio/istio-bin/bin/";
65-
6659
private static KubernetesClient client;
6760

6861
private static Util util;
@@ -71,26 +64,24 @@ class Fabric8IstioIT {
7164

7265
@BeforeAll
7366
static void beforeAll() throws Exception {
74-
// Path passed to K3S container must be absolute
75-
String absolutePath = new File(LOCAL_ISTIO_BIN_PATH).getAbsolutePath();
76-
K3S = Commons.container().withFileSystemBind(absolutePath, CONTAINER_ISTIO_BIN_PATH);
67+
K3S = Commons.container();
7768
K3S.start();
7869
util = new Util(K3S);
7970
client = util.client();
8071
Commons.validateImage(IMAGE_NAME, K3S);
8172
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
8273

83-
Commons.pullImage(ISTIO_PROXY, ISTIO_VERSION, K3S);
84-
Commons.loadImage(ISTIO_PROXY, ISTIO_VERSION, "istioproxy", K3S);
85-
Commons.pullImage(ISTIO_PILOT, ISTIO_VERSION, K3S);
86-
Commons.loadImage(ISTIO_PILOT, ISTIO_VERSION, "istiopilot", K3S);
74+
Commons.pullImage(ISTIO_PROXY, Commons.ISTIO_VERSION, K3S);
75+
Commons.loadImage(ISTIO_PROXY, Commons.ISTIO_VERSION, "istioproxy", K3S);
76+
Commons.pullImage(ISTIO_PILOT, Commons.ISTIO_VERSION, K3S);
77+
Commons.loadImage(ISTIO_PILOT, Commons.ISTIO_VERSION, "istiopilot", K3S);
8778

8879
processExecResult(K3S.execInContainer("sh", "-c", "kubectl create namespace istio-test"));
8980
processExecResult(
9081
K3S.execInContainer("sh", "-c", "kubectl label namespace istio-test istio-injection=enabled"));
9182

92-
processExecResult(K3S.execInContainer("sh", "-c", CONTAINER_ISTIO_BIN_PATH + "istioctl"
93-
+ " --kubeconfig=/etc/rancher/k3s/k3s.yaml install --set profile=minimal -y"));
83+
processExecResult(K3S.execInContainer("sh", "-c",
84+
"/tmp/istioctl" + " --kubeconfig=/etc/rancher/k3s/k3s.yaml install --set profile=minimal -y"));
9485

9586
util.setUpIstio(NAMESPACE);
9687

spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/Commons.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.testcontainers.containers.Container;
3939
import org.testcontainers.k3s.K3sContainer;
4040
import org.testcontainers.utility.DockerImageName;
41+
import org.testcontainers.utility.MountableFile;
4142

4243
import org.springframework.core.io.ClassPathResource;
4344
import org.springframework.util.ReflectionUtils;
@@ -56,6 +57,13 @@ public final class Commons {
5657

5758
private static final Log LOG = LogFactory.getLog(Commons.class);
5859

60+
/**
61+
* istio version used in our integration tests.
62+
*/
63+
public static final String ISTIO_VERSION = "1.16.0";
64+
65+
private static final String LOCAL_ISTIO_BIN_PATH = "istio-cli/istio-" + ISTIO_VERSION + "/bin";
66+
5967
private Commons() {
6068
throw new AssertionError("No instance provided");
6169
}
@@ -85,6 +93,8 @@ private Commons() {
8593

8694
private static final K3sContainer CONTAINER = new FixedPortsK3sContainer(DockerImageName.parse(Commons.RANCHER))
8795
.configureFixedPorts(EXPOSED_PORTS).withFileSystemBind(TEMP_FOLDER, TEMP_FOLDER)
96+
.withCopyFileToContainer(MountableFile.forClasspathResource(LOCAL_ISTIO_BIN_PATH + "/istioctl", 0744),
97+
"/tmp/istioctl")
8898
.withCommand(Commons.RANCHER_COMMAND).withReuse(true);
8999

90100
public static K3sContainer container() {

istio-cli/istio-1.16.0/bin/istioctl renamed to spring-cloud-kubernetes-test-support/src/main/resources/istio-cli/istio-1.16.0/bin/istioctl

File renamed without changes.

0 commit comments

Comments
 (0)