Search in sources :

Example 1 with StackCreationMock

use of com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock in project cloudbreak by hortonworks.

the class MockStackCreationV2Test method testStackCreation.

@Test
public void testStackCreation() throws Exception {
    // GIVEN
    // WHEN
    super.testStackCreation();
    // THEN
    StackCreationMock stackCreationMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, StackCreationMock.class);
    String stackName = getItContext().getContextParam(CloudbreakV2Constants.STACK_NAME);
    stackCreationMock.verifyCalls(stackName);
    StackV2Request stackV2Request = getItContext().getContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, StackV2Request.class);
    AmbariV2Request ambariV2Request = stackV2Request.getCluster().getAmbari();
    if (ambariV2Request.getEnableSecurity()) {
        KerberosRequest kerberosRequest = ambariV2Request.getKerberos();
        stackCreationMock.verifyKerberosCalls(stackName, kerberosRequest.getAdmin(), kerberosRequest.getPassword());
    }
}
Also used : StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) AmbariV2Request(com.sequenceiq.cloudbreak.api.model.v2.AmbariV2Request) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) Test(org.testng.annotations.Test) AbstractStackCreationV2Test(com.sequenceiq.it.cloudbreak.v2.AbstractStackCreationV2Test)

Example 2 with StackCreationMock

use of com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock in project cloudbreak by hortonworks.

the class MockClusterCreationWithSaltSuccessTest method configMockServer.

@BeforeClass
@Parameters({ "clusterName", "mockPort", "sshPort" })
public void configMockServer(String clusterName, @Optional("9443") int mockPort, @Optional("2020") int sshPort) {
    IntegrationTestContext itContext = getItContext();
    Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
    if (instanceMap == null || instanceMap.isEmpty()) {
        throw new IllegalStateException("instance map should not be empty!");
    }
    StackCreationMock stackCreationMock = (StackCreationMock) applicationContext.getBean(StackCreationMock.NAME, mockPort, sshPort, instanceMap);
    stackCreationMock.addSaltMappings();
    stackCreationMock.addAmbariMappings(clusterName);
    itContext.putContextParam(CloudbreakV2Constants.MOCK_SERVER, stackCreationMock);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) StackCreationMock(com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock) BeforeClass(org.testng.annotations.BeforeClass) Parameters(org.testng.annotations.Parameters)

Example 3 with StackCreationMock

use of com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock in project cloudbreak by hortonworks.

the class MockClusterCreationWithSaltSuccessTest method testClusterCreation.

@Test
@Parameters({ "clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser, @Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackId = Integer.valueOf(stackIdStr);
    Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
    List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
    Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts);
    itContext.putContextParam(CloudbreakITContextConstants.AMBARI_USER_ID, ambariUser);
    itContext.putContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID, ambariPassword);
    // WHEN
    ClusterRequest clusterRequest = new ClusterRequest();
    clusterRequest.setName(clusterName);
    clusterRequest.setDescription("Cluster for integration test");
    clusterRequest.setEmailNeeded(emailNeeded);
    clusterRequest.setEnableSecurity(enableSecurity);
    clusterRequest.setPassword(ambariPassword);
    clusterRequest.setUserName(ambariUser);
    clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
    clusterRequest.setHostGroups(hostGroupJsons1);
    if (enableSecurity) {
        KerberosRequest kerberosRequest = new KerberosRequest();
        kerberosRequest.setAdmin(kerberosAdmin);
        kerberosRequest.setPassword(kerberosPassword);
        kerberosRequest.setMasterKey(kerberosMasterKey);
        clusterRequest.setKerberos(kerberosRequest);
    }
    GatewayJson gatewayJson = new GatewayJson();
    gatewayJson.setEnableGateway(Boolean.TRUE);
    gatewayJson.setExposedServices(ImmutableList.of("ALL"));
    clusterRequest.setGateway(gatewayJson);
    ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
    Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
    // THEN
    Assert.assertNotNull(clusterId);
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
    CloudbreakUtil.checkClusterAvailability(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackIdStr, ambariUser, ambariPassword, checkAmbari);
    StackCreationMock stackCreationMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, StackCreationMock.class);
    stackCreationMock.verifyCalls(clusterName);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.it.cloudbreak.HostGroup) ClusterV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) StackCreationMock(com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 4 with StackCreationMock

use of com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock in project cloudbreak by hortonworks.

the class MockKerberizedClusterCreationTest method testClusterCreation.

@Test
@Parameters({ "clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser, @Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded, @Optional("true") boolean enableSecurity, @Optional(DEFAULT_KERBEROS_PASSWORD) String kerberosMasterKey, @Optional(DEFAULT_KERBEROS_ADMIN) String kerberosAdmin, @Optional(DEFAULT_KERBEROS_PASSWORD) String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
    // GIVEN
    // WHEN
    super.testClusterCreation(clusterName, ambariPort, ambariUser, ambariPassword, emailNeeded, enableSecurity, kerberosMasterKey, kerberosAdmin, kerberosPassword, runRecipesOnHosts, checkAmbari, mockPort);
    // THEN
    StackCreationMock stackCreationMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, StackCreationMock.class);
    stackCreationMock.verifyKerberosCalls(clusterName, kerberosAdmin, kerberosPassword);
}
Also used : StackCreationMock(com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 5 with StackCreationMock

use of com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock in project cloudbreak by hortonworks.

the class MockStackCreationWithSaltSuccessTest method breakDown.

@AfterClass
public void breakDown() {
    StackCreationMock stackCreationMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, StackCreationMock.class);
    stackCreationMock.stop();
}
Also used : StackCreationMock(com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock) AfterClass(org.testng.annotations.AfterClass)

Aggregations

StackCreationMock (com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock)6 Parameters (org.testng.annotations.Parameters)4 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)3 Test (org.testng.annotations.Test)3 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)2 AfterClass (org.testng.annotations.AfterClass)2 BeforeClass (org.testng.annotations.BeforeClass)2 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)1 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)1 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)1 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)1 AmbariV2Request (com.sequenceiq.cloudbreak.api.model.v2.AmbariV2Request)1 StackV2Request (com.sequenceiq.cloudbreak.api.model.v2.StackV2Request)1 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)1 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)1 HostGroup (com.sequenceiq.it.cloudbreak.HostGroup)1 InstanceGroup (com.sequenceiq.it.cloudbreak.InstanceGroup)1 AbstractStackCreationV2Test (com.sequenceiq.it.cloudbreak.v2.AbstractStackCreationV2Test)1