Skip to content
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

DT-1194: Speed up integration tests by running them in parallel #1896

Draft
wants to merge 33 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c49d0a1
Convert two integration tests to no longer require a full application…
pshapiro4broad Jan 23, 2025
3f9f507
WIP integration test migration
pshapiro4broad Jan 23, 2025
3b3f3f3
spotless
pshapiro4broad Jan 23, 2025
745ea66
more integration WIP
pshapiro4broad Jan 23, 2025
587b22d
spotless
pshapiro4broad Jan 24, 2025
2c11234
fix more issues
pshapiro4broad Jan 24, 2025
3797f55
fix more issues
pshapiro4broad Jan 24, 2025
5db6e56
spotless
pshapiro4broad Jan 24, 2025
8936b03
misc integration test changes
pshapiro4broad Jan 27, 2025
731142a
DT-1184: update db retry catch to use new exception class
pshapiro4broad Jan 27, 2025
4c6196a
Merge branch 'develop' into ps/int-test-improvements
pshapiro4broad Jan 27, 2025
e8c1e89
fix map deserialization issue
pshapiro4broad Jan 27, 2025
57f6ee3
merge fixes
pshapiro4broad Jan 27, 2025
83ba235
merge fixes
pshapiro4broad Jan 27, 2025
b7f4cb2
Merge branch 'ps/dt-1184-sql-retry-fix' into ps/int-test-improvements
pshapiro4broad Jan 27, 2025
d7171be
merge fixes
pshapiro4broad Jan 27, 2025
d897097
Fix cases where TransactionSystemException was thrown but not checked…
pshapiro4broad Jan 27, 2025
6b0bb49
Merge branch 'ps/dt-1184-sql-retry-fix' into ps/int-test-improvements
pshapiro4broad Jan 27, 2025
1cd45e3
add retry to db step in delete snapshot flight
pshapiro4broad Jan 27, 2025
c2a3474
thread safety
pshapiro4broad Jan 27, 2025
274fda2
minor fixes
pshapiro4broad Jan 27, 2025
270d479
log test users
pshapiro4broad Jan 27, 2025
1babe2d
spotless
pshapiro4broad Jan 27, 2025
c3464ff
fix NPE
pshapiro4broad Jan 28, 2025
6afd840
convert to concurrent execution
pshapiro4broad Jan 28, 2025
117b5b5
another retry case found while testing
pshapiro4broad Jan 28, 2025
bb20139
convert to concurrent execution
pshapiro4broad Jan 28, 2025
0a79c38
convert DatasetControlFilesIntegrationTest to concurrent execution
pshapiro4broad Jan 29, 2025
a165a85
convert SelfHostedDatasetIntegrationTest to concurrent execution
pshapiro4broad Jan 29, 2025
b3668b3
disable configuration (fault injection) tests
pshapiro4broad Jan 29, 2025
58252cf
concurrent azure tests (not working yet); longer timout for service run
pshapiro4broad Jan 29, 2025
0c1e42f
Merge branch 'develop' into ps/int-test-improvements
pshapiro4broad Jan 31, 2025
af71817
more work to get azure integration tests working in parallel
pshapiro4broad Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ tasks.register('testIntegration', Test) {
}
maxParallelForks = 8
outputs.upToDateWhen { false }
systemProperty 'junit.jupiter.execution.parallel.enabled', 'true'
}

tasks.register('testUnit', Test) {
Expand Down
1 change: 1 addition & 0 deletions scripts/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
- GOOGLE_SA_CERT
- RBS_POOLID
- RBS_INSTANCEURL
- TDR_LOG_APPENDER
ports:
- "8080:8080"
volumes:
Expand Down
8 changes: 8 additions & 0 deletions scripts/run
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ source "$(dirname "$0")"/init.sh
die() { log_error "$*" >&2; echo ""; usage; exit 2; } # complain to STDERR and exit with error
needs_arg() { if [ -z "$OPTARG" ]; then die "No arg for --$OPT option"; fi; }

# output plain logs instead of json
export TDR_LOG_APPENDER=Console-Standard

while getopts h-: OPT; do
# support long options: https://stackoverflow.com/a/28466267/519360
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
Expand Down Expand Up @@ -57,11 +60,16 @@ run_tests() {
#./gradlew --build-cache srcclr
}

wait_until_server_up() {
timeout 60 bash -c "until curl -s http:/localhost:8080/status; do sleep 1; done"
}

run_integration_tests() {
TEST_ENV=${TEST_ENV:-local}

cd "${ROOT_DIR}"
start_docker integration
wait_until_server_up
# shellcheck disable=SC2086 # The array syntax and quoting seems to break gradle
./gradlew testIntegration ${GRADLE_ARGS}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.TransactionSystemException;

public class CreateDatasetGetOrCreateBucketStep implements Step {
private static final Logger logger =
Expand Down Expand Up @@ -79,8 +80,8 @@ public StepResult doStep(FlightContext context) throws InterruptedException {
googleProjectResource.getServiceAccount());

workingMap.put(FileMapKeys.BUCKET_INFO, bucketForFile);
} catch (BucketLockException blEx) {
return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, blEx);
} catch (BucketLockException | TransactionSystemException e) {
return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, e);
} catch (GoogleResourceNamingException ex) {
return new StepResult(StepStatus.STEP_RESULT_FAILURE_FATAL, ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
import bio.terra.stairway.FlightMap;
import bio.terra.stairway.Step;
import bio.terra.stairway.StepResult;
import bio.terra.stairway.StepStatus;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.TransientDataAccessException;
import org.springframework.transaction.TransactionSystemException;

public class CreateDatasetGetOrCreateStorageAccountStep implements Step {
private static Logger logger =
Expand All @@ -40,11 +43,16 @@ public StepResult doStep(FlightContext context) throws InterruptedException {
workingMap.get(ProfileMapKeys.PROFILE_MODEL, BillingProfileModel.class);
UUID datasetId = workingMap.get(DatasetWorkingMapKeys.DATASET_ID, UUID.class);

AzureStorageAccountResource storageAccount =
resourceService.getOrCreateDatasetStorageAccount(
DatasetJsonConversion.datasetRequestToDataset(datasetRequestModel, datasetId),
profileModel,
context.getFlightId());
AzureStorageAccountResource storageAccount;
try {
storageAccount =
resourceService.getOrCreateDatasetStorageAccount(
DatasetJsonConversion.datasetRequestToDataset(datasetRequestModel, datasetId),
profileModel,
context.getFlightId());
} catch (TransientDataAccessException | TransactionSystemException e) {
return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, e);
}

logger.info("Enabling Azure storage account logging");
// Log files will reside in the storage account's $logs container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public DatasetCreateFlight(FlightMap inputParameters, Object applicationContext)
if (platform.isAzure()) {
addStep(
new CreateDatasetGetOrCreateStorageAccountStep(
resourceService, datasetRequest, azureBlobStorePdao));
resourceService, datasetRequest, azureBlobStorePdao),
getDefaultRandomBackoffRetryRule(appConfig.getMaxStairwayThreads()));

// Create the top level container
addStep(
Expand All @@ -130,7 +131,7 @@ public DatasetCreateFlight(FlightMap inputParameters, Object applicationContext)
// Create dataset metadata objects in postgres and lock the dataset
addStep(
new CreateDatasetMetadataStep(datasetDao, datasetRequest),
getDefaultExponentialBackoffRetryRule());
getDefaultRandomBackoffRetryRule(appConfig.getMaxStairwayThreads()));

// For azure backed datasets, add a link co connect the storage account to the dataset
if (platform.isAzure()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ public AzureResourceDao(NamedParameterJdbcTemplate jdbcTemplate) throws SQLExcep

@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE)
public UUID createApplicationDeployment(AzureApplicationDeploymentResource application) {
try {
var resource =
retrieveApplicationDeploymentByName(application.getAzureApplicationDeploymentName());
if (resource != null) {
// The database requires azure_application_deployment_name to be unique
// (see retrieveApplicationDeploymentBy below). To enforce that, we should add a db
// constraint
// and use ON CONFLICT to return the existing record instead. For now, check for a duplicate
// inside this transaction before writing a new record.
return resource.getId();
}
} catch (AzureResourceNotFoundException e) {
// This is the expected case, where the application deployment does not exist.
}

String sql =
"INSERT INTO application_deployment_resource "
+ "(azure_application_deployment_id,azure_application_deployment_name,azure_resource_group_name,"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import bio.terra.stairway.FlightMap;
import bio.terra.stairway.Step;
import bio.terra.stairway.StepResult;
import bio.terra.stairway.StepStatus;
import bio.terra.stairway.exception.RetryException;
import java.util.List;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.TransientDataAccessException;
import org.springframework.transaction.TransactionSystemException;

public class DeleteSnapshotMarkProjectStep implements Step {

Expand All @@ -26,19 +27,21 @@ public DeleteSnapshotMarkProjectStep(
this.snapshotService = snapshotService;
}

private static final Logger logger = LoggerFactory.getLogger(DeleteSnapshotMarkProjectStep.class);

@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
FlightMap workingMap = context.getWorkingMap();
UUID projectId = workingMap.get(SnapshotWorkingMapKeys.PROJECT_RESOURCE_ID, UUID.class);

List<UUID> projectsToBeDeleted =
resourceService.markUnusedProjectsForDelete(List.of(projectId));
try {
List<UUID> projectsToBeDeleted =
resourceService.markUnusedProjectsForDelete(List.of(projectId));

workingMap.put(SnapshotWorkingMapKeys.PROJECTS_MARKED_FOR_DELETE, projectsToBeDeleted);
workingMap.put(SnapshotWorkingMapKeys.PROJECTS_MARKED_FOR_DELETE, projectsToBeDeleted);

return StepResult.getStepResultSuccess();
return StepResult.getStepResultSuccess();
} catch (TransientDataAccessException | TransactionSystemException e) {
return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import static org.hamcrest.Matchers.is;

import bio.terra.common.category.Integration;
import bio.terra.common.configuration.TestConfiguration.User;
import bio.terra.integration.DataRepoFixtures;
import bio.terra.integration.IntegrationTestConfiguration;
import bio.terra.integration.UsersBase;
import bio.terra.integration.Users;
import bio.terra.model.ConfigGroupModel;
import bio.terra.model.ConfigModel;
import bio.terra.model.ConfigParameterModel;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -30,14 +32,27 @@
@SpringBootTest(classes = IntegrationTestConfiguration.class)
@ActiveProfiles({"google", "integrationtest"})
@Tag(Integration.TAG)
class RepositoryApiControllerAccessTest extends UsersBase {
@Disabled
class RepositoryApiControllerAccessTest {

@Autowired private DataRepoFixtures dataRepoFixtures;
@Autowired private Users users;

private User admin;
private User reader;

private User admin() {
return admin;
}

private User reader() {
return reader;
}

@BeforeEach
@Override
public void setup() throws Exception {
super.setup();
admin = users.admin();
reader = users.reader();
}

@Test
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/bio/terra/common/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class AuthService {
public AuthService(TestConfiguration testConfig, IamProviderInterface iamProvider)
throws Exception {
this.testConfig = testConfig;
Optional<String> pemfilename = Optional.ofNullable(testConfig.getJadePemFileName());
Optional<String> pemfilename = Optional.ofNullable(testConfig.jadePemFileName());
pemfilename.ifPresent(s -> pemfile = new File(s));
saEmail = testConfig.getJadeEmail();
saEmail = testConfig.jadeEmail();
httpTransport = GoogleNetHttpTransport.newTrustedTransport();
this.iamProvider = iamProvider;
}
Expand All @@ -85,7 +85,7 @@ private GoogleCredential buildCredential(String email, List<String> scopes)
throws IOException, GeneralSecurityException {
if (pemfile == null) {
throw new IllegalStateException(
String.format("pemfile not found: %s", testConfig.getJadePemFileName()));
String.format("pemfile not found: %s", testConfig.jadePemFileName()));
}
return new GoogleCredential.Builder()
.setTransport(httpTransport)
Expand Down
83 changes: 0 additions & 83 deletions src/test/java/bio/terra/common/auth/Users.java

This file was deleted.

Loading
Loading