kw2542 commented on a change in pull request #1248: SAMZA-2410: Update
ClusterBasedJobCoordinator config retrieval logic from loader.
URL: https://github.com/apache/samza/pull/1248#discussion_r368107532
##########
File path:
samza-core/src/test/java/org/apache/samza/clustermanager/TestClusterBasedJobCoordinator.java
##########
@@ -198,4 +203,31 @@ public void testRunWithClassLoader() throws Exception {
// make sure runClusterBasedJobCoordinator only got called once
verifyPrivate(ClusterBasedJobCoordinator.class).invoke("runClusterBasedJobCoordinator",
new Object[]{aryEq(args)});
}
+
+ @Test(expected = SamzaException.class)
+ public void testCreateFromConfigLoaderWithoutConfigLoaderFactory() {
+ ClusterBasedJobCoordinator.createFromConfigLoader(new MapConfig());
+ }
+
+ @Test
+ public void testCreateFromConfigLoader() throws Exception {
+ // partially mock ClusterBasedJobCoordinator (mock prepareJob method only)
+ PowerMockito.spy(ClusterBasedJobCoordinator.class);
+
+ Map<String, String> config = new HashMap<>();
+ config.put(ApplicationConfig.APP_CLASS,
MockStreamApplication.class.getCanonicalName());
+ config.put(JobConfig.CONFIG_LOADER_FACTORY,
PropertiesConfigLoaderFactory.class.getCanonicalName());
+ config.put(PropertiesConfigLoaderFactory.CONFIG_LOADER_PROPERTIES_PREFIX +
"path",
+ getClass().getResource("/test.properties").getPath());
+
+ PowerMockito.doAnswer(invocation -> invocation.getArgumentAt(0,
Config.class))
+ .when(ClusterBasedJobCoordinator.class, "prepareJob", any());
+
PowerMockito.whenNew(ClusterBasedJobCoordinator.class).withAnyArguments().thenReturn(mock(ClusterBasedJobCoordinator.class));
+
PowerMockito.whenNew(CoordinatorStreamStore.class).withAnyArguments().thenReturn(mock(CoordinatorStreamStore.class));
+
+ ClusterBasedJobCoordinator.createFromConfigLoader(new MapConfig(config));
+
+ verifyPrivate(ClusterBasedJobCoordinator.class).invoke("prepareJob",
any());
+ verifyNew(ClusterBasedJobCoordinator.class).withArguments(any(), any(),
any());
Review comment:
Updated the unit test have to explicit validation on arguments.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services