Search in sources :

Example 11 with VerificationHost

use of com.vmware.xenon.common.test.VerificationHost 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 12 with VerificationHost

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

the class ResolveCertificateUtil method setUp.

@Before
public void setUp() throws Throwable {
    VerificationHost HOST = VerificationHost.create(Integer.valueOf(0));
    HOST.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS.toMicros(250L));
    CommandLineArgumentParser.parseFromProperties(HOST);
    HOST.setStressTest(HOST.isStressTest);
    HOST.start();
    ServerX509TrustManager.init(HOST);
}
Also used : VerificationHost(com.vmware.xenon.common.test.VerificationHost) Before(org.junit.Before)

Aggregations

VerificationHost (com.vmware.xenon.common.test.VerificationHost)12 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)8 ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)7 ResourcePoolState (com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState)7 TestUtils (com.vmware.photon.controller.model.tasks.TestUtils)6 Operation (com.vmware.xenon.common.Operation)6 UriUtils (com.vmware.xenon.common.UriUtils)6 ArrayList (java.util.ArrayList)6 UUID (java.util.UUID)6 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)5 TaskState (com.vmware.xenon.common.TaskState)5 AuthCredentialsServiceState (com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState)5 Level (java.util.logging.Level)5 Assert.assertTrue (org.junit.Assert.assertTrue)5 Query (com.vmware.xenon.services.common.QueryTask.Query)4 HashMap (java.util.HashMap)4 ProvisionComputeTaskService (com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService)3 ProvisionComputeTaskState (com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState)3 AmazonEC2AsyncClient (com.amazonaws.services.ec2.AmazonEC2AsyncClient)2 InstanceViewTypes (com.microsoft.azure.management.compute.InstanceViewTypes)2