Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Merge ea0b8f2 into 73e22a7
Browse files Browse the repository at this point in the history
  • Loading branch information
mapingo committed Nov 22, 2018
2 parents 73e22a7 + ea0b8f2 commit e55a5f7
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;

Expand Down Expand Up @@ -159,30 +158,32 @@ public void shouldLockJobsToWorker() throws SQLException {
assertThat(jobs.size(), is(4));
}

@Ignore("TODO: This test is flip flopping when run with all the tests, needs to be investigated")
@Test
public void shouldFindLockedJobsToWorker() throws Exception {
final UUID jobId = randomUUID();
final Optional<UUID> worker = of(randomUUID());
final UUID jobId2 = randomUUID();
final UUID worker = randomUUID();

final Job job = new Job(jobId, jobData(JOB_DATA_JSON), "nextTask", now(), worker, of(now()));
final Job job = new Job(jobId, jobData(JOB_DATA_JSON), "nextTask", now(), of(worker), of(now()));
final Job job2 = new Job(jobId2, jobData(JOB_DATA_JSON), "nextTask", now(), empty(), empty());

jdbcRepository.insertJob(job);
jdbcRepository.insertJob(job2);

final UUID jobId2 = randomUUID();
assertThat(jobsCount(), is(2));

final Job job2 = new Job(jobId2, jobData(JOB_DATA_JSON), "nextTask", now(), empty(), empty());
final List<Job> preTestJobs = jdbcRepository.findJobsLockedTo(worker).collect(toList());
assertThat(preTestJobs.size(), is(1));

jdbcRepository.insertJob(job2);
jdbcRepository.lockJobsFor(worker, 10);

jdbcRepository.lockJobsFor(worker.get(), 10);
final List<Job> jobs = jdbcRepository.findJobsLockedTo(worker).collect(toList());

final List<Job> jobs = jdbcRepository.findJobsLockedTo(worker.get()).collect(toList());
assertThat(jobs.size(), is(2));

assertThat(jobs.get(0).getWorkerId(), is(worker));
assertThat(jobs.get(0).getWorkerId(), is(of(worker)));

assertThat(jobs.get(1).getWorkerId(), is(worker));
assertThat(jobs.get(1).getWorkerId(), is(of(worker)));
}

@Test
Expand Down

0 comments on commit e55a5f7

Please sign in to comment.