use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.
the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2IsEnabled.
@Test
public void testFetchAndSaveCcmParametersWhenCcmV2IsEnabled() {
Stack stack = getAStack();
stack.setTunnel(Tunnel.CCMV2);
DefaultCcmV2Parameters defaultCcmV2Parameters = mock(DefaultCcmV2Parameters.class);
when(ccmV2ParameterSupplier.getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2Parameters);
when(defaultCcmV2Parameters.getAgentCrn()).thenReturn("testAgentCrn");
when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
assertEquals(CcmConnectivityMode.CCMV2, ccmParameters.getConnectivityMode(), "CCM V2 should be enabled.");
assertEquals(defaultCcmV2Parameters, ccmParameters.getCcmV2Parameters(), "CCM V2 Parameters should match.");
verify(ccmV2ParameterSupplier, times(1)).getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString());
verifyNoInteractions(ccmParameterSupplier);
verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
verify(stackService, never()).setMinaSshdServiceIdByStackId(any(), any());
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.
the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmTunnelNotEnabled.
@Test
void testFetchAndSaveCcmParametersWhenCcmTunnelNotEnabled() {
Stack stack = getAStack();
CcmConnectivityParameters ccmNotEnabled = underTest.fetchAndSaveCcmParameters(stack);
assertEquals(CcmConnectivityMode.NONE, ccmNotEnabled.getConnectivityMode(), "CCM should not be enabled.");
verify(stackService, never()).setCcmV2AgentCrnByStackId(any(), any());
verify(stackService, never()).setMinaSshdServiceIdByStackId(any(), any());
verifyNoInteractions(ccmV2ParameterSupplier);
verifyNoInteractions(ccmParameterSupplier);
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters 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));
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.
the class SaltConfigProviderTest method testGetSaltConfig.
@Test
public void testGetSaltConfig() throws Exception {
Stack stack = mock(Stack.class);
when(stack.getCcmParameters()).thenReturn(new CcmConnectivityParameters(new DefaultCcmV2JumpgateParameters()));
FreeIpaConfigView freeIpaConfigView = mock(FreeIpaConfigView.class);
Map freeIpaConfigViewMap = mock(Map.class);
when(freeIpaConfigService.createFreeIpaConfigs(any(), any())).thenReturn(freeIpaConfigView);
when(stack.getCloudPlatform()).thenReturn(CLOUD_PLATFORM);
when(freeIpaConfigView.toMap()).thenReturn(freeIpaConfigViewMap);
when(telemetryConfigService.createTelemetryPillarConfig(any())).thenReturn(Map.of());
when(proxyConfigService.createProxyPillarConfig(any())).thenReturn(Map.of());
when(tagConfigService.createTagsPillarConfig(any())).thenReturn(Map.of());
when(ccmParametersConfigService.createCcmParametersPillarConfig(any(), any())).thenReturn(Map.of(PILLAR, new SaltPillarProperties(PILLARPATH, Map.of(PILLARKEY, PILLARVALUE))));
SaltConfig saltConfig = underTest.getSaltConfig(stack, Set.of());
Map<String, SaltPillarProperties> servicePillarConfig = saltConfig.getServicePillarConfig();
assertNotNull(servicePillarConfig);
SaltPillarProperties freeIpaProperties = servicePillarConfig.get("freeipa");
assertNotNull(freeIpaProperties);
assertEquals("/freeipa/init.sls", freeIpaProperties.getPath());
assertEquals(freeIpaConfigViewMap, freeIpaProperties.getProperties().get("freeipa"));
SaltPillarProperties discoveryProperties = servicePillarConfig.get("discovery");
assertNotNull(discoveryProperties);
assertEquals("/discovery/init.sls", discoveryProperties.getPath());
assertEquals(CLOUD_PLATFORM, discoveryProperties.getProperties().get("platform"));
SaltPillarProperties pillarProperties = servicePillarConfig.get(PILLAR);
assertNotNull(pillarProperties);
assertEquals(PILLARPATH, pillarProperties.getPath());
assertEquals(PILLARVALUE, pillarProperties.getProperties().get(PILLARKEY));
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.
the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2IsEnabled.
@Test
void testFetchAndSaveCcmParametersWhenCcmV2IsEnabled() {
Stack stack = getAStack();
stack.setTunnel(Tunnel.CCMV2);
DefaultCcmV2Parameters defaultCcmV2Parameters = mock(DefaultCcmV2Parameters.class);
FreeIpa freeIpa = mock(FreeIpa.class);
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
when(freeIpa.getDomain()).thenReturn("cldr.work.site");
when(ccmV2ParameterSupplier.getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2Parameters);
when(defaultCcmV2Parameters.getAgentCrn()).thenReturn("testAgentCrn");
when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
assertEquals(CcmConnectivityMode.CCMV2, ccmParameters.getConnectivityMode(), "CCM V2 should be enabled.");
assertEquals(defaultCcmV2Parameters, ccmParameters.getCcmV2Parameters(), "CCM V2 Parameters should match.");
verify(ccmV2ParameterSupplier, times(1)).getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString());
verifyNoInteractions(ccmParameterSupplier);
verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
}
Aggregations