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);
}
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);
}
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();
}
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);
}
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));
}
Aggregations