diff --git a/.github/workflows/java8_container_tests.yml b/.github/workflows/java8_container_tests.yml new file mode 100644 index 000000000000..646aed1980f5 --- /dev/null +++ b/.github/workflows/java8_container_tests.yml @@ -0,0 +1,67 @@ +name: Java 8 Container Tests + +# This build runs integration tests using testcontainers +# The user executing the test command must have access to a running docker daemon + +on: [pull_request] + +jobs: + build: + name: "modules: " + + strategy: + fail-fast: false + matrix: + modules: + - >- + alluxio.membership.** + # TODO: update the above + + runs-on: ubuntu-latest + if: "!contains(github.event.pull_request.title, 'DOCFIX') && + !contains(github.event.pull_request.title, 'SKIPCI')" + + steps: + - name: checkout repo + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: '10.11.0' + + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-java11-${{ hashFiles('**/pom.xml') }} + + - name: Cache local Go modules + uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.mod') }} + + - name: Run tests + id: test0 + run: | + mkdir -p ~/.m2 + ALLUXIO_DOCKER_NO_TTY=true \ + ALLUXIO_DOCKER_GIT_CLEAN=true \ + ALLUXIO_DOCKER_ID=0 \ + ALLUXIO_DOCKER_MVN_PROJECT_LIST=dora/tests/testcontainers \ + ALLUXIO_DOCKER_MVN_TESTS=${{ matrix.modules }} \ + dev/github/run_docker.sh + timeout-minutes: 60 + + - name: Archive artifacts + continue-on-error: true + uses: actions/upload-artifact@v3 + if: always() + with: + name: artifact + path: | + **/target/surefire-reports/* + **/target/artifacts/* + **/target/logs/* + retention-days: 7 diff --git a/dora/tests/testcontainers/src/test/java/alluxio/membership/MembershipManagerTest.java b/dora/tests/testcontainers/src/test/java/alluxio/membership/MembershipManagerTest.java index 7da24a5d8493..6c8bc960671f 100644 --- a/dora/tests/testcontainers/src/test/java/alluxio/membership/MembershipManagerTest.java +++ b/dora/tests/testcontainers/src/test/java/alluxio/membership/MembershipManagerTest.java @@ -19,6 +19,7 @@ import alluxio.wire.TieredIdentity; import alluxio.wire.WorkerInfo; import alluxio.wire.WorkerNetAddress; + import eu.rekawek.toxiproxy.model.ToxicDirection; import org.apache.log4j.PropertyConfigurator; import org.junit.After; @@ -47,12 +48,12 @@ import java.util.stream.Collectors; public class MembershipManagerTest { - private static final Network network = Network.newNetwork(); + private static final Network NETWORK = Network.newNetwork(); private static final int ETCD_PORT = 2379; @Rule public TemporaryFolder mFolder = new TemporaryFolder(); - private static ToxiproxyContainer.ContainerProxy etcdProxy; + private static ToxiproxyContainer.ContainerProxy sEtcdProxy; //Add for logging for debugging purpose @BeforeClass @@ -63,44 +64,44 @@ public static void init() { } @ClassRule - public static final GenericContainer etcd = + public static final GenericContainer ETCD_CONTAINER = new GenericContainer<>("quay.io/coreos/etcd:latest") .withCommand("etcd", "--listen-client-urls", "http://0.0.0.0:" + ETCD_PORT, "--advertise-client-urls", "http://0.0.0.0:" + ETCD_PORT) .withExposedPorts(ETCD_PORT) - .withNetwork(network); + .withNetwork(NETWORK); @ClassRule - public static final ToxiproxyContainer toxiproxy = + public static final ToxiproxyContainer TOXIPROXY = new ToxiproxyContainer( "ghcr.io/shopify/toxiproxy:2.5.0") - .withNetwork(network) + .withNetwork(NETWORK) .withNetworkAliases("toxiproxy"); private static List getClientEndpoints() { ArrayList clientEps = new ArrayList<>(); - clientEps.add("https://" + etcd.getHost() + - ":" + etcd.getMappedPort(ETCD_PORT)); + clientEps.add("https://" + ETCD_CONTAINER.getHost() + + ":" + ETCD_CONTAINER.getMappedPort(ETCD_PORT)); return clientEps; } private static List getProxiedClientEndpoints() { ArrayList clientURIs = new ArrayList<>(); clientURIs.add(URI.create( - "https://" + etcdProxy.getContainerIpAddress() + - ":" + etcdProxy.getProxyPort())); + "https://" + sEtcdProxy.getContainerIpAddress() + + ":" + sEtcdProxy.getProxyPort())); return clientURIs; } @BeforeClass public static void beforeAll() throws Exception { - etcdProxy = toxiproxy.getProxy(etcd, ETCD_PORT); + sEtcdProxy = TOXIPROXY.getProxy(ETCD_CONTAINER, ETCD_PORT); } @AfterClass public static void afterAll() { - network.close(); + NETWORK.close(); } @Before @@ -145,7 +146,9 @@ public void testEtcdMembership() throws Exception { membershipManager.join(wkr2); membershipManager.join(wkr3); List wkrs = new ArrayList<>(); - wkrs.add(wkr1); wkrs.add(wkr2); wkrs.add(wkr3); + wkrs.add(wkr1); + wkrs.add(wkr2); + wkrs.add(wkr3); List allMembers = membershipManager.getAllMembers().stream() .sorted(Comparator.comparing(w -> w.getAddress().getHost())) .collect(Collectors.toList()); @@ -220,7 +223,7 @@ public void testFlakyNetwork() throws Exception { MembershipManager healthyMgr = getHealthyEtcdMemberMgr(); System.out.println("All Node Status:\n" + healthyMgr.showAllMembers()); System.out.println("Induce 10 sec latency upstream to etcd..."); - etcdProxy.toxics() + sEtcdProxy.toxics() .latency("latency", ToxicDirection.UPSTREAM, 10000); CommonUtils.waitFor("Workers network errored", () -> { @@ -233,7 +236,7 @@ public void testFlakyNetwork() throws Exception { }, WaitForOptions.defaults().setTimeoutMs(TimeUnit.SECONDS.toMillis(10))); System.out.println("All Node Status:\n" + healthyMgr.showAllMembers()); System.out.println("Remove latency toxics..."); - etcdProxy.toxics().get("latency").remove(); + sEtcdProxy.toxics().get("latency").remove(); CommonUtils.waitFor("Workers network recovered", () -> { try { @@ -254,7 +257,8 @@ public void testStaticMembership() throws Exception { ps.println("worker2"); ps.println("worker3"); Configuration.set(PropertyKey.WORKER_MEMBERSHIP_MANAGER_TYPE, MembershipType.STATIC); - Configuration.set(PropertyKey.WORKER_STATIC_MEMBERSHIP_MANAGER_CONFIG_FILE, file.getAbsolutePath()); + Configuration.set(PropertyKey.WORKER_STATIC_MEMBERSHIP_MANAGER_CONFIG_FILE, + file.getAbsolutePath()); MembershipManager membershipManager = MembershipManager.Factory.create(Configuration.global()); Assert.assertTrue(membershipManager instanceof StaticMembershipManager);