use of com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.regionId in project photon-model by vmware.
the class AWSComputeDiskDay2ServiceTest method setUp.
@Before
public void setUp() throws Exception {
CommandLineArgumentParser.parseFromProperties(this);
setAwsClientMockInfo(this.isAwsClientMock, this.awsMockEndpointReference);
AuthCredentialsService.AuthCredentialsServiceState creds = new AuthCredentialsService.AuthCredentialsServiceState();
creds.privateKey = this.secretKey;
creds.privateKeyId = this.accessKey;
TestContext ec2WaitContext = new TestContext(1, Duration.ofSeconds(30L));
AWSUtils.getEc2AsyncClient(creds, TestAWSSetupUtils.regionId, getExecutor()).exceptionally(t -> {
ec2WaitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.client = ec2Client;
ec2WaitContext.complete();
});
ec2WaitContext.await();
this.awsTestContext = new HashMap<>();
setUpTestVpc(this.client, this.awsTestContext, this.isMock, this.zoneId);
this.singleNicSpec = (TestAWSSetupUtils.AwsNicSpecs) this.awsTestContext.get(TestAWSSetupUtils.NIC_SPECS_KEY);
this.host = VerificationHost.create(0);
try {
this.host.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS.toMicros(250));
this.host.start();
PhotonModelServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
ServiceMetadata[] serviceMetadata = { factoryService(DiskTaskService.class, DiskTaskService::createFactory) };
StartServicesHelper.startServices(this.host, serviceMetadata);
AWSAdaptersTestUtils.startServicesSynchronously(this.host);
this.host.setTimeoutSeconds(1200);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelMetricServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
initResourcePoolAndComputeHost(this.zoneId);
} catch (Throwable e) {
throw new Exception(e);
}
}
use of com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.regionId in project photon-model by vmware.
the class TestAWSEnumerationTask method setUp.
@Before
public void setUp() throws Throwable {
CommandLineArgumentParser.parseFromProperties(this);
setAwsClientMockInfo(this.isAwsClientMock, this.awsMockEndpointReference);
// create credentials
AuthCredentialsServiceState creds = new AuthCredentialsServiceState();
creds.privateKey = this.secretKey;
creds.privateKeyId = this.accessKey;
TestContext ec2WaitContext = new TestContext(1, Duration.ofSeconds(30L));
AWSUtils.getEc2AsyncClient(creds, TestAWSSetupUtils.regionId, getExecutor()).exceptionally(t -> {
ec2WaitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.client = ec2Client;
ec2WaitContext.complete();
});
ec2WaitContext.await();
TestContext s3WaitContext = new TestContext(1, Duration.ofSeconds(30L));
AWSUtils.getS3ClientAsync(creds, TestAWSSetupUtils.regionId, getExecutor()).exceptionally(t -> {
s3WaitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.s3Client = ec2Client;
s3WaitContext.complete();
});
s3WaitContext.await();
if (ENABLE_LOAD_BALANCER_ENUMERATION) {
TestContext lbWaitContext = new TestContext(1, Duration.ofSeconds(30L));
AWSUtils.getAwsLoadBalancingAsyncClient(creds, TestAWSSetupUtils.regionId, getExecutor()).exceptionally(t -> {
lbWaitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.lbClient = ec2Client;
lbWaitContext.complete();
});
lbWaitContext.await();
}
this.awsTestContext = new HashMap<>();
setUpTestVpc(this.client, this.awsTestContext, this.isMock);
this.vpcId = (String) this.awsTestContext.get(TestAWSSetupUtils.VPC_KEY);
this.subnetId = (String) this.awsTestContext.get(TestAWSSetupUtils.SUBNET_KEY);
this.securityGroupId = (String) this.awsTestContext.get(TestAWSSetupUtils.SECURITY_GROUP_KEY);
this.singleNicSpec = (AwsNicSpecs) this.awsTestContext.get(TestAWSSetupUtils.NIC_SPECS_KEY);
try {
PhotonModelServices.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
AWSAdaptersTestUtils.startServicesSynchronously(this.host);
this.host.setTimeoutSeconds(this.timeoutSeconds);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
} catch (Throwable e) {
this.host.log("Error starting up services for the test %s", e.getMessage());
throw new Exception(e);
}
// create the compute host, resource pool and the VM state to be used in the test.
initResourcePoolAndComputeHost();
}
Aggregations