Search in sources :

Example 6 with InstanceGroupType

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

the class JsonTest method testMembers.

@Test
public void testMembers() throws JsonProcessingException {
    Map<InstanceGroupType, String> userData = new EnumMap<>(InstanceGroupType.class);
    userData.put(InstanceGroupType.CORE, "CORE");
    Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    Json json = new Json(image);
    Assert.assertEquals("{\"imageName\":\"cb-centos66-amb200-2015-05-25\",\"userdata\":{\"CORE\":\"CORE\"},\"os\":\"redhat6\",\"osType\":\"redhat6\"," + "\"imageCatalogUrl\":\"\",\"imageCatalogName\":\"default\",\"imageId\":\"default-id\",\"packageVersions\":{}}", json.getValue());
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 7 with InstanceGroupType

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

the class JsonTest method testMultipleSerialisation.

// The reason for this to check whether serialisetion-deserialisation-serialisation results the same json
@Test
public void testMultipleSerialisation() throws IOException {
    Map<InstanceGroupType, String> userData = new EnumMap<>(InstanceGroupType.class);
    userData.put(InstanceGroupType.CORE, "CORE");
    Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    Json json = new Json(image);
    String expected = json.getValue();
    Image covertedAgain = json.get(Image.class);
    json = new Json(covertedAgain);
    Assert.assertEquals(expected, json.getValue());
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 8 with InstanceGroupType

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

the class StackDecoratorTest method createInstanceGroups.

private Set<InstanceGroup> createInstanceGroups(InstanceGroupType... types) {
    Set<InstanceGroup> groups = new LinkedHashSet<>(types.length);
    int i = 0;
    for (InstanceGroupType type : types) {
        InstanceGroup group = mock(InstanceGroup.class);
        when(group.getInstanceGroupType()).thenReturn(type);
        when(group.getGroupName()).thenReturn("name" + i);
        when(group.getNodeCount()).thenReturn(2);
        groups.add(group);
    }
    return groups;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 9 with InstanceGroupType

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

the class UserDataBuilderTest method testBuildUserDataAzure.

@Test
public void testBuildUserDataAzure() throws IOException {
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-init.sh");
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-init.sh");
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", new CcmConnectivityParameters(), null);
    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) Test(org.junit.Test)

Example 10 with InstanceGroupType

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

the class SecurityAccessManifesterTest method overrideSecurityAccessWhenOneCidrRangeProvidedThenShouldUpdateTheCidrRange.

@Test
void overrideSecurityAccessWhenOneCidrRangeProvidedThenShouldUpdateTheCidrRange() {
    InstanceGroupType gateway = GATEWAY;
    List<InstanceGroupV4Request> instanceGroups = getInstanceGroups();
    String theWholeWorld = "0.0.0.0/0";
    securityAccessManifester.overrideSecurityAccess(gateway, instanceGroups, null, theWholeWorld);
    assertEquals(1, instanceGroups.get(0).getSecurityGroup().getSecurityRules().size());
    assertEquals(List.of(theWholeWorld), collectSubnets(instanceGroups));
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.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