@Test public void testBuildTelemetryConfigListWithProxyConfig() { Stack stack = new Stack(); Cluster cluster = new Cluster(); cluster.setId(1L); cluster.setName("cl1"); stack.setCluster(cluster); WorkloadAnalytics wa = new WorkloadAnalytics(); ProxyConfig proxyConfig = ProxyConfig.builder() .withProtocol("https") .withServerHost("proxyServer") .withServerPort(80) .withProxyAuthentication(ProxyAuthentication.builder() .withUserName("proxyUser") .withPassword("proxyPassword") .build()) .build(); ApiConfigList result = underTest.buildTelemetryConfigList(stack, wa, null, null, proxyConfig); assertTrue(containsConfigWithValue(result, "telemetrypublisher_proxy_server", "proxyServer")); assertTrue(containsConfigWithValue(result, "telemetrypublisher_proxy_port", "80")); assertTrue(containsConfigWithValue(result, "telemetrypublisher_proxy_enabled", "true")); assertTrue(containsConfigWithValue(result, "telemetrypublisher_proxy_user", "proxyUser")); assertTrue(containsConfigWithValue(result, "telemetrypublisher_proxy_password", "proxyPassword")); }
@VisibleForTesting ApiConfigList buildTelemetryConfigList(Stack stack, WorkloadAnalytics wa, String sdxContextName, String sdxCrn, ProxyConfig proxyConfig) { final Map<String, String> configsToUpdate = new HashMap<>(); Map<String, String> telemetrySafetyValveMap = new HashMap<>(); telemetrySafetyValveMap.put(TELEMETRY_WA_CLUSTER_TYPE_HEADER, TELEMETRY_WA_DEFAULT_CLUSTER_TYPE); enrichWithSdxData(sdxContextName, sdxCrn, stack, wa, telemetrySafetyValveMap); telemetrySafetyValveMap.put(TELEMETRY_UPLOAD_LOGS, "true"); configsToUpdate.put(TELEMETRY_SAFETY_VALVE, createStringFromSafetyValveMap(telemetrySafetyValveMap)); if (proxyConfig != null) { configsToUpdate.put(TELEMETRY_PROXY_ENABLED, "true"); configsToUpdate.put(TELEMETRY_PROXY_SERVER, proxyConfig.getServerHost()); configsToUpdate.put(TELEMETRY_PROXY_PORT, String.valueOf(proxyConfig.getServerPort())); proxyConfig.getProxyAuthentication().ifPresent(auth -> { configsToUpdate.put(TELEMETRY_PROXY_USER, auth.getUserName()); configsToUpdate.put(TELEMETRY_PROXY_PASSWORD, auth.getPassword()); }); } return makeApiConfigList(configsToUpdate); }
ClouderaManagerMgmtTelemetryService { @VisibleForTesting ApiConfigList buildTelemetryConfigList(Stack stack, WorkloadAnalytics wa, String sdxContextName, String sdxCrn, ProxyConfig proxyConfig) { final Map<String, String> configsToUpdate = new HashMap<>(); Map<String, String> telemetrySafetyValveMap = new HashMap<>(); telemetrySafetyValveMap.put(TELEMETRY_WA_CLUSTER_TYPE_HEADER, TELEMETRY_WA_DEFAULT_CLUSTER_TYPE); enrichWithSdxData(sdxContextName, sdxCrn, stack, wa, telemetrySafetyValveMap); telemetrySafetyValveMap.put(TELEMETRY_UPLOAD_LOGS, "true"); configsToUpdate.put(TELEMETRY_SAFETY_VALVE, createStringFromSafetyValveMap(telemetrySafetyValveMap)); if (proxyConfig != null) { configsToUpdate.put(TELEMETRY_PROXY_ENABLED, "true"); configsToUpdate.put(TELEMETRY_PROXY_SERVER, proxyConfig.getServerHost()); configsToUpdate.put(TELEMETRY_PROXY_PORT, String.valueOf(proxyConfig.getServerPort())); proxyConfig.getProxyAuthentication().ifPresent(auth -> { configsToUpdate.put(TELEMETRY_PROXY_USER, auth.getUserName()); configsToUpdate.put(TELEMETRY_PROXY_PASSWORD, auth.getPassword()); }); } return makeApiConfigList(configsToUpdate); } }
ClouderaManagerMgmtTelemetryService { @VisibleForTesting ApiConfigList buildTelemetryConfigList(Stack stack, WorkloadAnalytics wa, String sdxContextName, String sdxCrn, ProxyConfig proxyConfig) { final Map<String, String> configsToUpdate = new HashMap<>(); Map<String, String> telemetrySafetyValveMap = new HashMap<>(); telemetrySafetyValveMap.put(TELEMETRY_WA_CLUSTER_TYPE_HEADER, TELEMETRY_WA_DEFAULT_CLUSTER_TYPE); enrichWithSdxData(sdxContextName, sdxCrn, stack, wa, telemetrySafetyValveMap); telemetrySafetyValveMap.put(TELEMETRY_UPLOAD_LOGS, "true"); configsToUpdate.put(TELEMETRY_SAFETY_VALVE, createStringFromSafetyValveMap(telemetrySafetyValveMap)); if (proxyConfig != null) { configsToUpdate.put(TELEMETRY_PROXY_ENABLED, "true"); configsToUpdate.put(TELEMETRY_PROXY_SERVER, proxyConfig.getServerHost()); configsToUpdate.put(TELEMETRY_PROXY_PORT, String.valueOf(proxyConfig.getServerPort())); proxyConfig.getProxyAuthentication().ifPresent(auth -> { configsToUpdate.put(TELEMETRY_PROXY_USER, auth.getUserName()); configsToUpdate.put(TELEMETRY_PROXY_PASSWORD, auth.getPassword()); }); } return makeApiConfigList(configsToUpdate); }  }
ClouderaManagerMgmtTelemetryService { @VisibleForTesting ApiConfigList buildTelemetryConfigList(Stack stack, WorkloadAnalytics wa, String sdxContextName, String sdxCrn, ProxyConfig proxyConfig) { final Map<String, String> configsToUpdate = new HashMap<>(); Map<String, String> telemetrySafetyValveMap = new HashMap<>(); telemetrySafetyValveMap.put(TELEMETRY_WA_CLUSTER_TYPE_HEADER, TELEMETRY_WA_DEFAULT_CLUSTER_TYPE); enrichWithSdxData(sdxContextName, sdxCrn, stack, wa, telemetrySafetyValveMap); telemetrySafetyValveMap.put(TELEMETRY_UPLOAD_LOGS, "true"); configsToUpdate.put(TELEMETRY_SAFETY_VALVE, createStringFromSafetyValveMap(telemetrySafetyValveMap)); if (proxyConfig != null) { configsToUpdate.put(TELEMETRY_PROXY_ENABLED, "true"); configsToUpdate.put(TELEMETRY_PROXY_SERVER, proxyConfig.getServerHost()); configsToUpdate.put(TELEMETRY_PROXY_PORT, String.valueOf(proxyConfig.getServerPort())); proxyConfig.getProxyAuthentication().ifPresent(auth -> { configsToUpdate.put(TELEMETRY_PROXY_USER, auth.getUserName()); configsToUpdate.put(TELEMETRY_PROXY_PASSWORD, auth.getPassword()); }); } return makeApiConfigList(configsToUpdate); }  void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef,
            final ApiRoleList mgmtRoles, final Telemetry telemetry); void updateTelemetryConfigs(final Stack stack, final ApiClient client,
            final Telemetry telemetry, final String sdxContextName,
            final String sdxStackCrn, final ProxyConfig proxyConfig); }
ClouderaManagerMgmtTelemetryService { @VisibleForTesting ApiConfigList buildTelemetryConfigList(Stack stack, WorkloadAnalytics wa, String sdxContextName, String sdxCrn, ProxyConfig proxyConfig) { final Map<String, String> configsToUpdate = new HashMap<>(); Map<String, String> telemetrySafetyValveMap = new HashMap<>(); telemetrySafetyValveMap.put(TELEMETRY_WA_CLUSTER_TYPE_HEADER, TELEMETRY_WA_DEFAULT_CLUSTER_TYPE); enrichWithSdxData(sdxContextName, sdxCrn, stack, wa, telemetrySafetyValveMap); telemetrySafetyValveMap.put(TELEMETRY_UPLOAD_LOGS, "true"); configsToUpdate.put(TELEMETRY_SAFETY_VALVE, createStringFromSafetyValveMap(telemetrySafetyValveMap)); if (proxyConfig != null) { configsToUpdate.put(TELEMETRY_PROXY_ENABLED, "true"); configsToUpdate.put(TELEMETRY_PROXY_SERVER, proxyConfig.getServerHost()); configsToUpdate.put(TELEMETRY_PROXY_PORT, String.valueOf(proxyConfig.getServerPort())); proxyConfig.getProxyAuthentication().ifPresent(auth -> { configsToUpdate.put(TELEMETRY_PROXY_USER, auth.getUserName()); configsToUpdate.put(TELEMETRY_PROXY_PASSWORD, auth.getPassword()); }); } return makeApiConfigList(configsToUpdate); }  void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef,
            final ApiRoleList mgmtRoles, final Telemetry telemetry); void updateTelemetryConfigs(final Stack stack, final ApiClient client,
            final Telemetry telemetry, final String sdxContextName,
            final String sdxStackCrn, final ProxyConfig proxyConfig);  }