Search in sources :

Example 26 with InstanceGroupType

use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataWithCCMV2.

@Test
public void testBuildUserDataWithCCMV2() throws IOException {
    CcmV2Parameters ccmV2Parameters = new DefaultCcmV2Parameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate");
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2Parameters);
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", ccmConnectivityParameters, null);
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-ccm-init.sh");
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-ccm-v2-init.sh");
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) CcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Test(org.junit.Test)

Example 27 with InstanceGroupType

use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataAzureWithNoAuthProxy.

@Test
public void testBuildUserDataAzureWithNoAuthProxy() throws IOException {
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-init-noauthproxy.sh");
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-init.sh");
    ProxyConfig proxyConfig = ProxyConfig.builder().withServerHost("proxy.host").withServerPort(1234).withNoProxyHosts("noproxy.com").withProtocol("http").build();
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", new CcmConnectivityParameters(), proxyConfig);
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) Test(org.junit.Test)

Example 28 with InstanceGroupType

use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataWithCCMV2Jumpgate.

@Test
public void testBuildUserDataWithCCMV2Jumpgate() throws IOException {
    CcmV2JumpgateParameters ccmV2JumpgateParameters = new DefaultCcmV2JumpgateParameters();
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2JumpgateParameters);
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", ccmConnectivityParameters, null);
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-ccm-init.sh");
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-ccm-v2-jumpgate-init.sh");
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters) Test(org.junit.Test)

Example 29 with InstanceGroupType

use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataAzureWithAuthProxy.

@Test
public void testBuildUserDataAzureWithAuthProxy() throws IOException {
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-init-authproxy.sh");
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-init.sh");
    ProxyAuthentication proxyAuthentication = ProxyAuthentication.builder().withUserName("user").withPassword("pwd").build();
    ProxyConfig proxyConfig = ProxyConfig.builder().withServerHost("proxy.host").withServerPort(1234).withProxyAuthentication(proxyAuthentication).withNoProxyHosts("noproxy.com").withProtocol("https").build();
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", new CcmConnectivityParameters(), proxyConfig);
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) ProxyAuthentication(com.sequenceiq.cloudbreak.dto.ProxyAuthentication) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) Test(org.junit.Test)

Example 30 with InstanceGroupType

use of com.sequenceiq.common.api.type.InstanceGroupType in project cloudbreak by hortonworks.

the class ComponentTestUtil method getStack.

public CloudStack getStack(InstanceStatus workerStatuses, InstanceStatus masterStatus) throws IOException {
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication(PUBLIC_KEY, "pubkeyid", LOGIN_USER_NAME);
    Security security = getSecurity();
    List<CloudInstance> masterInstances = List.of(getCloudInstance(instanceAuthentication, "master", masterStatus, 0L, null));
    List<CloudInstance> workerInstances = List.of(getCloudInstance(instanceAuthentication, "worker", workerStatuses, 0L, null), getCloudInstance(instanceAuthentication, "worker", workerStatuses, 1L, null), getCloudInstance(instanceAuthentication, "worker", InstanceStatus.STARTED, 2L, INSTANCE_ID_3));
    List<Group> groups = List.of(new Group("master", InstanceGroupType.CORE, masterInstances, security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), ROOT_VOLUME_SIZE, Optional.empty(), createGroupNetwork(), emptyMap()), new Group("worker", InstanceGroupType.CORE, workerInstances, security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), ROOT_VOLUME_SIZE, Optional.empty(), createGroupNetwork(), emptyMap()));
    Network network = new Network(new Subnet(CIDR));
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, CORE_CUSTOM_DATA, InstanceGroupType.GATEWAY, GATEWAY_CUSTOM_DATA);
    Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    String template = configuration.getTemplate(LATEST_AWS_CLOUD_FORMATION_TEMPLATE_PATH, "UTF-8").toString();
    return new CloudStack(groups, network, image, Map.of(), Map.of(), template, instanceAuthentication, LOGIN_USER_NAME, PUBLIC_KEY, null);
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) GroupNetwork(com.sequenceiq.cloudbreak.cloud.model.GroupNetwork) Network(com.sequenceiq.cloudbreak.cloud.model.Network) Subnet(com.sequenceiq.cloudbreak.cloud.model.Subnet)

Aggregations

InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)31 Image (com.sequenceiq.cloudbreak.cloud.model.Image)17 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)10 HashMap (java.util.HashMap)10 Test (org.junit.Test)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)8 Network (com.sequenceiq.cloudbreak.cloud.model.Network)8 Security (com.sequenceiq.cloudbreak.cloud.model.Security)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)7 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)7 Group (com.sequenceiq.cloudbreak.cloud.model.Group)6 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)5 Json (com.sequenceiq.cloudbreak.common.json.Json)5 GroupNetwork (com.sequenceiq.cloudbreak.cloud.model.GroupNetwork)4 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)4 PortDefinition (com.sequenceiq.cloudbreak.cloud.model.PortDefinition)4 SecurityRule (com.sequenceiq.cloudbreak.cloud.model.SecurityRule)4 Volume (com.sequenceiq.cloudbreak.cloud.model.Volume)4