use of com.hartwig.pipeline.Arguments in project pipeline5 by hartwigmedical.
the class GoogleComputeEngineTest method setUp.
@Before
public void setUp() throws Exception {
images = mock(Compute.Images.class);
imagesFromFamily = mock(Compute.Images.GetFromFamily.class);
when(imagesFromFamily.execute()).thenReturn(new Image());
when(images.getFromFamily(ARGUMENTS.project(), VirtualMachineJobDefinition.STANDARD_IMAGE)).thenReturn(imagesFromFamily);
final ArgumentCaptor<Instance> instanceArgumentCaptor = ArgumentCaptor.forClass(Instance.class);
Operation insertOperation = mock(Operation.class);
when(insertOperation.getName()).thenReturn("insert");
final Compute.Instances instances = mock(Compute.Instances.class);
lifecycleManager = mock(InstanceLifecycleManager.class);
instance = mock(Instance.class);
when(lifecycleManager.newInstance()).thenReturn(instance);
when(lifecycleManager.deleteOldInstancesAndStart(instanceArgumentCaptor.capture(), any(), any())).thenReturn(insertOperation);
when(instance.getName()).thenReturn(INSTANCE_NAME);
Compute.Instances.Stop stop = mock(Compute.Instances.Stop.class);
Operation stopOperation = mock(Operation.class);
when(stopOperation.getName()).thenReturn("stop");
when(stopOperation.getStatus()).thenReturn(DONE);
when(stop.execute()).thenReturn(stopOperation);
when(instances.stop(ARGUMENTS.project(), FIRST_ZONE_NAME, INSTANCE_NAME)).thenReturn(stop);
Compute.Instances.Delete delete = mock(Compute.Instances.Delete.class);
Operation deleteOperation = mock(Operation.class);
when(deleteOperation.getName()).thenReturn("delete");
when(deleteOperation.getStatus()).thenReturn(DONE);
when(delete.execute()).thenReturn(stopOperation);
when(instances.delete(ARGUMENTS.project(), FIRST_ZONE_NAME, INSTANCE_NAME)).thenReturn(delete);
Compute.Instances.List list = mock(Compute.Instances.List.class);
InstanceList instanceList = mock(InstanceList.class);
Instance one = mock(Instance.class);
Instance two = mock(Instance.class);
Instance three = mock(Instance.class);
when(one.getName()).thenReturn("vm-1");
when(two.getName()).thenReturn("vm-2");
when(three.getName()).thenReturn("vm-3");
List<Instance> existingInstances = Arrays.asList(one, two, three);
when(instances.list(any(), any())).thenReturn(list);
when(list.execute()).thenReturn(instanceList);
when(instanceList.getItems()).thenReturn(existingInstances);
final Compute.ZoneOperations zoneOperations = mock(Compute.ZoneOperations.class);
final Compute.ZoneOperations.Get zoneOpGet = mock(Compute.ZoneOperations.Get.class);
Operation zoneOpGetOperation = mock(Operation.class);
when(zoneOpGetOperation.getStatus()).thenReturn(DONE);
when(zoneOpGet.execute()).thenReturn(zoneOpGetOperation);
when(zoneOperations.get(ARGUMENTS.project(), FIRST_ZONE_NAME, "insert")).thenReturn(zoneOpGet);
when(zoneOperations.get(ARGUMENTS.project(), FIRST_ZONE_NAME, "stop")).thenReturn(zoneOpGet);
compute = mock(Compute.class);
when(compute.images()).thenReturn(images);
when(compute.instances()).thenReturn(instances);
when(compute.zoneOperations()).thenReturn(zoneOperations);
Compute.Zones zones = mock(Compute.Zones.class);
Compute.Zones.List zonesList = mock(Compute.Zones.List.class);
when(zonesList.execute()).thenReturn(new ZoneList().setItems(Lists.newArrayList(zone(FIRST_ZONE_NAME), zone(SECOND_ZONE_NAME))));
when(zones.list(ARGUMENTS.project())).thenReturn(zonesList);
when(compute.zones()).thenReturn(zones);
bucketWatcher = mock(BucketCompletionWatcher.class);
victim = new GoogleComputeEngine(ARGUMENTS, compute, z -> {
}, lifecycleManager, bucketWatcher, Labels.of(Arguments.testDefaults(), TestInputs.defaultSomaticRunMetadata()));
runtimeBucket = MockRuntimeBucket.test();
jobDefinition = VirtualMachineJobDefinition.builder().name("test").namespacedResults(RESULTS_DIRECTORY).startupCommand(BashStartupScript.of(runtimeBucket.getRuntimeBucket().name())).build();
}
use of com.hartwig.pipeline.Arguments in project pipeline5 by hartwigmedical.
the class SmokeTest method runFullPipelineAndCheckFinalStatus.
public void runFullPipelineAndCheckFinalStatus(final String inputMode, final PipelineStatus expectedStatus, @SuppressWarnings("OptionalUsedAsFieldOrParameterType") final Optional<String> targetedRegionsBed, final RefGenomeVersion refGenomeVersion) throws Exception {
final PipelineMain victim = new PipelineMain();
final String version = version();
final String setName = noDots(inputMode + "-" + version);
final String fixtureDir = "smoke_test/" + inputMode + "/";
@SuppressWarnings("deprecation") final String randomRunId = noDots(RandomStringUtils.random(5, true, false));
final ImmutableArguments.Builder builder = Arguments.defaultsBuilder(Arguments.DefaultsProfile.DEVELOPMENT.toString()).sampleJson(Resources.testResource(fixtureDir + "samples.json")).cloudSdkPath(findCloudSdk()).setId(setName).runId(randomRunId).runGermlineCaller(false).cleanup(false).outputBucket("smoketest-pipeline-output-pilot-1").context(Context.DIAGNOSTIC).useTargetRegions(false).refGenomeVersion(refGenomeVersion);
if (whoami.equals("root")) {
String privateKeyPath = workingDir() + "/google-key.json";
builder.privateKeyPath(privateKeyPath).uploadPrivateKeyPath(privateKeyPath);
}
Arguments arguments = builder.build();
Storage storage = StorageProvider.from(arguments, CredentialProvider.from(arguments).get()).get();
cleanupBucket(inputMode, arguments.outputBucket(), storage);
PipelineState state = victim.start(arguments);
assertThat(state.status()).isEqualTo(expectedStatus);
File expectedFilesResource = new File(Resources.testResource(fixtureDir + "expected_output_files"));
List<String> expectedFiles = FileUtils.readLines(expectedFilesResource, FILE_ENCODING);
final String outputDir = setName + "-" + randomRunId;
List<String> actualFiles = listOutput(outputDir, arguments.outputBucket(), storage);
assertThat(actualFiles).containsOnlyElementsOf(expectedFiles);
if (inputMode.equals("tumor-reference")) {
ComparAssert.assertThat(storage, arguments.outputBucket(), outputDir).isEqualToTruthset(Resources.testResource(fixtureDir + "/truthset")).cleanup();
}
cleanupBucket(outputDir, arguments.outputBucket(), storage);
}
use of com.hartwig.pipeline.Arguments in project pipeline5 by hartwigmedical.
the class RuntimeBucketTest method usesCmek.
@Test
public void usesCmek() {
String keyName = "key";
Arguments arguments = Arguments.testDefaultsBuilder().cmek(keyName).build();
RuntimeBucket.from(storage, NAMESPACE, referenceRunMetadata(), arguments, labels);
assertThat(bucketInfo.getValue().getDefaultKmsKeyName()).isEqualTo(keyName);
}
use of com.hartwig.pipeline.Arguments in project pipeline5 by hartwigmedical.
the class FullSomaticResultsTest method setUp.
@Before
public void setUp() throws Exception {
storage = mock(Storage.class);
Arguments arguments = Arguments.testDefaultsBuilder().outputBucket(OUTPUT_BUCKET).build();
victim = new FullSomaticResults(storage, arguments, 1);
outputBucket = mock(Bucket.class);
when(outputBucket.getName()).thenReturn(OUTPUT_BUCKET);
when(storage.get(OUTPUT_BUCKET)).thenReturn(outputBucket);
}
Aggregations