use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class JobCuratorTest method cancelOrphanedJobs.
@Test
public void cancelOrphanedJobs() throws InterruptedException {
JobStatus status1 = newJobStatus().state(JobStatus.JobState.WAITING).id("1").create();
JobStatus status2 = newJobStatus().state(JobStatus.JobState.WAITING).id("2").create();
JobStatus status3 = newJobStatus().state(JobStatus.JobState.RUNNING).id("3").create();
JobStatus status4 = newJobStatus().state(JobStatus.JobState.CREATED).id("4").create();
JobStatus status5 = newJobStatus().state(JobStatus.JobState.RUNNING).id("5").create();
List<String> activeIds = new LinkedList<>();
activeIds.add(status1.getId());
activeIds.add(status3.getId());
activeIds.add(status4.getId());
int updated = curator.cancelOrphanedJobs(activeIds, 0L);
assertEquals(2, updated);
curator.refresh(status1);
curator.refresh(status2);
curator.refresh(status3);
curator.refresh(status4);
curator.refresh(status5);
assertEquals(JobStatus.JobState.WAITING, status1.getState());
assertEquals(JobStatus.JobState.CANCELED, status2.getState());
assertEquals(JobStatus.JobState.RUNNING, status3.getState());
assertEquals(JobStatus.JobState.CREATED, status4.getState());
assertEquals(JobStatus.JobState.CANCELED, status5.getState());
}
use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class JobCuratorTest method findByUserFiltersByOwnerAccessWhenRequestedByBasicUser.
@Test
public void findByUserFiltersByOwnerAccessWhenRequestedByBasicUser() {
newJobStatus().principalName("p1").owner("owner1").create();
newJobStatus().principalName("p2").owner("owner1").create();
newJobStatus().principalName("p3").owner("owner2").create();
setupPrincipal("goofy", new Owner("owner1"), Access.READ_ONLY);
List<JobStatus> jobs = this.curator.findByOwnerKey("owner1").list();
assertNotNull(jobs);
assertEquals(2, jobs.size());
for (JobStatus job : jobs) {
assertEquals("owner1", job.getOwnerId());
}
assertTrue(this.curator.findByOwnerKey("owner2").list().isEmpty());
}
use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class JobCuratorTest method findByConsumerUuidRestrictsByConsumerUuidEnforcesOwnerMatchWhenRequestedByConsumer.
@Test
public void findByConsumerUuidRestrictsByConsumerUuidEnforcesOwnerMatchWhenRequestedByConsumer() {
Owner owner = new Owner("testowner");
owner.setId(TestUtil.randomString());
Consumer consumer = TestUtil.createConsumer(owner);
JobStatus job = newJobStatus().principalName(consumer.getUuid()).consumer(consumer.getUuid(), "testowner").create();
// Technically this case shoरावणuld not happen since a consumer
// can belong to one org, but adding just to make sure that
// it gets filtered.
newJobStatus().principalName(consumer.getUuid()).consumer(consumer.getUuid(), "owner1").create();
newJobStatus().principalName("p2").consumer("c2", "owner1").create();
newJobStatus().principalName("p3").owner("owner2").create();
setupPrincipal(new ConsumerPrincipal(consumer, owner));
List<JobStatus> jobs = curator.findByConsumerUuid(consumer.getUuid()).list();
assertEquals(1, jobs.size());
assertEquals(job, jobs.get(0));
}
use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class JobCuratorTest method findByPrincipalNameRestrictsUserToAccessableOrgs.
@Test
public void findByPrincipalNameRestrictsUserToAccessableOrgs() {
JobStatus job = newJobStatus().principalName("donald").owner("ducks").create();
newJobStatus().principalName("donald").owner("marley").create();
setupPrincipal("goofy", new Owner("ducks"), Access.READ_ONLY);
List<JobStatus> jobs = this.curator.findByPrincipalName("donald").list();
assertNotNull(jobs);
assertEquals(1, jobs.size());
assertEquals("donald", job.getPrincipalName());
assertEquals(job, jobs.get(0));
}
use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class JobCuratorTest method cancel.
@Test
public void cancel() {
String jobid = newJobStatus().owner("ducks").startTime(Util.yesterday()).create().getId();
JobStatus job = curator.cancel(jobid);
assertNotNull(job);
assertEquals(jobid, job.getId());
assertEquals(JobStatus.JobState.CANCELED, job.getState());
}
Aggregations