Skip to content

Commit

Permalink
checkstyle fix + add new workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyge2022 committed Aug 14, 2023
1 parent 711c201 commit b3007fd
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 16 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/java8_container_tests.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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<String> getClientEndpoints() {
ArrayList<String> 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<URI> getProxiedClientEndpoints() {
ArrayList<URI> 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
Expand Down Expand Up @@ -145,7 +146,9 @@ public void testEtcdMembership() throws Exception {
membershipManager.join(wkr2);
membershipManager.join(wkr3);
List<WorkerInfo> wkrs = new ArrayList<>();
wkrs.add(wkr1); wkrs.add(wkr2); wkrs.add(wkr3);
wkrs.add(wkr1);
wkrs.add(wkr2);
wkrs.add(wkr3);
List<WorkerInfo> allMembers = membershipManager.getAllMembers().stream()
.sorted(Comparator.comparing(w -> w.getAddress().getHost()))
.collect(Collectors.toList());
Expand Down Expand Up @@ -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",
() -> {
Expand All @@ -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 {
Expand All @@ -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);
Expand Down

0 comments on commit b3007fd

Please sign in to comment.