Skip to content

Commit

Permalink
SDC-12952. Test failures introduced by changes to RuntimeInfo
Browse files Browse the repository at this point in the history
Change-Id: I1b659d8fffae75066d4e4556c7d99065056a9370
Reviewed-on: https://review.streamsets.net/c/datacollector/+/27758
Reviewed-by: Jeff Evans <jeff@streamsets.com>
Tested-by: StreamSets CI <streamsets-ci-spam@streamsets.com>
  • Loading branch information
Ji Sun committed Nov 22, 2019
1 parent 9ccd1cb commit 6d8f77f
Showing 1 changed file with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void cleanUp() {
System.getProperties().remove(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.DATA_DIR);
System.getProperties().remove(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.STATIC_WEB_DIR);
System.getProperties().remove(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.RESOURCES_DIR);
System.getProperties().remove(RuntimeInfo.getBaseHttpUrlAttr(RuntimeInfo.SDC_PRODUCT));
System.getProperties().remove(String.format(RuntimeInfo.BASE_HTTP_URL_ATTR, RuntimeInfo.SDC_PRODUCT));
}

@Test
Expand Down Expand Up @@ -122,8 +122,7 @@ public void testConfigIdAndBaseHttpUrl() throws Exception {
Assert.assertTrue(dir.mkdirs());
System.setProperty(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.CONFIG_DIR, dir.getAbsolutePath());
Properties props = new Properties();
final String productName = "sdc";
props.setProperty(String.format(RuntimeInfo.BASE_HTTP_URL_ATTR, productName), "HTTP");
props.setProperty(String.format(RuntimeInfo.BASE_HTTP_URL_ATTR, RuntimeInfo.SDC_PRODUCT), "HTTP");
props.setProperty(RemoteSSOService.SECURITY_SERVICE_APP_AUTH_TOKEN_CONFIG, "AUTH_TOKEN");
props.setProperty(RemoteSSOService.DPM_ENABLED, "true");
props.setProperty(RemoteSSOService.DPM_DEPLOYMENT_ID, "foo");
Expand All @@ -142,26 +141,31 @@ public void testConfigIdAndBaseHttpUrl() throws Exception {
@Test
public void testTransformerRuntimeInfoConfigAndId() throws Exception {
final String productName = "transformer";
System.setProperty(productName + RuntimeInfo.STATIC_WEB_DIR, "target/w");
System.setProperty(productName + RuntimeInfo.CONFIG_DIR, "target/x");
System.setProperty(productName + RuntimeInfo.LOG_DIR, "target/y");
System.setProperty(productName + RuntimeInfo.DATA_DIR, "target/z");
System.setProperty(productName + RuntimeInfo.RESOURCES_DIR, "target/R");

File dir = new File("target", UUID.randomUUID().toString());
Assert.assertTrue(dir.mkdirs());
System.setProperty(productName + RuntimeInfo.CONFIG_DIR, dir.getAbsolutePath());
Properties props = new Properties();
props.setProperty(String.format(RuntimeInfo.BASE_HTTP_URL_ATTR, productName), "HTTP");
Writer writer = new FileWriter(new File(dir, productName + ".properties"));
props.store(writer, "");
writer.close();
RuntimeModule.setProductName(productName);
RuntimeModule.setPropertyPrefix(productName);
ObjectGraph og = ObjectGraph.create(RuntimeModule.class);
og.get(Configuration.class);
RuntimeInfo info = og.get(RuntimeInfo.class);
Assert.assertEquals("HTTP", info.getBaseHttpUrl());
try {
File dir = new File("target", UUID.randomUUID().toString());
Assert.assertTrue(dir.mkdirs());
System.setProperty(productName + RuntimeInfo.CONFIG_DIR, dir.getAbsolutePath());
Properties props = new Properties();
props.setProperty(String.format(RuntimeInfo.BASE_HTTP_URL_ATTR, productName), "HTTP");
Writer writer = new FileWriter(new File(dir, productName + ".properties"));
props.store(writer, "");
writer.close();
RuntimeModule.setProductName(productName);
RuntimeModule.setPropertyPrefix(productName);
ObjectGraph og = ObjectGraph.create(RuntimeModule.class);
og.get(Configuration.class);
RuntimeInfo info = og.get(RuntimeInfo.class);
Assert.assertEquals("HTTP", info.getBaseHttpUrl());
} finally {
// set productName back to default value of SDC
RuntimeModule.setProductName(RuntimeInfo.SDC_PRODUCT);
RuntimeModule.setPropertyPrefix(RuntimeInfo.SDC_PRODUCT);
// Clean up the system properties set for the transformer
System.getProperties().remove(productName + RuntimeInfo.DATA_DIR);
System.getProperties().remove(productName + RuntimeInfo.CONFIG_DIR);
}
}

@Test
Expand All @@ -170,7 +174,7 @@ public void testSlaveRuntimeInfoConfigAndId() throws Exception {
Assert.assertTrue(dir.mkdirs());
System.setProperty(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.CONFIG_DIR, dir.getAbsolutePath());
Properties props = new Properties();
props.setProperty(RuntimeInfo.getBaseHttpUrlAttr(RuntimeInfo.SDC_PRODUCT), "HTTP");
props.setProperty(String.format(RuntimeInfo.BASE_HTTP_URL_ATTR, RuntimeInfo.SDC_PRODUCT), "HTTP");
props.setProperty(ClusterModeConstants.CLUSTER_PIPELINE_REMOTE, "true");
props.setProperty(RemoteSSOService.SECURITY_SERVICE_APP_AUTH_TOKEN_CONFIG, "AUTH_TOKEN");
props.setProperty(RemoteSSOService.DPM_ENABLED, "true");
Expand Down

0 comments on commit 6d8f77f

Please sign in to comment.