Search in sources :

Example 36 with TestContext

use of com.vmware.xenon.common.test.TestContext in project photon-model by vmware.

the class AzurePowerServiceTest method createTaskResultListener.

private void createTaskResultListener(VerificationHost host, String taskLink, Function<Operation, Boolean> h) {
    StatelessService service = new StatelessService() {

        @Override
        public void handleRequest(Operation update) {
            if (!h.apply(update)) {
                super.handleRequest(update);
            }
        }
    };
    TestContext ctx = this.host.testCreate(1);
    Operation startOp = Operation.createPost(host, taskLink).setCompletion((o, e) -> {
        if (e != null) {
            ctx.failIteration(e);
            return;
        }
        ctx.completeIteration();
    }).setReferer(this.host.getReferer());
    this.host.startService(startOp, service);
    ctx.await();
}
Also used : PowerState(com.vmware.photon.controller.model.resources.ComputeService.PowerState) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) ProvisionComputeTaskService(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService) AzureTestUtil.deleteVMs(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.deleteVMs) PhotonModelServices(com.vmware.photon.controller.model.PhotonModelServices) VerificationHost(com.vmware.xenon.common.test.VerificationHost) AzureTestUtil.createDefaultResourcePool(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createDefaultResourcePool) AzureTestUtil.createDefaultComputeHost(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createDefaultComputeHost) After(org.junit.After) AzureEnvironment(com.microsoft.azure.AzureEnvironment) Assert.fail(org.junit.Assert.fail) URI(java.net.URI) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) AzureConstants(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants) DEFAULT_NIC_SPEC(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.DEFAULT_NIC_SPEC) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) StatelessService(com.vmware.xenon.common.StatelessService) ResourceOperationResponse(com.vmware.photon.controller.model.adapterapi.ResourceOperationResponse) TestUtils(com.vmware.photon.controller.model.tasks.TestUtils) UUID(java.util.UUID) AzureAdaptersTestUtils(com.vmware.photon.controller.model.adapters.azure.base.AzureAdaptersTestUtils) InstanceViewStatus(com.microsoft.azure.management.compute.InstanceViewStatus) UriUtils(com.vmware.xenon.common.UriUtils) Action(com.vmware.xenon.common.Service.Action) InstanceViewTypes(com.microsoft.azure.management.compute.InstanceViewTypes) TaskState(com.vmware.xenon.common.TaskState) Assume.assumeFalse(org.junit.Assume.assumeFalse) PhotonModelMetricServices(com.vmware.photon.controller.model.PhotonModelMetricServices) ResourcePoolState(com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState) Function(java.util.function.Function) ProvisionComputeTaskState(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState) AzureTestUtil.createDefaultVMResource(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createDefaultVMResource) Level(java.util.logging.Level) AzureTestUtil.createDefaultAuthCredentials(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createDefaultAuthCredentials) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) TestName(org.junit.rules.TestName) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) BasicReusableHostTestCase(com.vmware.xenon.common.BasicReusableHostTestCase) AzureTestUtil(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil) Before(org.junit.Before) ComputePowerRequest(com.vmware.photon.controller.model.adapterapi.ComputePowerRequest) PhotonModelTaskServices(com.vmware.photon.controller.model.tasks.PhotonModelTaskServices) ComputeManagementClientImpl(com.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl) Assert.assertNotNull(org.junit.Assert.assertNotNull) Operation(com.vmware.xenon.common.Operation) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Rule(org.junit.Rule) TestContext(com.vmware.xenon.common.test.TestContext) PhotonModelAdaptersRegistryAdapters(com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersRegistryAdapters) AzureTestUtil.generateName(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.generateName) AzureTestUtil.createDefaultEndpointState(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createDefaultEndpointState) ApplicationTokenCredentials(com.microsoft.azure.credentials.ApplicationTokenCredentials) Assert.assertEquals(org.junit.Assert.assertEquals) StatelessService(com.vmware.xenon.common.StatelessService) TestContext(com.vmware.xenon.common.test.TestContext) Operation(com.vmware.xenon.common.Operation)

Example 37 with TestContext

use of com.vmware.xenon.common.test.TestContext in project photon-model by vmware.

the class AzureInstanceTypeServiceTest method testGetInstanceTypes.

@Test
public void testGetInstanceTypes() throws Throwable {
    Assume.assumeFalse(this.isMock);
    TestContext ctx = getHost().testCreate(1);
    URI uri = buildUri(getHost(), AzureInstanceTypeService.SELF_LINK, buildUriQuery("endpoint", this.endpointState.documentSelfLink));
    send(Operation.createGet(uri).setCompletion((op, t) -> {
        try {
            if (t != null) {
                ctx.failIteration(t);
                return;
            }
            assertEquals(Operation.STATUS_CODE_OK, op.getStatusCode());
            InstanceTypeList instanceTypesList = op.getBody(InstanceTypeList.class);
            assertNotNull("Tenant links should ne set.", instanceTypesList.tenantLinks);
            assertEquals("Tenant links size equal to endpoint tenant links size is " + "expected.", this.endpointState.tenantLinks.size(), instanceTypesList.tenantLinks.size());
            assertNotNull("Instance types should not be null.", instanceTypesList.instanceTypes);
            InstanceType instanceTypeBasicA0 = instanceTypesList.instanceTypes.stream().filter(instanceType -> VirtualMachineSizeTypes.BASIC_A0.toString().equals(instanceType.name)).findFirst().get();
            assertNotNull("BASIC_A0 Instance type should not be null.", instanceTypeBasicA0);
            final String regionId = this.endpointState.endpointProperties.get(EndpointConfigRequest.REGION_KEY);
            final List<VirtualMachineSizeInner> azureSizes = getAzureSdkClients().getComputeManager().inner().virtualMachineSizes().list(regionId);
            assertEquals(azureSizes.size(), instanceTypesList.instanceTypes.size());
            VirtualMachineSizeInner azureSizeBasicA0 = azureSizes.stream().filter(azureSize -> VirtualMachineSizeTypes.BASIC_A0.toString().equals(azureSize.name())).findFirst().get();
            assertEquals("Invalid cpuCount", azureSizeBasicA0.numberOfCores(), instanceTypeBasicA0.cpuCount);
            assertEquals("Invalid dataDiskMaxCount", azureSizeBasicA0.maxDataDiskCount(), instanceTypeBasicA0.dataDiskMaxCount);
            assertEquals("Invalid dataDiskSizeInMB", azureSizeBasicA0.resourceDiskSizeInMB(), instanceTypeBasicA0.dataDiskSizeInMB);
            assertEquals("Invalid bootDiskSizeInMB", azureSizeBasicA0.osDiskSizeInMB(), instanceTypeBasicA0.bootDiskSizeInMB);
            assertEquals("Invalid memoryInMB", azureSizeBasicA0.memoryInMB(), instanceTypeBasicA0.memoryInMB);
            ctx.completeIteration();
        } catch (AssertionError err) {
            ctx.failIteration(err);
        }
    }));
    testWait(ctx);
}
Also used : Assert.assertNotNull(org.junit.Assert.assertNotNull) Operation(com.vmware.xenon.common.Operation) TestUtils(com.vmware.photon.controller.model.tasks.TestUtils) ServiceDocument(com.vmware.xenon.common.ServiceDocument) Test(org.junit.Test) VirtualMachineSizeTypes(com.microsoft.azure.management.compute.VirtualMachineSizeTypes) AzureBaseTest(com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest) VirtualMachineSizeInner(com.microsoft.azure.management.compute.implementation.VirtualMachineSizeInner) InstanceType(com.vmware.photon.controller.model.support.InstanceTypeList.InstanceType) List(java.util.List) EndpointConfigRequest(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest) TestContext(com.vmware.xenon.common.test.TestContext) EndpointService(com.vmware.photon.controller.model.resources.EndpointService) UriUtils(com.vmware.xenon.common.UriUtils) UriUtils.buildUri(com.vmware.xenon.common.UriUtils.buildUri) InstanceTypeList(com.vmware.photon.controller.model.support.InstanceTypeList) Assume(org.junit.Assume) URI(java.net.URI) UriUtils.buildUriQuery(com.vmware.xenon.common.UriUtils.buildUriQuery) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) TestContext(com.vmware.xenon.common.test.TestContext) List(java.util.List) InstanceTypeList(com.vmware.photon.controller.model.support.InstanceTypeList) InstanceType(com.vmware.photon.controller.model.support.InstanceTypeList.InstanceType) URI(java.net.URI) VirtualMachineSizeInner(com.microsoft.azure.management.compute.implementation.VirtualMachineSizeInner) InstanceTypeList(com.vmware.photon.controller.model.support.InstanceTypeList) Test(org.junit.Test) AzureBaseTest(com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest)

Example 38 with TestContext

use of com.vmware.xenon.common.test.TestContext in project photon-model by vmware.

the class AzureLifecycleOperationServiceTest method triggerRestart.

private void triggerRestart() {
    String taskLink = UUID.randomUUID().toString();
    ResourceOperationRequest request = new ResourceOperationRequest();
    request.isMockRequest = this.isMock;
    request.operation = ResourceOperation.RESTART.operation;
    request.resourceReference = UriUtils.buildUri(this.host, this.vmState.documentSelfLink);
    request.taskReference = UriUtils.buildUri(this.host, taskLink);
    TestContext ctx = this.host.testCreate(2);
    createTaskResultListener(this.host, taskLink, (u) -> {
        if (u.getAction() != Action.PATCH) {
            return false;
        }
        ResourceOperationResponse response = u.getBody(ResourceOperationResponse.class);
        if (TaskState.isFailed(response.taskInfo)) {
            ctx.failIteration(new IllegalStateException(response.taskInfo.failure.message));
        } else if (TaskState.isFinished(response.taskInfo)) {
            ctx.completeIteration();
        }
        return true;
    });
    Operation restartOp = Operation.createPatch(UriUtils.buildUri(this.host, AzureLifecycleOperationService.SELF_LINK)).setBody(request).setReferer("/tests").setCompletion((o, e) -> {
        if (e != null) {
            ctx.failIteration(e);
            return;
        }
        ctx.completeIteration();
    });
    this.host.send(restartOp);
    ctx.await();
}
Also used : ResourceOperationResponse(com.vmware.photon.controller.model.adapterapi.ResourceOperationResponse) TestContext(com.vmware.xenon.common.test.TestContext) ResourceOperationRequest(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest) Operation(com.vmware.xenon.common.Operation) ResourceOperation(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation)

Example 39 with TestContext

use of com.vmware.xenon.common.test.TestContext in project photon-model by vmware.

the class AzureLifecycleOperationServiceTest method triggerSuspend.

private void triggerSuspend() {
    String taskLink = UUID.randomUUID().toString();
    ResourceOperationRequest request = new ResourceOperationRequest();
    request.isMockRequest = this.isMock;
    request.operation = ResourceOperation.SUSPEND.operation;
    request.resourceReference = UriUtils.buildUri(this.host, this.vmState.documentSelfLink);
    request.taskReference = UriUtils.buildUri(this.host, taskLink);
    TestContext ctx = this.host.testCreate(2);
    createTaskResultListener(this.host, taskLink, (u) -> {
        if (u.getAction() != Action.PATCH) {
            return false;
        }
        ResourceOperationResponse response = u.getBody(ResourceOperationResponse.class);
        if (TaskState.isFailed(response.taskInfo)) {
            ctx.failIteration(new IllegalStateException(response.taskInfo.failure.message));
        } else if (TaskState.isFinished(response.taskInfo)) {
            ctx.completeIteration();
        }
        return true;
    });
    Operation restartOp = Operation.createPatch(UriUtils.buildUri(this.host, AzureLifecycleOperationService.SELF_LINK)).setBody(request).setReferer("/tests2").setCompletion((o, e) -> {
        if (e != null) {
            ctx.failIteration(e);
            return;
        }
        ctx.completeIteration();
    });
    this.host.send(restartOp);
    ctx.await();
}
Also used : ResourceOperationResponse(com.vmware.photon.controller.model.adapterapi.ResourceOperationResponse) TestContext(com.vmware.xenon.common.test.TestContext) ResourceOperationRequest(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest) Operation(com.vmware.xenon.common.Operation) ResourceOperation(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation)

Example 40 with TestContext

use of com.vmware.xenon.common.test.TestContext 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();
}
Also used : Arrays(java.util.Arrays) DetachVolumeRequest(com.amazonaws.services.ec2.model.DetachVolumeRequest) AWSResourceType.ec2_vpc(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType.ec2_vpc) TestAWSSetupUtils.createAWSComputeHost(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.createAWSComputeHost) AttachVolumeRequest(com.amazonaws.services.ec2.model.AttachVolumeRequest) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) VerificationHost(com.vmware.xenon.common.test.VerificationHost) LifecycleState(com.vmware.photon.controller.model.resources.ComputeService.LifecycleState) TestAWSSetupUtils.createAWSEndpointState(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.createAWSEndpointState) TestAWSSetupUtils.createAWSResourcePool(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.createAWSResourcePool) TestAWSSetupUtils.provisionAWSVMWithEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.provisionAWSVMWithEC2Client) TestAWSSetupUtils.tearDownTestVpc(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.tearDownTestVpc) TagSet(com.amazonaws.services.s3.model.TagSet) TestAWSSetupUtils.provisionAWSLoadBalancerWithEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.provisionAWSLoadBalancerWithEC2Client) Utils(com.vmware.xenon.common.Utils) BlockDeviceMapping(com.amazonaws.services.ec2.model.BlockDeviceMapping) LoadBalancerState(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Duration(java.time.Duration) Map(java.util.Map) TestUtils.getExecutor(com.vmware.photon.controller.model.adapters.awsadapter.TestUtils.getExecutor) ProvisioningUtils.queryDocumentsAndAssertExpectedCount(com.vmware.photon.controller.model.tasks.ProvisioningUtils.queryDocumentsAndAssertExpectedCount) ServiceDocumentQueryResult(com.vmware.xenon.common.ServiceDocumentQueryResult) TestAWSSetupUtils.enumerateResources(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.enumerateResources) TestAWSSetupUtils.tearDownTestDisk(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.tearDownTestDisk) TestAWSSetupUtils.waitForInstancesToBeTerminated(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.waitForInstancesToBeTerminated) ProvisioningUtils(com.vmware.photon.controller.model.tasks.ProvisioningUtils) SubnetService(com.vmware.photon.controller.model.resources.SubnetService) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) Set(java.util.Set) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) NetworkInterfaceService(com.vmware.photon.controller.model.resources.NetworkInterfaceService) TagService(com.vmware.photon.controller.model.resources.TagService) Assert.assertFalse(org.junit.Assert.assertFalse) Tag(com.amazonaws.services.ec2.model.Tag) UriUtils(com.vmware.xenon.common.UriUtils) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) TestAWSSetupUtils.enumerateResourcesPreserveMissing(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.enumerateResourcesPreserveMissing) TestAWSSetupUtils.getComputeByAWSId(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.getComputeByAWSId) TestUtils.doPatch(com.vmware.photon.controller.model.tasks.TestUtils.doPatch) PhotonModelMetricServices(com.vmware.photon.controller.model.PhotonModelMetricServices) ResourcePoolState(com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) StringUtil(io.netty.util.internal.StringUtil) TagsUtil(com.vmware.photon.controller.model.adapters.util.TagsUtil) TestAWSSetupUtils.getNICByAWSId(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.getNICByAWSId) ArrayList(java.util.ArrayList) Regions(com.amazonaws.regions.Regions) SecurityGroupState(com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState) ServiceUriPaths(com.vmware.xenon.services.common.ServiceUriPaths) AWSUtils.unTagResources(com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.unTagResources) TagState(com.vmware.photon.controller.model.resources.TagService.TagState) Query(com.vmware.xenon.services.common.QueryTask.Query) UriPaths(com.vmware.photon.controller.model.UriPaths) TestName(org.junit.rules.TestName) TestAWSSetupUtils.getLoadBalancerByAWSId(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.getLoadBalancerByAWSId) Before(org.junit.Before) TestAWSSetupUtils.stopVMsUsingEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.stopVMsUsingEC2Client) TestAWSSetupUtils.createAWSAuthentication(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.createAWSAuthentication) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) TestAWSSetupUtils.createNICDirectlyWithEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.createNICDirectlyWithEC2Client) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) SecurityGroupService(com.vmware.photon.controller.model.resources.SecurityGroupService) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AWS_VPC_ID(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_VPC_ID) EC2_WINDOWS_AMI(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.EC2_WINDOWS_AMI) NetworkService(com.vmware.photon.controller.model.resources.NetworkService) TestContext(com.vmware.xenon.common.test.TestContext) AWSUtils.tagResourcesWithName(com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.tagResourcesWithName) CUSTOM_OS_TYPE(com.vmware.photon.controller.model.ComputeProperties.CUSTOM_OS_TYPE) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) ProvisioningUtils.queryComputeInstances(com.vmware.photon.controller.model.tasks.ProvisioningUtils.queryComputeInstances) TestAWSSetupUtils.setAwsClientMockInfo(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.setAwsClientMockInfo) RegionEnumerationResponse(com.vmware.photon.controller.model.adapterapi.RegionEnumerationResponse) NetworkState(com.vmware.photon.controller.model.resources.NetworkService.NetworkState) VolumeType(com.amazonaws.services.ec2.model.VolumeType) Assert.assertEquals(org.junit.Assert.assertEquals) AmazonEC2AsyncClient(com.amazonaws.services.ec2.AmazonEC2AsyncClient) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) EC2_LINUX_AMI(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.EC2_LINUX_AMI) TestAWSSetupUtils.deleteVMsUsingEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.deleteVMsUsingEC2Client) BucketTaggingConfiguration(com.amazonaws.services.s3.model.BucketTaggingConfiguration) AWSResourceType(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType) QueryTask(com.vmware.xenon.services.common.QueryTask) PhotonModelServices(com.vmware.photon.controller.model.PhotonModelServices) OSType(com.vmware.photon.controller.model.ComputeProperties.OSType) TestAWSSetupUtils.setUpTestVpc(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.setUpTestVpc) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) CommandLineArgumentParser(com.vmware.xenon.common.CommandLineArgumentParser) CreateVolumeRequest(com.amazonaws.services.ec2.model.CreateVolumeRequest) After(org.junit.After) AWSResourceType.ec2_subnet(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType.ec2_subnet) Assert.fail(org.junit.Assert.fail) URI(java.net.URI) TestAWSSetupUtils.getInternalTagsByType(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.getInternalTagsByType) TagsUtil.newTagState(com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState) TestAWSSetupUtils.provisionAWSEBSVMWithEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.provisionAWSEBSVMWithEC2Client) AwsNicSpecs(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.AwsNicSpecs) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) TestAWSSetupUtils.waitForProvisioningToComplete(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.waitForProvisioningToComplete) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) CompletionException(java.util.concurrent.CompletionException) TestAWSSetupUtils.deleteLBsUsingLBClient(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.deleteLBsUsingLBClient) UUID(java.util.UUID) TestUtils.getSubnetStates(com.vmware.photon.controller.model.adapters.awsadapter.TestUtils.getSubnetStates) Collectors(java.util.stream.Collectors) ServiceHost(com.vmware.xenon.common.ServiceHost) AWS_GATEWAY_ID(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_GATEWAY_ID) TestAWSSetupUtils.deleteNICDirectlyWithEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.deleteNICDirectlyWithEC2Client) AmazonElasticLoadBalancingAsyncClient(com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingAsyncClient) List(java.util.List) EbsBlockDevice(com.amazonaws.services.ec2.model.EbsBlockDevice) TestAWSSetupUtils.setUpTestVolume(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.setUpTestVolume) TAG_KEY_TYPE(com.vmware.photon.controller.model.constants.PhotonModelConstants.TAG_KEY_TYPE) Entry(java.util.Map.Entry) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) DiskService(com.vmware.photon.controller.model.resources.DiskService) TestAWSSetupUtils.addNICDirectlyWithEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.addNICDirectlyWithEC2Client) TestAWSSetupUtils.deleteVMsOnThisEndpoint(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.deleteVMsOnThisEndpoint) AWSResourceType.ec2_instance(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType.ec2_instance) BasicTestCase(com.vmware.xenon.common.BasicTestCase) RouteConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration) HashMap(java.util.HashMap) AWSUtils.tagResources(com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.tagResources) TestAWSSetupUtils.zoneId(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.zoneId) TestAWSSetupUtils.detachNICDirectlyWithEC2Client(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.detachNICDirectlyWithEC2Client) AWSConstants.setQueryPageSize(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.setQueryPageSize) Level(java.util.logging.Level) CreateVolumeResult(com.amazonaws.services.ec2.model.CreateVolumeResult) AWSResourceType.ec2_net_interface(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType.ec2_net_interface) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) AWS_VPC_ROUTE_TABLE_ID(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_VPC_ROUTE_TABLE_ID) PhotonModelTaskServices(com.vmware.photon.controller.model.tasks.PhotonModelTaskServices) ENABLE_LOAD_BALANCER_PROPERTY(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSLoadBalancerEnumerationAdapterService.ENABLE_LOAD_BALANCER_PROPERTY) Assert.assertNotNull(org.junit.Assert.assertNotNull) Operation(com.vmware.xenon.common.Operation) AWSConstants.setQueryResultLimit(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.setQueryResultLimit) ProvisioningUtils.queryAllFactoryResources(com.vmware.photon.controller.model.tasks.ProvisioningUtils.queryAllFactoryResources) TestAWSSetupUtils.instanceType(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.instanceType) TestAWSSetupUtils.createAWSVMResource(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.createAWSVMResource) Rule(org.junit.Rule) PhotonModelAdaptersRegistryAdapters(com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersRegistryAdapters) DeleteVolumeRequest(com.amazonaws.services.ec2.model.DeleteVolumeRequest) TestAWSSetupUtils.regionId(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.regionId) TestAWSSetupUtils.provisionMachine(com.vmware.photon.controller.model.adapters.awsadapter.TestAWSSetupUtils.provisionMachine) Collections(java.util.Collections) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) TestContext(com.vmware.xenon.common.test.TestContext) CompletionException(java.util.concurrent.CompletionException) CompletionException(java.util.concurrent.CompletionException) Before(org.junit.Before)

Aggregations

TestContext (com.vmware.xenon.common.test.TestContext)43 Operation (com.vmware.xenon.common.Operation)37 Test (org.junit.Test)18 ResourceOperationResponse (com.vmware.photon.controller.model.adapterapi.ResourceOperationResponse)14 UriUtils (com.vmware.xenon.common.UriUtils)13 AuthCredentialsServiceState (com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState)13 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)12 After (org.junit.After)12 Assert.assertEquals (org.junit.Assert.assertEquals)12 Before (org.junit.Before)12 CompletionException (java.util.concurrent.CompletionException)11 AmazonEC2AsyncClient (com.amazonaws.services.ec2.AmazonEC2AsyncClient)10 ResourceOperation (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation)10 ResourceOperationRequest (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest)10 CommandLineArgumentParser (com.vmware.xenon.common.CommandLineArgumentParser)10 ArrayList (java.util.ArrayList)10 List (java.util.List)10 Duration (java.time.Duration)9 HashMap (java.util.HashMap)9 Level (java.util.logging.Level)9