Search in sources :

Example 6 with EnvironmentNetworkMockParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams in project cloudbreak by hortonworks.

the class MockCloudProvider method getMockNetworkParams.

private EnvironmentNetworkMockParams getMockNetworkParams() {
    EnvironmentNetworkMockParams environmentNetworkMockParams = new EnvironmentNetworkMockParams();
    environmentNetworkMockParams.setInternetGatewayId(getInternetGatewayId());
    environmentNetworkMockParams.setVpcId(getVpcId());
    return environmentNetworkMockParams;
}
Also used : EnvironmentNetworkMockParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams)

Example 7 with EnvironmentNetworkMockParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams in project cloudbreak by hortonworks.

the class MockCloudProvider method environmentNetworkParameters.

private EnvironmentNetworkMockParams environmentNetworkParameters() {
    EnvironmentNetworkMockParams params = new EnvironmentNetworkMockParams();
    params.setVpcId(getVpcId());
    params.setInternetGatewayId(getInternetGatewayId());
    return params;
}
Also used : EnvironmentNetworkMockParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams)

Example 8 with EnvironmentNetworkMockParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams in project cloudbreak by hortonworks.

the class MockSdxRepairTests method repairTerminatedMasterAndItFailedButInstanceShouldBeDeletedOnProviderSide.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running Cloudbreak", when = "terminate instances and repair an sdx cluster", then = "repair should fail and repaired instance should be in deleted on provider side")
public void repairTerminatedMasterAndItFailedButInstanceShouldBeDeletedOnProviderSide(MockedTestContext testContext) {
    String sdxInternal = resourcePropertyProvider().getName();
    String networkKey = "someOtherNetwork";
    SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
    sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NON_HA);
    CustomDomainSettingsV4Request customDomain = new CustomDomainSettingsV4Request();
    customDomain.setDomainName("dummydomainname");
    customDomain.setHostname("dummyhostname");
    customDomain.setClusterNameAsSubdomain(true);
    customDomain.setHostgroupNameAsHostname(true);
    testContext.given(networkKey, EnvironmentNetworkTestDto.class).withMock(new EnvironmentNetworkMockParams()).given(EnvironmentTestDto.class).withNetwork(networkKey).withCreateFreeIpa(Boolean.TRUE).withName(resourcePropertyProvider().getEnvironmentName()).when(getEnvironmentTestClient().create()).await(EnvironmentStatus.AVAILABLE).given(FreeIpaTestDto.class).when(freeIpaTestClient.create()).await(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE).given(sdxInternal, SdxInternalTestDto.class).withDatabase(sdxDatabaseRequest).withCustomDomain(customDomain).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).then((tc, testDto, client) -> {
        List<String> instancesToDelete = new ArrayList<>(sdxUtil.getInstanceIds(testDto, client, MASTER.getName()));
        instancesToDelete.forEach(instanceId -> getExecuteQueryToMockInfrastructure().call("/" + testDto.getCrn() + "/spi/" + instanceId + "/terminate", w -> w));
        getExecuteQueryToMockInfrastructure().executeMethod(Method.build("POST"), "/" + testDto.getCrn() + "/spi/disable_add_instance", new HashMap<>(), null, response -> {
        }, w -> w);
        return testDto;
    }).await(SdxClusterStatusResponse.NODE_FAILURE, pollingInterval(Duration.ofSeconds(POLLING_INTERVAL_FOR_REPAIR_SECONDS))).when(sdxTestClient.repairInternal(MASTER.getName()), key(sdxInternal)).awaitForMasterDeletedOnProvider().awaitForFlowFail().then((tc, testDto, client) -> {
        getExecuteQueryToMockInfrastructure().executeMethod(Method.build("POST"), "/" + testDto.getCrn() + "/spi/enable_add_instance", new HashMap<>(), null, response -> {
        }, w -> w);
        return testDto;
    }).when(sdxTestClient.repairInternal(MASTER.getName()), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).validate();
}
Also used : SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) EnvironmentNetworkMockParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) ArrayList(java.util.ArrayList) Description(com.sequenceiq.it.cloudbreak.context.Description) EnvironmentNetworkTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto) Inject(javax.inject.Inject) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) Duration(java.time.Duration) CustomDomainSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request) SdxUtil(com.sequenceiq.it.cloudbreak.util.SdxUtil) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) Method(com.sequenceiq.it.cloudbreak.dto.mock.Method) RunningParameter.pollingInterval(com.sequenceiq.it.cloudbreak.context.RunningParameter.pollingInterval) MASTER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER) IDBROKER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.IDBROKER) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) Consumer(java.util.function.Consumer) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) List(java.util.List) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) HostGroupType(com.sequenceiq.it.cloudbreak.cloud.HostGroupType) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) HashMap(java.util.HashMap) CustomDomainSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request) EnvironmentNetworkMockParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams) ArrayList(java.util.ArrayList) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 9 with EnvironmentNetworkMockParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams in project cloudbreak by hortonworks.

the class MockSdxRepairTests method testRepair.

public void testRepair(MockedTestContext testContext, List<HostGroupType> hostGroups, Consumer<String> actionOnNode, SdxClusterStatusResponse stateBeforeRepair) {
    String sdxInternal = resourcePropertyProvider().getName();
    String networkKey = "someOtherNetwork";
    SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
    sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NON_HA);
    CustomDomainSettingsV4Request customDomain = new CustomDomainSettingsV4Request();
    customDomain.setDomainName("dummydomainname");
    customDomain.setHostname("dummyhostname");
    customDomain.setClusterNameAsSubdomain(true);
    customDomain.setHostgroupNameAsHostname(true);
    testContext.given(networkKey, EnvironmentNetworkTestDto.class).withMock(new EnvironmentNetworkMockParams()).given(EnvironmentTestDto.class).withNetwork(networkKey).withCreateFreeIpa(Boolean.TRUE).withName(resourcePropertyProvider().getEnvironmentName()).when(getEnvironmentTestClient().create()).await(EnvironmentStatus.AVAILABLE).given(FreeIpaTestDto.class).when(freeIpaTestClient.create()).await(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE).given(sdxInternal, SdxInternalTestDto.class).withDatabase(sdxDatabaseRequest).withCustomDomain(customDomain).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).then((tc, testDto, client) -> {
        List<String> instancesToDelete = new ArrayList<>();
        for (HostGroupType hostGroupType : hostGroups) {
            instancesToDelete.addAll(sdxUtil.getInstanceIds(testDto, client, hostGroupType.getName()));
        }
        instancesToDelete.forEach(instanceId -> actionOnNode.accept("/" + testDto.getCrn() + "/spi/" + instanceId));
        return testDto;
    }).await(stateBeforeRepair, pollingInterval(Duration.ofSeconds(POLLING_INTERVAL_FOR_REPAIR_SECONDS))).when(sdxTestClient.repairInternal(hostGroups.stream().map(HostGroupType::getName).toArray(String[]::new)), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).validate();
}
Also used : HostGroupType(com.sequenceiq.it.cloudbreak.cloud.HostGroupType) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) CustomDomainSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request) EnvironmentNetworkMockParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams) ArrayList(java.util.ArrayList) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest)

Example 10 with EnvironmentNetworkMockParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams in project cloudbreak by hortonworks.

the class MockSdxTests method testCustomSDXCanBeCreatedThenDeletedSuccessfully.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running Cloudbreak", when = "a valid SDX Custom Create request is sent", then = "SDX should be available AND deletable")
public void testCustomSDXCanBeCreatedThenDeletedSuccessfully(MockedTestContext testContext) {
    String sdxCustom = resourcePropertyProvider().getName();
    String networkKey = "someNetwork";
    testContext.given(networkKey, EnvironmentNetworkTestDto.class).withMock(new EnvironmentNetworkMockParams()).given(EnvironmentTestDto.class).withNetwork(networkKey).withCreateFreeIpa(Boolean.FALSE).withName(resourcePropertyProvider().getEnvironmentName()).when(getEnvironmentTestClient().create()).await(EnvironmentStatus.AVAILABLE).given(sdxCustom, SdxCustomTestDto.class).withCustomInstanceGroup("master", "xlarge").when(sdxTestClient.createCustom(), key(sdxCustom)).await(SdxClusterStatusResponse.RUNNING, key(sdxCustom)).then(this::validateInstanceGroupInstanceTypeIsModified).then((tc, testDto, client) -> sdxTestClient.deleteCustom().action(tc, testDto, client)).await(SdxClusterStatusResponse.DELETED, key(sdxCustom)).validate();
}
Also used : EnvironmentNetworkTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) SdxCustomTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxCustomTestDto) EnvironmentNetworkMockParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Aggregations

EnvironmentNetworkMockParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams)15 Description (com.sequenceiq.it.cloudbreak.context.Description)10 Test (org.testng.annotations.Test)10 EnvironmentNetworkTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto)9 EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)9 SdxInternalTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto)6 FreeIpaTestDto (com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto)4 CustomDomainSettingsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request)2 HostGroupType (com.sequenceiq.it.cloudbreak.cloud.HostGroupType)2 ImageSettingsTestDto (com.sequenceiq.it.cloudbreak.dto.ImageSettingsTestDto)2 SdxDatabaseRequest (com.sequenceiq.sdx.api.model.SdxDatabaseRequest)2 ArrayList (java.util.ArrayList)2 EnvironmentStatus (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus)1 FreeIpaTestClient (com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient)1 SdxTestClient (com.sequenceiq.it.cloudbreak.client.SdxTestClient)1 IDBROKER (com.sequenceiq.it.cloudbreak.cloud.HostGroupType.IDBROKER)1 MASTER (com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER)1 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)1 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)1 RunningParameter.pollingInterval (com.sequenceiq.it.cloudbreak.context.RunningParameter.pollingInterval)1