-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run container orchestrator acceptance tests #13699
Merged
lmossman
merged 5 commits into
master
from
lmossman/run-container-orchestrator-acceptance-tests
Jul 8, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fcd13bc
Add CONTAINER_ORCHESTRATOR=true flag to kube acceptance tests
lmossman 3192a4a
Add CONTAINER_ORCHESTRATOR=true flag to GKE acceptance tests too
lmossman 9407892
fix downtime test
lmossman 1b16b90
fix the other orchestrator tests
lmossman 2309de2
move container orchestrator acceptance tests to their own class
lmossman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,6 @@ | |
import io.airbyte.api.client.model.generated.SyncMode; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.commons.lang.MoreBooleans; | ||
import io.airbyte.container_orchestrator.ContainerOrchestratorApp; | ||
import io.airbyte.test.utils.AirbyteAcceptanceTestHarness; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import java.io.IOException; | ||
|
@@ -50,11 +49,7 @@ | |
import java.sql.SQLException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.Future; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
|
@@ -63,12 +58,9 @@ | |
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestMethodOrder; | ||
import org.junit.jupiter.api.Timeout; | ||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; | ||
import org.junitpioneer.jupiter.RetryingTest; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.slf4j.MDC; | ||
|
||
/** | ||
* The class test for advanced platform functionality that can be affected by the networking | ||
|
@@ -306,208 +298,4 @@ public void testBackpressure() throws Exception { | |
} | ||
} | ||
|
||
@RetryingTest(3) | ||
@Order(5) | ||
@EnabledIfEnvironmentVariable(named = "CONTAINER_ORCHESTRATOR", | ||
matches = "true") | ||
public void testDowntimeDuringSync() throws Exception { | ||
final String connectionName = "test-connection"; | ||
final UUID sourceId = testHarness.createPostgresSource().getSourceId(); | ||
final UUID destinationId = testHarness.createDestination().getDestinationId(); | ||
final AirbyteCatalog catalog = testHarness.discoverSourceSchema(sourceId); | ||
final SyncMode syncMode = SyncMode.FULL_REFRESH; | ||
final DestinationSyncMode destinationSyncMode = DestinationSyncMode.OVERWRITE; | ||
catalog.getStreams().forEach(s -> s.getConfig().syncMode(syncMode).destinationSyncMode(destinationSyncMode)); | ||
|
||
for (final var input : List.of("KILL_BOTH_NON_SYNC_SLIGHTLY_FIRST", "KILL_ONLY_SYNC", "KILL_ONLY_NON_SYNC")) { | ||
LOGGER.info("Checking " + input); | ||
|
||
final UUID connectionId = | ||
testHarness.createConnection(connectionName, sourceId, destinationId, List.of(), catalog, null).getConnectionId(); | ||
|
||
JobInfoRead connectionSyncRead = null; | ||
|
||
while (connectionSyncRead == null) { | ||
|
||
try { | ||
connectionSyncRead = apiClient.getConnectionApi().syncConnection(new ConnectionIdRequestBody().connectionId(connectionId)); | ||
} catch (final Exception e) { | ||
LOGGER.error("retrying after error", e); | ||
} | ||
} | ||
|
||
Thread.sleep(10000); | ||
|
||
switch (input) { | ||
case "KILL_BOTH_NON_SYNC_SLIGHTLY_FIRST" -> { | ||
LOGGER.info("Scaling down both workers at roughly the same time..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(0); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-sync-worker").scale(0, true); | ||
|
||
LOGGER.info("Scaling up both workers..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(1); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-sync-worker").scale(1); | ||
} | ||
case "KILL_ONLY_SYNC" -> { | ||
LOGGER.info("Scaling down only sync worker..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-sync-worker").scale(0, true); | ||
|
||
LOGGER.info("Scaling up sync worker..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-sync-worker").scale(1); | ||
} | ||
case "KILL_ONLY_NON_SYNC" -> { | ||
LOGGER.info("Scaling down only non-sync worker..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(0, true); | ||
|
||
LOGGER.info("Scaling up non-sync worker..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(1); | ||
} | ||
} | ||
|
||
waitForSuccessfulJob(apiClient.getJobsApi(), connectionSyncRead.getJob()); | ||
|
||
final long numAttempts = apiClient.getJobsApi() | ||
.getJobInfo(new JobIdRequestBody().id(connectionSyncRead.getJob().getId())) | ||
.getAttempts() | ||
.size(); | ||
|
||
// it should be able to accomplish the resume without an additional attempt! | ||
assertEquals(1, numAttempts); | ||
} | ||
} | ||
|
||
@RetryingTest(3) | ||
@Order(6) | ||
@EnabledIfEnvironmentVariable(named = "CONTAINER_ORCHESTRATOR", | ||
matches = "true") | ||
public void testCancelSyncWithInterruption() throws Exception { | ||
final String connectionName = "test-connection"; | ||
final UUID sourceId = testHarness.createPostgresSource().getSourceId(); | ||
final UUID destinationId = testHarness.createDestination().getDestinationId(); | ||
final UUID operationId = testHarness.createOperation().getOperationId(); | ||
final AirbyteCatalog catalog = testHarness.discoverSourceSchema(sourceId); | ||
final SyncMode syncMode = SyncMode.FULL_REFRESH; | ||
final DestinationSyncMode destinationSyncMode = DestinationSyncMode.OVERWRITE; | ||
catalog.getStreams().forEach(s -> s.getConfig().syncMode(syncMode).destinationSyncMode(destinationSyncMode)); | ||
final UUID connectionId = | ||
testHarness.createConnection(connectionName, sourceId, destinationId, List.of(operationId), catalog, null).getConnectionId(); | ||
|
||
final JobInfoRead connectionSyncRead = apiClient.getConnectionApi().syncConnection(new ConnectionIdRequestBody().connectionId(connectionId)); | ||
waitWhileJobHasStatus(apiClient.getJobsApi(), connectionSyncRead.getJob(), Set.of(JobStatus.RUNNING)); | ||
|
||
Thread.sleep(5000); | ||
|
||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(0); | ||
Thread.sleep(1000); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(1); | ||
|
||
final var resp = apiClient.getJobsApi().cancelJob(new JobIdRequestBody().id(connectionSyncRead.getJob().getId())); | ||
assertEquals(JobStatus.CANCELLED, resp.getJob().getStatus()); | ||
} | ||
|
||
@RetryingTest(3) | ||
@Order(7) | ||
@Timeout(value = 5, | ||
unit = TimeUnit.MINUTES) | ||
@EnabledIfEnvironmentVariable(named = "CONTAINER_ORCHESTRATOR", | ||
matches = "true") | ||
public void testCuttingOffPodBeforeFilesTransfer() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this test entirely because it was almost identical to testDowntimeDuringSync and I didn't see the need for it |
||
final String connectionName = "test-connection"; | ||
final UUID sourceId = testHarness.createPostgresSource().getSourceId(); | ||
final UUID destinationId = testHarness.createDestination().getDestinationId(); | ||
final UUID operationId = testHarness.createOperation().getOperationId(); | ||
final AirbyteCatalog catalog = testHarness.discoverSourceSchema(sourceId); | ||
final SyncMode syncMode = SyncMode.FULL_REFRESH; | ||
final DestinationSyncMode destinationSyncMode = DestinationSyncMode.OVERWRITE; | ||
catalog.getStreams().forEach(s -> s.getConfig().syncMode(syncMode).destinationSyncMode(destinationSyncMode)); | ||
|
||
LOGGER.info("Creating connection..."); | ||
final UUID connectionId = | ||
testHarness.createConnection(connectionName, sourceId, destinationId, List.of(operationId), catalog, null).getConnectionId(); | ||
|
||
LOGGER.info("Waiting for connection to be available in Temporal..."); | ||
|
||
LOGGER.info("Run manual sync..."); | ||
final JobInfoRead connectionSyncRead = apiClient.getConnectionApi().syncConnection(new ConnectionIdRequestBody().connectionId(connectionId)); | ||
|
||
LOGGER.info("Waiting for job to run..."); | ||
waitWhileJobHasStatus(apiClient.getJobsApi(), connectionSyncRead.getJob(), Set.of(JobStatus.RUNNING)); | ||
|
||
LOGGER.info("Scale down workers..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(0); | ||
|
||
LOGGER.info("Wait for worker scale down..."); | ||
Thread.sleep(1000); | ||
|
||
LOGGER.info("Scale up workers..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(1); | ||
|
||
LOGGER.info("Waiting for worker timeout..."); | ||
Thread.sleep(ContainerOrchestratorApp.MAX_SECONDS_TO_WAIT_FOR_FILE_COPY * 1000 + 1000); | ||
|
||
LOGGER.info("Waiting for job to retry and succeed..."); | ||
waitForSuccessfulJob(apiClient.getJobsApi(), connectionSyncRead.getJob()); | ||
} | ||
|
||
@RetryingTest(3) | ||
@Order(8) | ||
@Timeout(value = 5, | ||
unit = TimeUnit.MINUTES) | ||
@EnabledIfEnvironmentVariable(named = "CONTAINER_ORCHESTRATOR", | ||
matches = "true") | ||
public void testCancelSyncWhenCancelledWhenWorkerIsNotRunning() throws Exception { | ||
final String connectionName = "test-connection"; | ||
final UUID sourceId = testHarness.createPostgresSource().getSourceId(); | ||
final UUID destinationId = testHarness.createDestination().getDestinationId(); | ||
final UUID operationId = testHarness.createOperation().getOperationId(); | ||
final AirbyteCatalog catalog = testHarness.discoverSourceSchema(sourceId); | ||
final SyncMode syncMode = SyncMode.FULL_REFRESH; | ||
final DestinationSyncMode destinationSyncMode = DestinationSyncMode.OVERWRITE; | ||
catalog.getStreams().forEach(s -> s.getConfig().syncMode(syncMode).destinationSyncMode(destinationSyncMode)); | ||
|
||
LOGGER.info("Creating connection..."); | ||
final UUID connectionId = | ||
testHarness.createConnection(connectionName, sourceId, destinationId, List.of(operationId), catalog, null).getConnectionId(); | ||
|
||
LOGGER.info("Waiting for connection to be available in Temporal..."); | ||
|
||
LOGGER.info("Run manual sync..."); | ||
final JobInfoRead connectionSyncRead = apiClient.getConnectionApi().syncConnection(new ConnectionIdRequestBody().connectionId(connectionId)); | ||
|
||
LOGGER.info("Waiting for job to run..."); | ||
waitWhileJobHasStatus(apiClient.getJobsApi(), connectionSyncRead.getJob(), Set.of(JobStatus.RUNNING)); | ||
|
||
LOGGER.info("Waiting for job to run a little..."); | ||
Thread.sleep(5000); | ||
|
||
LOGGER.info("Scale down workers..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(0); | ||
|
||
LOGGER.info("Waiting for worker shutdown..."); | ||
Thread.sleep(2000); | ||
|
||
LOGGER.info("Starting background cancellation request..."); | ||
final var pool = Executors.newSingleThreadExecutor(); | ||
final var mdc = MDC.getCopyOfContextMap(); | ||
final Future<JobInfoRead> resp = | ||
pool.submit(() -> { | ||
MDC.setContextMap(mdc); | ||
try { | ||
final JobInfoRead jobInfoRead = apiClient.getJobsApi().cancelJob(new JobIdRequestBody().id(connectionSyncRead.getJob().getId())); | ||
LOGGER.info("jobInfoRead = " + jobInfoRead); | ||
return jobInfoRead; | ||
} catch (final ApiException e) { | ||
LOGGER.error("Failed to read from api", e); | ||
throw e; | ||
} | ||
}); | ||
Thread.sleep(2000); | ||
|
||
LOGGER.info("Scaling up workers..."); | ||
kubernetesClient.apps().deployments().inNamespace("default").withName("airbyte-worker").scale(1); | ||
|
||
LOGGER.info("Waiting for cancellation to go into effect..."); | ||
assertEquals(JobStatus.CANCELLED, resp.get().getJob().getStatus()); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed these inputs and switch statement, because we don't have any deployments called
airbyte-sync-worker
. I think this was leftover from some other changes or something