Skip to content

Commit

Permalink
Improved ClusterITest - don't remove instances and logs if it failed.
Browse files Browse the repository at this point in the history
- There is a race confition in IMQ and if logs are removed, I can't read them.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Apr 9, 2023
1 parent 489cf9e commit fe88bfd
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import java.io.StringWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.concurrent.atomic.AtomicBoolean;

import org.glassfish.main.itest.tools.GlassFishTestEnvironment;
import org.glassfish.main.itest.tools.asadmin.Asadmin;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand All @@ -52,6 +54,7 @@ public class ClusterITest {
private static final String URL1 = "http://localhost:" + PORT1;
private static final String URL2 = "http://localhost:" + PORT2;
private static final Asadmin ASADMIN = GlassFishTestEnvironment.getAsadmin();
private static final AtomicBoolean INSTANCES_REACHABLE = new AtomicBoolean();


@AfterAll
Expand Down Expand Up @@ -108,25 +111,29 @@ public void checkClusterTest() {
assertThat(ASADMIN.exec("list-instances"), asadminOK());
assertThat(getURL(URL1), stringContainsInOrder("GlassFish Server"));
assertThat(getURL(URL2), stringContainsInOrder("GlassFish Server"));
INSTANCES_REACHABLE.set(true);
}

@Test
@Order(5)
public void stopInstancesTest() {
Assumptions.assumeTrue(INSTANCES_REACHABLE.get());
assertThat(ASADMIN.exec("stop-local-instance", "--kill", INSTANCE_NAME_1), asadminOK());
assertThat(ASADMIN.exec("stop-local-instance", "--kill", INSTANCE_NAME_2), asadminOK());
}

@Test
@Order(6)
public void deleteInstancesTest() {
Assumptions.assumeTrue(INSTANCES_REACHABLE.get());
assertThat(ASADMIN.exec("delete-local-instance", INSTANCE_NAME_1), asadminOK());
assertThat(ASADMIN.exec("delete-local-instance", INSTANCE_NAME_2), asadminOK());
}

@Test
@Order(7)
public void deleteClusterTest() {
Assumptions.assumeTrue(INSTANCES_REACHABLE.get());
assertThat(ASADMIN.exec("delete-cluster", CLUSTER_NAME), asadminOK());
}

Expand Down

0 comments on commit fe88bfd

Please sign in to comment.