use of org.junit.Assert.assertEquals in project photon-model by vmware.
the class TestAWSClientManagement method testAWSClientManagementArnDr.
@Test
public void testAWSClientManagementArnDr() throws Throwable {
this.ec2ClientReferenceCount = getClientReferenceCount(AwsClientType.EC2);
this.host.setTimeoutSeconds(60);
// Getting a reference to client managers in the test
AWSClientManager ec2ClientManager = getClientManager(AwsClientType.EC2);
ec2ClientManager.cleanUpArnCache();
assertEquals(this.ec2ClientReferenceCount + 1, getClientReferenceCount(AwsClientType.EC2));
this.creds = new AuthCredentialsServiceState();
this.creds.customProperties = new HashMap<>();
this.creds.customProperties.put(ARN_KEY, this.arn);
this.creds.customProperties.put(EXTERNAL_ID_KEY, this.externalId);
TestContext waitContext = new TestContext(1, Duration.ofSeconds(30L));
ec2ClientManager.getOrCreateEC2ClientAsync(this.creds, TestAWSSetupUtils.regionId, this.instanceService).exceptionally(t -> {
waitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.client = ec2Client;
waitContext.complete();
});
waitContext.await();
Assert.assertNotNull(this.client);
this.clientCacheCount = ec2ClientManager.getCacheCount();
// Requesting another AWS client with the same set of credentials will not
// create a new entry in the cache
AmazonEC2AsyncClient oldClient = this.client;
TestContext nextContext = new TestContext(1, Duration.ofSeconds(30L));
ec2ClientManager.getOrCreateEC2ClientAsync(this.creds, TestAWSSetupUtils.regionId, this.instanceService).exceptionally(t -> {
nextContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.client = ec2Client;
nextContext.complete();
});
nextContext.await();
Assert.assertNotNull(this.client);
Assert.assertEquals(oldClient, this.client);
assertEquals(this.clientCacheCount, ec2ClientManager.getCacheCount());
}
use of org.junit.Assert.assertEquals in project photon-model by vmware.
the class TestAzureLongRunningEnumeration method testLongRunEnumeration.
@Test
public void testLongRunEnumeration() throws Throwable {
// Log node stats at the beginning of the test
logNodeStats(this.host.getServiceStats(this.nodeStatsUri));
// 1. Provision VMs
List<ProvisionComputeTaskState> taskStates = new ArrayList<>();
for (int i = 0; i < numOfVMsToTest; i++) {
this.storageDescriptions.add(createDefaultStorageAccountDescription(this.host, this.mockedStorageAccountName, computeHost, endpointState));
this.resourceGroupStates.add(createDefaultResourceGroupState(this.host, this.mockedStorageAccountName, computeHost, endpointState, ResourceGroupStateType.AzureResourceGroup));
this.diskStates.add(createDefaultDiskState(this.host, this.mockedStorageAccountName, this.mockedStorageAccountName, computeHost, endpointState));
// create an Azure VM compute resource (this also creates a disk and a storage account)
this.vmStates.add(createDefaultVMResource(this.host, azureVMNames.get(i), computeHost, endpointState, nicSpecs.get(i)));
// kick off a provision task to do the actual VM creation
ProvisionComputeTaskState provisionTask = new ProvisionComputeTaskState();
provisionTask.computeLink = this.vmStates.get(i).documentSelfLink;
provisionTask.isMockRequest = this.isMock;
provisionTask.taskSubStage = SubStage.CREATING_HOST;
taskStates.add(TestUtils.doPost(this.host, provisionTask, ProvisionComputeTaskState.class, UriUtils.buildUri(this.host, ProvisionComputeTaskService.FACTORY_LINK)));
}
for (ProvisionComputeTaskState taskState : taskStates) {
this.host.waitForFinishedTask(ProvisionComputeTaskState.class, taskState.documentSelfLink);
}
this.host.log(Level.INFO, "VMs provisioned successfully.");
// Check resources have been created
// expected VM count = numOfVMsToTest + 1 (1 compute host instance + numOfVMsToTest vm compute state)
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, numOfVMsToTest + 1, ComputeService.FACTORY_LINK, false);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, numOfVMsToTest, StorageDescriptionService.FACTORY_LINK, false);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, numOfVMsToTest, ResourceGroupService.FACTORY_LINK, false);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, numOfVMsToTest, DiskService.FACTORY_LINK, false);
Map<String, ComputeState> azLrtComputeStates = getVMComputeStatesWithPrefix();
Assert.assertEquals(numOfVMsToTest, azLrtComputeStates.size());
if (this.isMock) {
runEnumeration(this.host, computeHost.documentSelfLink, computeHost.resourcePoolLink, endpointState, this.isMock);
for (int i = 0; i < numOfVMsToTest; i++) {
deleteVMs(this.host, this.vmStates.get(i).documentSelfLink, this.isMock, 1);
this.vmStates.set(i, null);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, numOfVMsToTest - i, ComputeService.FACTORY_LINK, false);
deleteServiceDocument(this.host, this.storageDescriptions.get(i).documentSelfLink);
this.storageDescriptions.set(i, null);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, numOfVMsToTest - i - 1, StorageDescriptionService.FACTORY_LINK, true);
deleteServiceDocument(this.host, this.resourceGroupStates.get(i).documentSelfLink);
this.resourceGroupStates.set(i, null);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, numOfVMsToTest - i - 1, ResourceGroupService.FACTORY_LINK, false);
deleteServiceDocument(this.host, this.diskStates.get(i).documentSelfLink);
this.diskStates.set(i, null);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, numOfVMsToTest - i - 1, DiskService.FACTORY_LINK, false);
}
return;
}
// 2. Create extra resources
createStaleResource();
tagAzureResources();
// stale resources + 1 compute host instance + 1 vm compute state
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, STALE_VM_RESOURCES_COUNT + (numOfVMsToTest + 1), ComputeService.FACTORY_LINK, false);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, STALE_STORAGE_ACCOUNTS_COUNT + numOfVMsToTest, StorageDescriptionService.FACTORY_LINK, false);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, STALE_CONTAINERS_COUNT + STALE_RG_COUNT + 1, ResourceGroupService.FACTORY_LINK, false);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, STALE_DISKS_COUNT + numOfVMsToTest, DiskService.FACTORY_LINK, false);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, STALE_SECURITY_GROUPS_COUNT, SecurityGroupService.FACTORY_LINK, false);
this.vmCount = getAzureVMCount(this.computeManagementClient);
this.host.log(Level.INFO, "Initial VM Count: %d", this.vmCount);
// 3. Run multiple enumerations over a period of time.
this.host.log(Level.INFO, "Waiting for multiple enumeration runs...");
ScheduledFuture<?> enums = runEnumerationAndLogNodeStatsPeriodically();
this.host.waitFor("Timeout while waiting for test run duration", () -> {
TimeUnit.MINUTES.sleep(this.testRunDurationInMinutes);
enums.cancel(false);
return true;
});
this.host.waitFor("Timeout while waiting for last enumeration to clear out.", () -> {
TimeUnit.MINUTES.sleep(1);
return true;
});
verifyResourceDuplicates();
// 4. Validate extra resources
assertRemoteResources();
assertStaleResources();
ServiceDocumentQueryResult result = ProvisioningUtils.queryDocumentsAndAssertExpectedCount(this.host, this.vmCount, ComputeService.FACTORY_LINK, false);
// validate type field for enumerated VMs
result.documents.entrySet().stream().map(e -> Utils.fromJson(e.getValue(), ComputeState.class)).filter(c -> !c.documentSelfLink.equals(computeHost.documentSelfLink)).forEach(c -> assertEquals(ComputeType.VM_GUEST, c.type));
// validate internal tags for enumerated VMs
TagService.TagState expectedInternalTypeTag = newTagState(TAG_KEY_TYPE, AzureConstants.AzureResourceType.azure_vm.toString(), false, endpointState.tenantLinks);
result.documents.entrySet().stream().map(e -> Utils.fromJson(e.getValue(), ComputeState.class)).filter(c -> c.type.equals(ComputeType.VM_GUEST)).forEach(c -> {
assertNotNull(c.tagLinks);
assertTrue(c.tagLinks.contains(expectedInternalTypeTag.documentSelfLink));
});
// validate environment name field for enumerated VMs
result.documents.entrySet().stream().map(e -> Utils.fromJson(e.getValue(), ComputeState.class)).forEach(c -> assertEquals(ComputeDescription.ENVIRONMENT_NAME_AZURE, c.environmentName));
// 5. Validate enumerated compute states have not changed.
Map<String, ComputeState> azLrtComputeStatesEnd = getVMComputeStatesWithPrefix();
assertTrue(numOfVMsToTest <= azLrtComputeStatesEnd.size());
assertComputeStatesEqual(azLrtComputeStates, azLrtComputeStatesEnd);
// 1 network per each stale vm resource + 1 network for original vm compute state.
ServiceDocumentQueryResult networkResults = ProvisioningUtils.queryAllFactoryResources(this.host, NetworkService.FACTORY_LINK);
// validate internal tags for enumerated networks
TagService.TagState expectedNetworkInternalTypeTag = newTagState(TAG_KEY_TYPE, NETWORK_TAG_TYPE_VALUE, false, endpointState.tenantLinks);
networkResults.documents.entrySet().stream().map(e -> Utils.fromJson(e.getValue(), NetworkState.class)).forEach(c -> {
assertNotNull(c.tagLinks);
assertTrue(c.tagLinks.contains(expectedNetworkInternalTypeTag.documentSelfLink));
});
// 1 subnet per network, 1 network per each stale vm resource + 1 subnet for the original
// compute state.
ServiceDocumentQueryResult subnetResults = ProvisioningUtils.queryAllFactoryResources(this.host, SubnetService.FACTORY_LINK);
// validate internal tags for enumerated subnets
TagService.TagState expectedSubnetInternalTypeTag = newTagState(TAG_KEY_TYPE, SUBNET_TAG_TYPE_VALUE, false, endpointState.tenantLinks);
subnetResults.documents.entrySet().stream().map(e -> Utils.fromJson(e.getValue(), SubnetState.class)).forEach(c -> {
assertNotNull(c.tagLinks);
assertTrue(c.tagLinks.contains(expectedSubnetInternalTypeTag.documentSelfLink));
});
ServiceDocumentQueryResult nicResults = ProvisioningUtils.queryAllFactoryResources(this.host, NetworkInterfaceService.FACTORY_LINK);
// validate internal tags for enumerated network interfaces
TagService.TagState expectedNicInternalTypeTag = newTagState(TAG_KEY_TYPE, NETWORK_INTERFACE_TAG_TYPE_VALUE, false, endpointState.tenantLinks);
nicResults.documents.entrySet().stream().map(e -> Utils.fromJson(e.getValue(), NetworkInterfaceState.class)).forEach(c -> {
assertNotNull(c.tagLinks);
assertTrue(c.tagLinks.contains(expectedNicInternalTypeTag.documentSelfLink));
});
for (int i = 0; i < numOfVMsToTest; i++) {
this.host.log(Level.INFO, "Deleting vm: %s", azureVMNames.get(i));
this.computeManagementClient.virtualMachines().beginDelete(azureVMNames.get(i), azureVMNames.get(i));
}
runEnumeration(this.host, computeHost.documentSelfLink, computeHost.resourcePoolLink, endpointState, this.isMock);
for (int i = 0; i < numOfVMsToTest; i++) {
assertResourceDisassociated(this.host, ComputeService.FACTORY_LINK, azureVMNames.get(i), true);
// clean up
this.vmStates.set(i, null);
this.resourceManagementClient.resourceGroups().beginDelete(azureVMNames.get(i));
this.host.log(Level.INFO, "Deleting vm resource group %s", azureVMNames.get(i));
}
// Log node stats at the end of the test
logNodeStats(this.host.getServiceStats(this.nodeStatsUri));
}
use of org.junit.Assert.assertEquals in project evosuite by EvoSuite.
the class PrivateReflectionSystemTest method testPrivateConstructor.
private TestSuiteChromosome testPrivateConstructor() {
Properties.P_REFLECTION_ON_PRIVATE = 0.9;
Properties.REFLECTION_START_PERCENT = 0.0;
GeneticAlgorithm ga = do100percentLineTestOnStandardCriteriaWithMethodTrace(PrivateConstructor.class);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
assertTrue(!best.getTests().isEmpty());
double cov = best.getCoverageInstanceOf(MethodCoverageSuiteFitness.class);
Assert.assertEquals("Non-optimal method coverage: ", 1d, cov, 0.001);
Optional<FitnessFunction<?>> ff = ga.getFitnessFunctions().stream().filter(m -> m instanceof MethodCoverageSuiteFitness).findAny();
assertEquals(1, best.getNumOfCoveredGoals(ff.get()));
cov = best.getCoverageInstanceOf(MethodTraceCoverageSuiteFitness.class);
Assert.assertEquals("Non-optimal method trace coverage: ", 1d, cov, 0.001);
ff = ga.getFitnessFunctions().stream().filter(m -> m instanceof MethodTraceCoverageSuiteFitness).findAny();
assertEquals(1, best.getNumOfCoveredGoals(ff.get()));
return best;
}
use of org.junit.Assert.assertEquals in project gridss by PapenfussLab.
the class ExtractSVReadsTest method regression_should_extract_split_read_alignments_as_group_2.
// @Test
@Category(Hg38Tests.class)
public void regression_should_extract_split_read_alignments_as_group_2() throws IOException {
File ref = Hg38Tests.findHg38Reference();
ReferenceLookup lookup = new SynchronousReferenceLookupAdapter(new IndexedFastaSequenceFile(ref));
Files.copy(new File("src/test/resources/sa.split/test2.sam"), input);
ExtractSVReads extract = new ExtractSVReads();
// new ProcessingContext(getFSContext(), ref, lookup, null, getConfig());
extract.setReference(lookup);
extract.MIN_CLIP_LENGTH = 4;
extract.INSERT_SIZE_METRICS = new File("src/test/resources/sa.split/test.insert_size_metrics");
extract.READ_PAIR_CONCORDANCE_METHOD = ReadPairConcordanceMethod.PERCENTAGE;
extract.OUTPUT = output;
extract.INPUT = input;
try (SamReader reader = SamReaderFactory.make().open(input)) {
extract.setup(reader.getFileHeader(), input);
}
List<SAMRecord> records = getRecords(input);
List<Boolean> result = records.stream().map(r -> extract.shouldExtract(ImmutableList.of(r), lookup)[0]).collect(Collectors.toList());
/*
for (int i = 0; i < records.size(); i++) {
SAMRecord r = records.get(i);
System.out.print(r.getSupplementaryAlignmentFlag() ? "S" : " ");
System.out.print(r.getFirstOfPairFlag() ? "1" : "2");
System.out.print(" Extracted=" + (result.get(i) ? "y" : "n"));
System.out.print(" HasConcPair=" + (ExtractSVReads.hasReadPairingConsistentWithReference(extract.getReadPairConcordanceCalculator(), ImmutableList.of(r)) ? "y" : "n"));
boolean[] ra = ExtractSVReads.hasReadAlignmentConsistentWithReference(ImmutableList.of(r));
System.out.print(" HasConcRead=" + (ra[0] ? "y" : "n") + (ra[1] ? "y" : "n"));
System.out.println(" " + new ChimericAlignment(r).toString());
}*/
// primary read pair alignment implies an unexpected library fragment size = extract them all
Assert.assertEquals(ImmutableList.of(true, true, true, true), result);
lookup.close();
}
use of org.junit.Assert.assertEquals in project solr-document-store by DBCDK.
the class BiliographicRecordAPIBeanIT method testSupersedeIdIncluded.
@Test
public void testSupersedeIdIncluded() throws JsonProcessingException {
String bibliographicRecordId = "page-order";
Response json = bean.getBibliographicKeysWithSupersedeId(bibliographicRecordId, 1, 10, "agencyId", false);
FrontendReturnListType<BibliographicFrontendEntity> frontendReturnListType = (FrontendReturnListType<BibliographicFrontendEntity>) json.getEntity();
List<String> supersedeIds = frontendReturnListType.result.stream().map(b -> b.getSupersedeId()).collect(Collectors.toList());
Assert.assertEquals(supersedeIds, Arrays.asList("0639423", "0639423", "0639423", "0639423", "0639423", "0639423", "0639423", "0639423"));
String repositoryId = "p-o";
Response jsonRepo = bean.getBibliographicKeysByRepositoryIdWithSupersedeId(repositoryId, 1, 10, "agencyId", false);
FrontendReturnListType<BibliographicFrontendEntity> frontendReturnListTypeRepo = (FrontendReturnListType<BibliographicFrontendEntity>) jsonRepo.getEntity();
List<String> supersedeIdsRepo = frontendReturnListTypeRepo.result.stream().map(b -> b.getSupersedeId()).collect(Collectors.toList());
Assert.assertEquals(supersedeIdsRepo, Arrays.asList("0639423", "0639423", "0639423", "0639423", "0639423", "0639423", "0639423", "0639423"));
}
Aggregations