use of com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.EC2_LINUX_AMI in project photon-model by vmware.
the class AWSLoadBalancerServiceTest method setUp.
@Override
@Before
public void setUp() throws Throwable {
CommandLineArgumentParser.parseFromProperties(this);
try {
PhotonModelServices.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
AWSAdaptersTestUtils.startServicesSynchronously(this.host);
AuthCredentialsServiceState creds = new AuthCredentialsServiceState();
creds.privateKey = this.secretKey;
creds.privateKeyId = this.accessKey;
TestContext lbWaitContext = new TestContext(1, Duration.ofSeconds(30L));
AWSUtils.getAwsLoadBalancingAsyncClient(creds, this.regionId, getExecutor()).exceptionally(t -> {
lbWaitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.client = ec2Client;
lbWaitContext.complete();
});
lbWaitContext.await();
TestContext ec2WaitContext = new TestContext(1, Duration.ofSeconds(30L));
AWSUtils.getEc2AsyncClient(creds, this.regionId, getExecutor()).exceptionally(t -> {
ec2WaitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.ec2client = ec2Client;
ec2WaitContext.complete();
});
ec2WaitContext.await();
TestContext secGroupWaitContext = new TestContext(1, Duration.ofSeconds(30L));
AWSUtils.getEc2AsyncClient(creds, this.regionId, getExecutor()).exceptionally(t -> {
secGroupWaitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.securityGroupClient = new AWSSecurityGroupClient(ec2Client);
secGroupWaitContext.complete();
});
secGroupWaitContext.await();
this.host.setTimeoutSeconds(this.timeoutSeconds);
this.endpointState = createEndpointState();
String vm1 = "vm1";
String vm2 = "vm2";
if (!this.isMock) {
vm1 = provisionAWSVMWithEC2Client(this.host, this.ec2client, EC2_LINUX_AMI, this.subnetId, null);
this.instancesToCleanUp.add(vm1);
vm2 = provisionAWSVMWithEC2Client(this.host, this.ec2client, EC2_LINUX_AMI, this.subnetId, null);
this.instancesToCleanUp.add(vm2);
}
this.cs1 = createComputeState(vm1);
this.cs2 = createComputeState(vm2);
} catch (Throwable e) {
this.host.log("Error starting up services for the test %s", e.getMessage());
throw new Exception(e);
}
}
Aggregations