Skip to content

Commit

Permalink
Run tests in parallel. (#8050)
Browse files Browse the repository at this point in the history
Enable running tests in parallel.

Remove some unnecessary test setup and tests.
  • Loading branch information
davinchia committed Aug 25, 2023
1 parent da7056e commit fb720c4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
* Workflow state change listener for testing. Used to verify the behavior of event signals in
Expand All @@ -25,7 +26,7 @@ public static void reset() {
@Override
public Queue<ChangedStateEvent> events(final UUID testId) {
if (!events.containsKey(testId)) {
return new LinkedList<>();
return new ConcurrentLinkedQueue<>();
}

return events.get(testId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,10 @@
import io.airbyte.test.utils.TestConnectionCreate;
import java.io.IOException;
import java.net.URISyntaxException;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
Expand Down Expand Up @@ -121,21 +118,14 @@ static void end() {
testHarness.stopDbAndContainers();
}

@BeforeEach
void setup() throws URISyntaxException, IOException, SQLException {
testHarness.setup();
}

@AfterEach
void tearDown() {
testHarness.cleanup();
}

@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
@Test
@RetryingTest(3)
void testManualSync() throws Exception {
testHarness.setup();

final UUID sourceId = testHarness.createPostgresSource().getSourceId();
final UUID destinationId = testHarness.createPostgresDestination().getDestinationId();

final SourceDiscoverSchemaRead discoverResult = testHarness.discoverSourceSchemaWithId(sourceId);
final AirbyteCatalog catalog = discoverResult.getCatalog();
final SyncMode syncMode = SyncMode.FULL_REFRESH;
Expand All @@ -153,8 +143,9 @@ void testManualSync() throws Exception {
waitForSuccessfulJob(apiClient.getJobsApi(), connectionSyncRead.getJob());
Asserts.assertSourceAndDestinationDbRawRecordsInSync(testHarness.getSourceDatabase(), testHarness.getDestinationDatabase(), PUBLIC_SCHEMA_NAME,
conn.getNamespaceFormat(), false, false);
Asserts.assertStreamStatuses(apiClient, workspaceId, conn.getConnectionId(), connectionSyncRead, StreamStatusRunState.COMPLETE,
StreamStatusJobType.SYNC);
Asserts.assertStreamStatuses(apiClient, workspaceId, connectionId, connectionSyncRead, StreamStatusRunState.COMPLETE, StreamStatusJobType.SYNC);

testHarness.cleanup();
}

@RetryingTest(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
import io.airbyte.api.client2.model.generated.SourceDefinitionCreate;
import io.airbyte.api.client2.model.generated.SourceDefinitionIdRequestBody;
import io.airbyte.api.client2.model.generated.SourceDefinitionRead;
import io.airbyte.test.utils.AcceptanceTestHarness;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.sql.SQLException;
import java.time.Duration;
import java.util.UUID;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import okhttp3.OkHttpClient;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -37,30 +34,17 @@ class VersioningAcceptanceTests {
private static AirbyteApiClient2 apiClient2;
private static UUID workspaceId;

private static AcceptanceTestHarness testHarness;

@BeforeAll
static void init() throws URISyntaxException, IOException, InterruptedException {
testHarness = new AcceptanceTestHarness(null, workspaceId);
RetryPolicy<okhttp3.Response> policy = RetryPolicy.ofDefaults();
apiClient2 = new AirbyteApiClient2("http://localhost:8001/api", policy);

workspaceId = apiClient2.getWorkspaceApi().listWorkspaces().getWorkspaces().get(0).getWorkspaceId();
}
static void init() throws IOException {
RetryPolicy<okhttp3.Response> policy = RetryPolicy.<okhttp3.Response>builder()
.handle(Throwable.class)
.withMaxAttempts(5)
.withBackoff(Duration.ofSeconds(1), Duration.ofSeconds(10)).build();

@AfterAll
static void afterAll() {
testHarness.stopDbAndContainers();
}

@BeforeEach
void setup() throws SQLException, URISyntaxException, IOException {
testHarness.setup();
}
OkHttpClient client = new OkHttpClient.Builder().readTimeout(Duration.ofSeconds(20)).build();
apiClient2 = new AirbyteApiClient2("http://localhost:8001/api", policy, client);

@AfterEach
void tearDown() {
testHarness.cleanup();
workspaceId = apiClient2.getWorkspaceApi().listWorkspaces().getWorkspaces().get(0).getWorkspaceId();
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#junit.jupiter.execution.parallel.enabled=true
#junit.jupiter.execution.parallel.mode.classes.default=concurrent
junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.mode.classes.default=concurrent

0 comments on commit fb720c4

Please sign in to comment.