question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test Job with Execution Window.

See original GitHub issue

Hi

new JobRequest.Builder(SyncJob.TAG)
                .setExtras(extras)
                .setExecutionWindow(startMs, endMs)
                .setRequiredNetworkType(JobRequest.NetworkType.ANY)
                .setUpdateCurrent(true)
                .setPersisted(true)
                .setRequirementsEnforced(true)
                .build()
                .schedule();

this is a builder for a job, and execution window is between 1AM - 6AM as it was given in the example(it fits well, my needs).

  • Question is , how can I test this? If I change phone’s clock, this does not help, because execution windows is too wide. Also, I noticed that this job runs after the 6AM, for example, it happened to run at 8PM. I looked in library’s test files, but there was written expected behavior of job, not the action itself. It may not run in the given execution time window.

  • in onRunJob, I do async job and return RESCHEDULE every time ,to ensure that service will run, because it failed to run, several nights.

Please response, maybe I’m missing something.

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
vRallevcommented, Apr 4, 2017

I don’t like the design of the JobScheduler. The problem is that you need to launch a background thread on your own and manage its state. You end up with many callbacks, because you need to post the result to the service again.

The library is doing all of this for you. However, if you run an async operation then the worker thread of the library finishes and doesn’t know that there’s still an operation going on.

Could be a problem, because when the library thinks it’s done, then the service is killed and your app is more likely stopped by the system.

1reaction
vRallevcommented, Apr 4, 2017

If you follow the sample, then it should work. It’s possible that devices adjust the execution window in order to save battery. Unfortunately, there isn’t anything I could do.

You can start a job manually if the job schedule is used (Android 5+), see here.

Can you show your onRunJob() method? If you follow my sample, then you shouldn’t return RESCHEDULE. That explains why you see that your job runs at 8 PM.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window Tester Jobs, Employment | Indeed.com
1250 Window Tester jobs available on Indeed.com. Apply to Quality Assurance Tester, Tester, Senior Software Engineer and more!
Read more >
Test Programs for the Windows Agent
There are various ways of starting Windows jobs or programs. ... The test programs do not have an actual function. their execution can...
Read more >
Tips and Tricks for Testing Salesforce - Topcoder
Go to “Developer Console” and click “Query Editor” tab · Click on “Debug” tab · Select the ”Open Execute Anonymous Window” option or...
Read more >
How to properly test a Flink window function? - Stack Overflow
Get the StreamExecutionEnvironment; Create objects and add to the invironment; Do a keyBy; add a Session Window; execute an aggregate function.
Read more >
Abort Apex test class execution using ApexTestQueueItems
"To abort a class that is in the Apex job queue, perform an update operation on the ApexTestQueueItem object and set its Status...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found