Skip to content

Commit

Permalink
Cleanup in integration tests utilities 3 (#1767)
Browse files Browse the repository at this point in the history
* clean

* clean

* clean

* clean

* clean
  • Loading branch information
wind57 authored Oct 16, 2024
1 parent e500c43 commit 0900b73
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ static void after() throws Exception {

manifests(Phase.DELETE);
Commons.cleanUp(IMAGE_NAME, K3S);
Commons.systemPrune();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ static void beforeAll() throws Exception {
static void afterAll() throws Exception {
util.deleteNamespace("istio-system");
Commons.cleanUp(IMAGE_NAME, K3S);
Commons.systemPrune();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ static void afterAll() throws Exception {
util.deleteNamespace("left");
util.deleteNamespace("right");
Commons.cleanUp(IMAGE_NAME, K3S);
Commons.systemPrune();

manifests(Phase.DELETE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ static void afterAll() {
util.deleteNamespace(NAMESPACE_A);
util.deleteNamespace(NAMESPACE_B);
app(Phase.DELETE);
Commons.systemPrune();
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ static void beforeAll() throws Exception {
static void afterAll() throws Exception {
configWatcher(Phase.DELETE);
Commons.cleanUp(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
Commons.systemPrune();
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ static void afterAll() throws Exception {
util.deleteNamespace(LEFT_NAMESPACE);
util.deleteNamespace(RIGHT_NAMESPACE);
Commons.cleanUp(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
Commons.systemPrune();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ static void afterAll() throws Exception {

discoveryServer(Phase.DELETE);
discoveryClient(Phase.DELETE);
Commons.systemPrune();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ static void beforeAll() throws Exception {
static void afterAll() throws Exception {
manifests(Phase.DELETE);
Commons.cleanUp(IMAGE_NAME, K3S);
Commons.systemPrune();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ static void afterAll() throws Exception {
util.deleteNamespace(NAMESPACE_A);
util.deleteNamespace(NAMESPACE_B);
manifests(Phase.DELETE);
Commons.systemPrune();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ static void afterAll() throws Exception {
Commons.cleanUp(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
Commons.cleanUp(CONFIG_WATCHER_APP_A_IMAGE, K3S);
Commons.cleanUp(CONFIG_WATCHER_APP_B_IMAGE, K3S);
Commons.systemPrune();
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ static void afterAll() throws Exception {
Commons.cleanUp(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
Commons.cleanUp(CONFIG_WATCHER_APP_A_IMAGE, K3S);
Commons.cleanUp(CONFIG_WATCHER_APP_B_IMAGE, K3S);
Commons.systemPrune();
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ static void afterAll() throws Exception {
util.deleteNamespace("left");
util.deleteNamespace("right");
Commons.cleanUp(IMAGE_NAME, K3S);
Commons.systemPrune();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ static void setup() throws Exception {
static void afterAll() throws Exception {
configK8sClientIt(Phase.DELETE);
Commons.cleanUp(IMAGE_NAME, K3S);
Commons.systemPrune();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static void load(K3sContainer container, String tarName, String imageName
.findFirst();
if (found.isPresent()) {
LOG.info("running in github actions, will load from : " + TMP_IMAGES + " tar : " + found.get());
Commons.loadImageFromPath(found.get(), container);
loadImageFromPath(found.get(), container);
return;
}
else {
Expand All @@ -174,8 +174,8 @@ public static void load(K3sContainer container, String tarName, String imageName
try {
LOG.info("no tars found, will resort to pulling the image");
LOG.info("using : " + imageVersion + " for : " + imageNameForDownload);
Commons.pullImage(imageNameForDownload, imageVersion, container);
Commons.loadImage(imageNameForDownload, imageVersion, tarName, container);
pullImage(imageNameForDownload, imageVersion, container);
loadImage(imageNameForDownload, imageVersion, tarName, container);
}
catch (Exception e) {
throw new RuntimeException(e);
Expand All @@ -198,10 +198,6 @@ public static void cleanUp(String image, K3sContainer container) throws Exceptio
container.execInContainer("rm", TEMP_FOLDER + "/" + image + ".tar");
}

public static void cleanUpDownloadedImage(String image) throws Exception {
CONTAINER.execInContainer("crictl", "rmi", image);
}

/**
* validates that the provided image does exist in the local docker registry.
*/
Expand Down Expand Up @@ -232,19 +228,6 @@ public static String processExecResult(Container.ExecResult execResult) {
return execResult.getStdout();
}

/**
* equivalent of 'docker system prune', but for crictl.
*/
public static void systemPrune() {
try {
CONTAINER.execInContainer("sh", "-c",
"crictl ps -a | grep -v Running | awk '{print $1}' | xargs crictl rm && crictl rmi --prune");
}
catch (Exception e) {
throw new RuntimeException(e);
}
}

public static String pomVersion() {
try (InputStream in = new ClassPathResource(KUBERNETES_VERSION_FILE).getInputStream()) {
String version = StreamUtils.copyToString(in, StandardCharsets.UTF_8);
Expand Down

0 comments on commit 0900b73

Please sign in to comment.