Skip to content

Commit 26c7239

Browse files
biharitomimhmxs
authored andcommitted
CLOUD-10329 mock tests for kerberized cluster creation
1 parent 7c36bf5 commit 26c7239

File tree

4 files changed

+212
-10
lines changed

4 files changed

+212
-10
lines changed

integration-test/it-application.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ integrationtest:
88
defaultBlueprintName: hdp-small-default
99
outputdir: /it
1010
command: suites
11-
suiteFiles: /it/src/main/resources/testsuites/mock/mock-scaling-salt.yaml
11+
suiteFiles:
12+
- /it/src/main/resources/testsuites/mock/mock-scaling-salt.yaml
13+
- /it/src/main/resources/testsuites/mock/mock-kerberized-clustercreate-salt.yaml
1214
cleanup:
1315
cleanupBeforeStart: true

integration-test/src/main/java/com/sequenceiq/it/cloudbreak/mock/MockClusterCreationWithSaltSuccessTest.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ public void testClusterCreation(@Optional("it-cluster") String clusterName, @Opt
8888
Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts);
8989
itContext.putContextParam(CloudbreakITContextConstants.AMBARI_USER_ID, ambariUser);
9090
itContext.putContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID, ambariPassword);
91+
92+
Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
93+
if (instanceMap == null || instanceMap.isEmpty()) {
94+
throw new IllegalStateException("instance map should not be empty!");
95+
}
96+
97+
initSpark();
98+
addSaltMappings(instanceMap);
99+
addAmbariMappings(instanceMap);
100+
customMappings(instanceMap);
101+
91102
// WHEN
92103
ClusterRequest clusterRequest = new ClusterRequest();
93104
clusterRequest.setName(clusterName);
@@ -108,16 +119,7 @@ public void testClusterCreation(@Optional("it-cluster") String clusterName, @Opt
108119
gatewayJson.setEnableGateway(Boolean.TRUE);
109120
gatewayJson.setExposedServices(ImmutableList.of("ALL"));
110121
clusterRequest.setGateway(gatewayJson);
111-
initSpark();
112122

113-
Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
114-
115-
if (instanceMap == null || instanceMap.isEmpty()) {
116-
throw new IllegalStateException("instance map should not be empty!");
117-
}
118-
119-
addSaltMappings(instanceMap);
120-
addAmbariMappings(instanceMap);
121123

122124
ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
123125
Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
@@ -127,8 +129,13 @@ public void testClusterCreation(@Optional("it-cluster") String clusterName, @Opt
127129
CloudbreakUtil.checkClusterAvailability(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackIdStr, ambariUser, ambariPassword, checkAmbari);
128130

129131
verifyCalls(instanceMap, clusterName);
132+
customVerifiers(instanceMap, clusterId, clusterName);
130133
}
131134

135+
protected void customMappings(Map<String, CloudVmMetaDataStatus> instanceMap) { }
136+
137+
protected void customVerifiers(Map<String, CloudVmMetaDataStatus> instanceMap, Long clusterId, String clusterName) { }
138+
132139
private void verifyCalls(Map<String, CloudVmMetaDataStatus> instanceMap, String clusterName) {
133140
verify(SALT_BOOT_ROOT + "/health", "GET").exactTimes(1).verify();
134141
Verification distributeVerification = verify(SALT_BOOT_ROOT + "/salt/action/distribute", "POST").exactTimes(1);
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package com.sequenceiq.it.cloudbreak.mock;
2+
3+
import static com.sequenceiq.it.spark.ITResponse.AMBARI_API_ROOT;
4+
import static com.sequenceiq.it.spark.ITResponse.SALT_API_ROOT;
5+
6+
import java.util.Map;
7+
8+
import org.junit.Before;
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
11+
import org.testng.Assert;
12+
import org.testng.annotations.BeforeMethod;
13+
import org.testng.annotations.Optional;
14+
import org.testng.annotations.Parameters;
15+
import org.testng.annotations.Test;
16+
17+
import com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus;
18+
import com.sequenceiq.it.IntegrationTestContext;
19+
import com.sequenceiq.it.cloudbreak.CloudbreakITContextConstants;
20+
21+
public class MockKerberizedClusterCreationTest extends MockClusterCreationWithSaltSuccessTest {
22+
23+
private static final Logger LOGGER = LoggerFactory.getLogger(MockKerberizedClusterCreationTest.class);
24+
25+
private static final String DEFAULT_KERBEROS_PASSWORD = "admin123!@#";
26+
27+
private static final String DEFAULT_KERBEROS_ADMIN = "admin";
28+
29+
private static final String DEFAULT_KERBEROS_PRINCIPAL = "/admin";
30+
31+
private String kerberosPassword;
32+
33+
private String kerberosAdmin;
34+
35+
@Before
36+
public void setup() { }
37+
38+
@BeforeMethod
39+
public void setContextParameters() {
40+
IntegrationTestContext itContext = getItContext();
41+
Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID), "Blueprint id is mandatory.");
42+
Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.STACK_ID), "Stack id is mandatory.");
43+
}
44+
45+
@Test
46+
@Parameters({"clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin",
47+
"kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort"})
48+
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser,
49+
@Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded,
50+
@Optional("true") boolean enableSecurity, @Optional(DEFAULT_KERBEROS_PASSWORD) String kerberosMasterKey,
51+
@Optional(DEFAULT_KERBEROS_ADMIN) String kerberosAdmin, @Optional(DEFAULT_KERBEROS_PASSWORD) String kerberosPassword,
52+
@Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
53+
54+
this.kerberosAdmin = kerberosAdmin;
55+
this.kerberosPassword = kerberosPassword;
56+
57+
super.testClusterCreation(clusterName,
58+
ambariPort,
59+
ambariUser,
60+
ambariPassword,
61+
emailNeeded,
62+
enableSecurity,
63+
kerberosMasterKey,
64+
kerberosAdmin,
65+
kerberosPassword,
66+
runRecipesOnHosts,
67+
checkAmbari,
68+
mockPort);
69+
}
70+
71+
@Override
72+
protected void customMappings(Map<String, CloudVmMetaDataStatus> instanceMap) {
73+
LOGGER.info("Adding custom mappings for Kerberized cluster");
74+
super.customMappings(instanceMap);
75+
}
76+
77+
@Override
78+
protected void customVerifiers(Map<String, CloudVmMetaDataStatus> instanceMap, Long clusterId, String clusterName) {
79+
LOGGER.info("Adding custom verifiers for Kerberized cluster");
80+
super.customVerifiers(instanceMap, clusterId, clusterName);
81+
82+
verify(SALT_API_ROOT + "/run", "POST")
83+
.bodyContains("fun=grains.append")
84+
.bodyContains("kerberos_server_master")
85+
.exactTimes(1)
86+
.verify();
87+
88+
String principalKV = String.format("\"principal\": \"%s%s\"", kerberosAdmin, DEFAULT_KERBEROS_PRINCIPAL);
89+
String passwordKV = String.format("\"key\": \"%s\"", kerberosPassword);
90+
verify(AMBARI_API_ROOT + "/clusters/" + clusterName, "POST")
91+
.exactTimes(1)
92+
.bodyContains("\"alias\": \"kdc.admin.credential\"")
93+
.bodyContains(principalKV)
94+
.bodyContains(passwordKV)
95+
.verify();
96+
}
97+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: mock-kerberized-clustercreate-salt
2+
parameters: {
3+
cloudProvider: MOCK,
4+
blueprintName: "Data Science: Apache Spark 1.6, Apache Zeppelin 0.7.0"
5+
}
6+
7+
tests:
8+
- name: init
9+
classes:
10+
- com.sequenceiq.it.TestSuiteInitializer
11+
- com.sequenceiq.it.cloudbreak.CloudbreakTestSuiteInitializer
12+
13+
- name: start ssh server on port 2020
14+
parameters:
15+
sshPort: 2020
16+
classes:
17+
- com.sequenceiq.it.cloudbreak.StartSshServerTest
18+
19+
- name: create mock credential
20+
parameters:
21+
credentialName: it-mock-krb-credential-salt
22+
publicKeyFile: raw:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3JiQtcQT48nn7Ax+yJLJqaWKRzczeJAda6x4JHFRqJW15pAmrSG7ld33V89yHeizAziLfhYYhw6uwN4aDKixS/XreQxZWyK2k/namyr8crFC83n6NNxlDa9DGujg61X8JoE2SyPHSVwhizfyoEmnkeyXJlsn6YtEnKfq23P4Di+p6I9xj7Ay52EzRHKMRMH8Q4kscKfp0taQKdOD2rCO1eOJ7vwCdMLjZc4H6TISk+lwnAJlDfbIdy6SO2jKIJvwoSjehfitWgGp8dGIEcV59GmO2aGlSwCqAwF6S9qP7O++5B5irFKc0TxuIplDSPL/yuCycWvz81FJKLTaUdJ6l
23+
classes:
24+
- com.sequenceiq.it.cloudbreak.mock.MockCredentialCreationTest
25+
26+
- name: create mock network
27+
parameters:
28+
networkName: it-mock-krb-network-salt
29+
subnetCIDR: 10.0.36.0/24
30+
classes:
31+
- com.sequenceiq.it.cloudbreak.mock.MockNetworkCreationTest
32+
33+
- name: create mock security group
34+
parameters:
35+
name: it-mock-krb-security-group-salt
36+
port: 22,443,8080,8500,50070,8088,8030,8050,19888,16010,60000,16020,16030,9083,10000,10001,9999,9997,21000,8443,15000,8744,11000,18080,8042,9996,9995,6080,3080,9200,3376,7070
37+
provider: MOCK
38+
classes:
39+
- com.sequenceiq.it.cloudbreak.SecurityGroupCreationTest
40+
41+
- name: create master template
42+
parameters:
43+
mockName: it-mock-krb-smoke-gateway-salt
44+
mockInstanceType: small
45+
volumeType: ssd
46+
volumeCount: 1
47+
volumeSize: 10
48+
templateAdditions: "master,1,GATEWAY"
49+
classes:
50+
- com.sequenceiq.it.cloudbreak.mock.MockTemplateCreationTest
51+
52+
- name: create worker template
53+
parameters:
54+
mockName: it-mock-krb-smoke-worker-salt
55+
mockInstanceType: large
56+
volumeType: ephemeral
57+
volumeCount: 1
58+
volumeSize: 40
59+
templateAdditions: "worker,3"
60+
classes:
61+
- com.sequenceiq.it.cloudbreak.mock.MockTemplateCreationTest
62+
63+
- name: create compute template
64+
parameters:
65+
mockName: it-mock-krb-smoke-compute-salt
66+
mockInstanceType: large
67+
volumeType: magnetic
68+
volumeCount: 3
69+
volumeSize: 200
70+
templateAdditions: "compute,5"
71+
classes:
72+
- com.sequenceiq.it.cloudbreak.mock.MockTemplateCreationTest
73+
74+
- name: create cluster
75+
parameters: {
76+
stackName: it-mock-krb-stack-salt,
77+
region: europe,
78+
threshold: 4,
79+
availabilityZone: europe-b,
80+
clusterName: it-mock-krb-cluster-salt,
81+
checkAmbari: false,
82+
mockPort: 9443,
83+
orchestrator: SALT,
84+
emailNeeded: true,
85+
enableSecurity: true,
86+
publicKeyFile: "raw:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0Rfl2G2vDs6yc19RxCqReunFgpYj+ucyLobpTCBtfDwzIbJot2Fmife6M42mBtiTmAK6x8kcUEeab6CB4MUzsqF7vGTFUjwWirG/XU5pYXFUBhi8xzey+KS9KVrQ+UuKJh/AN9iSQeMV+rgT1yF5+etVH+bK1/37QCKp3+mCqjFzPyQOrvkGZv4sYyRwX7BKBLleQmIVWpofpjT7BfcCxH877RzC5YMIi65aBc82Dl6tH6OEiP7mzByU52yvH6JFuwZ/9fWj1vXCWJzxx2w0F1OU8Zwg8gNNzL+SVb9+xfBE7xBHMpYFg72hBWPh862Ce36F4NZd3MpWMSjMmpDPh centos"
87+
}
88+
classes:
89+
- com.sequenceiq.it.cloudbreak.mock.MockStackCreationWithSaltSuccessTest
90+
- com.sequenceiq.it.cloudbreak.mock.MockKerberizedClusterCreationTest
91+
92+
- name: stop ssh server
93+
parameters:
94+
sshPort: 2020
95+
classes:
96+
- com.sequenceiq.it.cloudbreak.StopSshServerTest

0 commit comments

Comments
 (0)