Skip to content
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

Integration Tests (Finally) #92

Merged
merged 2 commits into from Sep 11, 2014
Merged

Integration Tests (Finally) #92

merged 2 commits into from Sep 11, 2014

Conversation

Albert-IV
Copy link
Collaborator

So if you look at this PR, you might be amused to see that I stuck with the child_process.fork() method for testing here.

Initially I had tried invalidating the new Agenda() instance and recreating it, however that led to a lot of odd problems that I couldn't fully figure out, so I scrapped that idea in favor of a way of dynamically loading Agenda jobs in the forked process.

A few caveats with this PR.

  1. Set up paths to use path.join() to ensure cross-compatibility with non-Unix environments. That being said, I haven't through the rest of the code yet to know if that's true (and the ability to use Make on a Windows machine is questionable).
  2. Linting: I added some jsHint/ jsLint globals to the top of the test file to get rid of some warnings. That being said, I could have totally included that in my settings to get rid of those warnings, so let me know you want that removed.
  3. Other Styling Changes: My default text editor settings trim off whitespace, plus I added semicolons to a block of code that was missing them.
  4. Blind Change of Test: On the "should reuse the same job on multiple runs" test, I added the var counter = 0; statement to match the surrounding tests. This was a total blindly made change, but the tests passed before and after I made the changes, so I think we're good!

If you want these commits squashed, let me know and I can take care of it.

Do you have any other ideas for integration tests? I thought we might be able to add something to check manual job processing and concurrent Agenda instances, but I'm not super-familiar with that API and figured we could start with these.

What started as a simple "Let's see what jsHint issues arise"
made me find a couple things.

One section was missing semi-colons, which I added (which is
just a styling change).

After fixing globals and the semi-colons, I found a section that
was referencing a variable that wasn't actually set.  I saw in
a similar test created it before starting the increment, which I
blindly copied into the test.

Tests passed before and after the changes.  These are all styling
changes.
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 4e08907 on droppedonjapan:master into a380ba3 on rschmukler:master.

So this adds a few tests using the child_process.fork() method,
in the attempt to recreate starting/ restarting conditions that
may occur for a service or application.

These have been broken into each job assignment method.

.each()
  - Ensures jobs do not get re-ran after restart.
  - Ensures array names still have jobs ran.

.schedule()
  - Ensures on startup future jobs do not get ran.
  - Ensures jobs scheduled before current time get ran.
  - Ensures array names still have jobs ran.

.every()
  - Ensures job gets ran as soon as possible.

There are a few nitpicks here that I still have, such as using
path.join() to ensure this can be tested in non-Unix enviroments.

Seeing as this uses Make, I am not 100% sure how useful
cross-compatibility is, not to mention I haven't validated that
the rest of the codebase uses path.join() either.
@Albert-IV
Copy link
Collaborator Author

Sorry, had noticed a dumb IIFE in the now() test.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.32%) when pulling 6369db9 on droppedonjapan:master into a380ba3 on rschmukler:master.

@Albert-IV
Copy link
Collaborator Author

I'll take a look at this when I get home, no idea how removing an IIFE reduced test coverage.

@rschmukler rschmukler merged commit 6369db9 into agenda:master Sep 11, 2014
@rschmukler
Copy link
Collaborator

@droppedonjapan This is fantastic! Thank you for the work! Feel free to open another PR if you figure out the issue w/ coveralls -- otherwise, I'm not too worried.

Processing w/ multiple agenda instances could be interesting -- my guess is that we would find improvements for potential load balancing across instances, although improving it w/o more robust messaging between instances might not be possible.

@Albert-IV
Copy link
Collaborator Author

@rschmukler Yeah, that could be a fun project to work on, if nothing else to have some sort of benchmarks. I wonder, how does one benchmark that sort of thing?

Since users will be doing their own random jobs, I'd imagine you could mock up longer and shorter processes with different timeouts, maybe get a timeline of what jobs Agenda is working on at what time.

If you get a simple array of start / end times for jobs, you could graph it with some random charting library.

I guess the real question is if a clustered setup for tasks would be an eventual goal to support out of the box?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants