Search in sources :

Example 21 with InstanceGroupType

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

the class GcpAttachedDiskResourceBuilderTest method setUpBuild.

@BeforeEach
void setUpBuild() throws Exception {
    privateCrn = "crn";
    CloudContext cloudContext = CloudContext.Builder.builder().withId(privateId).withName("testname").withCrn("crn").withPlatform("GCP").withWorkspaceId(WORKSPACE_ID).build();
    CloudCredential cloudCredential = new CloudCredential(privateCrn, "credentialname", "account");
    cloudCredential.putParameter("projectId", "projectId");
    cloudInstance = new CloudInstance(instanceId, new InstanceTemplate("flavor", "group", 1L, new ArrayList<>(), InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 1L, "img", TemporaryStorage.ATTACHED_VOLUMES, 0L), new InstanceAuthentication("pub", "pub", "cb"), "subnet1", "az1");
    Location location = Location.location(Region.region("region"), AvailabilityZone.availabilityZone("az"));
    context = new GcpContext(cloudContext.getName(), location, "projectId", "serviceAccountId", compute, false, 30, false);
    List<CloudResource> networkResources = Collections.singletonList(new Builder().type(ResourceType.GCP_NETWORK).name("network-test").build());
    context.addNetworkResources(networkResources);
    privateId = 1L;
    name = "master";
    flavor = "m1.medium";
    instanceId = "SOME_ID";
    auth = new AuthenticatedContext(cloudContext, cloudCredential);
    params = Map.of();
    volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1, CloudVolumeUsageType.GENERAL), new Volume("/hadoop/fs2", "HDD", 1, CloudVolumeUsageType.GENERAL));
    List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[] { new PortDefinition("22", "22"), new PortDefinition("443", "443") }, "tcp"));
    security = new Security(rules, emptyList());
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
    InstanceTemplate instanceTemplate = new InstanceTemplate(flavor, name, privateId, volumes, InstanceStatus.CREATE_REQUESTED, params, 0L, "cb-centos66-amb200-2015-05-25", TemporaryStorage.ATTACHED_VOLUMES, 0L);
    CloudInstance cloudInstance = new CloudInstance(instanceId, instanceTemplate, instanceAuthentication, "subnet-1", "az1");
    group = new Group(name, InstanceGroupType.CORE, Collections.singletonList(cloudInstance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), 50, Optional.empty(), createGroupNetwork(), emptyMap());
    List<VolumeSetAttributes.Volume> volumes = new ArrayList<>();
    volumes.add(new VolumeSetAttributes.Volume("1234", "noop", 0, "eph", CloudVolumeUsageType.GENERAL));
    VolumeSetAttributes attributes = new VolumeSetAttributes("Ireland", true, "", volumes, 0, "eph");
    Map<String, Object> params = new HashMap<>();
    params.put(CloudResource.ATTRIBUTES, attributes);
    buildableResource = List.of(CloudResource.builder().type(ResourceType.GCP_DISK).status(CommonStatus.REQUESTED).name("disk").params(params).build());
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
    Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    cloudStack = new CloudStack(Collections.emptyList(), null, image, emptyMap(), emptyMap(), null, null, null, null, null);
    when(intermediateBuilderExecutor.submit(any(Callable.class))).thenAnswer(invocation -> {
        Callable<Void> callable = invocation.getArgument(0);
        return new MockFuture(callable);
    });
    operation = new Operation();
    operation.setName("operation");
    operation.setHttpErrorStatusCode(null);
    when(compute.disks()).thenReturn(disks);
    when(disks.insert(anyString(), anyString(), any(Disk.class))).thenReturn(insert);
    when(insert.execute()).thenReturn(operation);
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) Builder(com.sequenceiq.cloudbreak.cloud.model.CloudResource.Builder) ArrayList(java.util.ArrayList) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) SecurityRule(com.sequenceiq.cloudbreak.cloud.model.SecurityRule) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Operation(com.google.api.services.compute.model.Operation) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Callable(java.util.concurrent.Callable) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) GcpContext(com.sequenceiq.cloudbreak.cloud.gcp.context.GcpContext) Disk(com.google.api.services.compute.model.Disk) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) PortDefinition(com.sequenceiq.cloudbreak.cloud.model.PortDefinition) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Location(com.sequenceiq.cloudbreak.cloud.model.Location) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 22 with InstanceGroupType

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

the class GcpBackendServiceResourceBuilderTest method setup.

@BeforeEach
private void setup() {
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
    image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    GcpResourceNameService resourceNameService = new GcpResourceNameService();
    ReflectionTestUtils.setField(resourceNameService, "maxResourceNameLength", 50);
    ReflectionTestUtils.setField(underTest, "resourceNameService", resourceNameService);
    Network network = new Network(null);
    cloudStack = new CloudStack(Collections.emptyList(), network, image, emptyMap(), emptyMap(), null, null, null, null, null);
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) Network(com.sequenceiq.cloudbreak.cloud.model.Network) GcpResourceNameService(com.sequenceiq.cloudbreak.cloud.gcp.service.GcpResourceNameService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 23 with InstanceGroupType

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

the class GcpForwardingRuleResourceBuilderTest method setup.

@BeforeEach
private void setup() {
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
    image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    GcpResourceNameService resourceNameService = new GcpResourceNameService();
    ReflectionTestUtils.setField(resourceNameService, "maxResourceNameLength", 50);
    ReflectionTestUtils.setField(underTest, "resourceNameService", resourceNameService);
    Network network = new Network(null);
    cloudStack = new CloudStack(Collections.emptyList(), network, image, emptyMap(), emptyMap(), null, null, null, null, null);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("hcport", 8080);
    parameters.put("trafficport", 8080);
    resource = new CloudResource.Builder().type(ResourceType.GCP_FORWARDING_RULE).status(CommonStatus.CREATED).group("master").name("super").params(parameters).persistent(true).build();
    backendResource = new CloudResource.Builder().type(ResourceType.GCP_BACKEND_SERVICE).status(CommonStatus.CREATED).group("master").name("backendsuper").params(parameters).persistent(true).build();
    ipResource = new CloudResource.Builder().type(ResourceType.GCP_RESERVED_IP).status(CommonStatus.CREATED).group("master").name("ipsuper").persistent(true).build();
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) GcpResourceNameService(com.sequenceiq.cloudbreak.cloud.gcp.service.GcpResourceNameService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Network(com.sequenceiq.cloudbreak.cloud.model.Network) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 24 with InstanceGroupType

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

the class GcpHealthCheckResourceBuilderTest method setup.

@BeforeEach
private void setup() {
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
    image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    GcpResourceNameService resourceNameService = new GcpResourceNameService();
    ReflectionTestUtils.setField(resourceNameService, "maxResourceNameLength", 50);
    ReflectionTestUtils.setField(underTest, "resourceNameService", resourceNameService);
    Network network = new Network(null);
    cloudStack = new CloudStack(Collections.emptyList(), network, image, emptyMap(), emptyMap(), null, null, null, null, null);
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) Network(com.sequenceiq.cloudbreak.cloud.model.Network) GcpResourceNameService(com.sequenceiq.cloudbreak.cloud.gcp.service.GcpResourceNameService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 25 with InstanceGroupType

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

the class UserDataBuilderTest method testBuildUserDataWithCCM.

@Test
public void testBuildUserDataWithCCM() throws IOException {
    BaseServiceEndpoint serviceEndpoint = new BaseServiceEndpoint(new HostEndpoint("ccm.cloudera.com"));
    DefaultServerParameters serverParameters = new DefaultServerParameters(serviceEndpoint, "pub-key", "mina-id");
    DefaultInstanceParameters instanceParameters = new DefaultInstanceParameters("tunnel-id", "key-id", "private-key");
    DefaultTunnelParameters nginxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.GATEWAY, 9443);
    DefaultTunnelParameters knoxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.KNOX, 8443);
    CcmParameters ccmParameters = new DefaultCcmParameters(serverParameters, instanceParameters, List.of(nginxTunnel, knoxTunnel));
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmParameters);
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", ccmConnectivityParameters, null);
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-ccm-init.sh");
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-ccm-init.sh");
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
}
Also used : DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) CcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters) CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) BaseServiceEndpoint(com.sequenceiq.cloudbreak.ccm.endpoint.BaseServiceEndpoint) DefaultInstanceParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultInstanceParameters) HostEndpoint(com.sequenceiq.cloudbreak.ccm.endpoint.HostEndpoint) DefaultServerParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultServerParameters) DefaultTunnelParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultTunnelParameters) Test(org.junit.Test)

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