-
Notifications
You must be signed in to change notification settings - Fork 331
SAMZA-2408: Update RemoteApplicationRunner to submit job only #1247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
16c0d74
4105111
4f864b2
077d4d2
ba8ab36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,9 +75,20 @@ public void testWaitForFinishTimesout() { | |
| assertFalse("Application finished before the timeout.", finished); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRunWithConfigLoaderFactoryPresent() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. I guess the code as-is isn't very unit test friendly. It would be nice to test the invocation of .submit vs .run on JobRunner depending on the presence of the ConfigLoaderFactory. Maybe we could factor out the JobRunner creation into its own method, and use a spy to stub out the return value of that method to be a mock JobRunner that we can verify? Disclaimer though, I'm not sure what the best practices are of using spies...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha, I figured that too. In general, I prefer not to mess with production code for the sake of unit tests. The current unit actually test the new flow, I passed null SamzaApplication to RemoteApplicationRunner's constructor. In RemoteApplicationRunner#run, if it goes the legacy flow, it will throw exception when constructing RemoteJobPlanner where SamzaApplication is required. Do you think this is enough?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is some precedence elsewhere in samza code; ZkJobCoordinator.readJobModelFromMetadataStore for example uses a similar method structure + spy in unit test. You are correct that the test written now does ensure that the legacy flow isn't triggered, but it does little to verify the behavior of the new flow. I won't block the PR on this though.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 that there is a bit of missing test coverage here. It would be nice if this class was set up better for improved testing, but I also won't block the PR on this. |
||
| Map<String, String> config = new HashMap<>(); | ||
| config.put(ApplicationConfig.APP_NAME, "test-app"); | ||
| config.put(JobConfig.CONFIG_LOADER_FACTORY, "org.apache.samza.config.loaders.PropertiesConfigLoaderFactory"); | ||
| config.put(JobConfig.STREAM_JOB_FACTORY_CLASS, MockStreamJobFactory.class.getName()); | ||
| runner = new RemoteApplicationRunner(null, new MapConfig(config)); | ||
|
|
||
| runner.run(null); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetStatus() { | ||
| Map m = new HashMap<String, String>(); | ||
| Map<String, String> m = new HashMap<>(); | ||
| m.put(JobConfig.JOB_NAME, "jobName"); | ||
| m.put(JobConfig.STREAM_JOB_FACTORY_CLASS, MockStreamJobFactory.class.getName()); | ||
|
|
||
|
|
@@ -101,8 +112,8 @@ public MockStreamJobFactory() { | |
| @Override | ||
| public StreamJob getJob(final Config config) { | ||
|
|
||
| StreamJob streamJob = new StreamJob() { | ||
| JobConfig c = (JobConfig) config; | ||
| return new StreamJob() { | ||
| JobConfig c = new JobConfig(config); | ||
|
|
||
| @Override | ||
| public StreamJob submit() { | ||
|
|
@@ -137,8 +148,6 @@ public ApplicationStatus getStatus() { | |
| } | ||
| } | ||
| }; | ||
|
|
||
| return streamJob; | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.