From 4e5692a213e8caa9b1299634a8ca881f13641dda Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Thu, 21 Feb 2019 16:36:29 +0200 Subject: Enable JobsBrokerService tests Change-Id: I35d7e5802c6838eb53c116afe9013dbf60ae2248 Issue-ID: VID-378 Signed-off-by: Ittay Stern --- .../onap/vid/services/JobsBrokerServiceTest.java | 34 +++++++++++----------- .../test/resources/WEB-INF/conf/system.properties | 4 +++ 2 files changed, 21 insertions(+), 17 deletions(-) (limited to 'vid-app-common/src') diff --git a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java index 3686dc26e..632da88f9 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java @@ -210,7 +210,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { ((JobsBrokerServiceInDatabaseImpl) broker).deleteAll(); } - @Test(enabled = false) + @Test public void givenSingleJob_getIt_verifySameJob() { final Job originalJob = waitForFutureJob(newJobAsync(broker)); @@ -218,7 +218,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { assertThat(JOBS_SHOULD_MATCH, retrievedJob, is(originalJob)); } - @Test(enabled = false) + @Test public void givenManyJobs_getJobsAndPushThemBack_alwaysSeeAllOfThemWithPeek() throws InterruptedException { final List originalJobs = putALotOfJobs(broker); @@ -236,12 +236,12 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { assertThat(JOBS_PEEKED_SHOULD_MATCH, broker.peek(), containsInAnyOrder(originalJobs.toArray())); } - @Test(enabled = false) + @Test public void givenManyJobs_getThemAll_verifySameJobs() { putAndGetALotOfJobs(broker); } - @Test(enabled = false) + @Test public void givenManyJobs_getThemAllThenPushBackandGet_verifySameJobs() { final List retrievedJobs1 = putAndGetALotOfJobs(broker); @@ -503,7 +503,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { JobDaoImpl toJob(); } - @Test(enabled = false, dataProvider = "jobs") + @Test(dataProvider = "jobs") public void givenSomeJobs_pullNextJob_returnNextOrNothingAsExpected(List jobbers, int msoLimit, int expectedIndexSelected, Job.JobStatus topic, String assertionReason) { JobsBrokerServiceInDatabaseImpl broker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, msoLimit, 20); final List jobs = jobbers.stream().map(Jobber::toJob).collect(toList()); @@ -528,12 +528,12 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { .map(v -> new Object[]{v}).collect(toList()).toArray(new Object[][]{}); } - @Test(enabled = false, dataProvider = "topics", expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = "Unsupported topic.*") + @Test(dataProvider = "topics", expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = "Unsupported topic.*") public void pullUnexpectedTopic_exceptionIsThrown(Job.JobStatus topic) { broker.pull(topic, UUID.randomUUID().toString()); } - @Test(enabled = false, expectedExceptions = NoJobException.class) + @Test(expectedExceptions = NoJobException.class) public void givenNonPendingJobs_getJobAsPendingTopic_verifyNothingRetrieved() { Stream.of(Job.JobStatus.values()) .filter(not(s -> s.equals(PENDING))) @@ -545,26 +545,26 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { waitForFutureOptionalJob(pullJobAsync(broker)); } - @Test(enabled = false) + @Test public void givenPendingAndNonPendingJobs_getJobAsPendingTopic_verifyAJobRetrieved() { newJobAsync(broker); // this negated the expected result of the call below givenNonPendingJobs_getJobAsPendingTopic_verifyNothingRetrieved(); } - @Test(enabled = false, expectedExceptions = NoJobException.class) + @Test(expectedExceptions = NoJobException.class) public void givenManyJobs_pullThemAllAndAskOneMore_verifyFinallyNothingRetrieved() { putAndGetALotOfJobs(broker); waitForFutureOptionalJob(pullJobAsync(broker)); } - @Test(enabled = false, expectedExceptions = NoJobException.class) + @Test(expectedExceptions = NoJobException.class) public void givenNoJob_requestJob_verifyNothingRetrieved() throws InterruptedException, ExecutionException, TimeoutException { final Future> futureOptionalJob = pullJobAsync(broker); assertThat("job should not be waiting yet", futureOptionalJob.get(FEW, MILLISECONDS).isPresent(), is(false)); waitForFutureOptionalJob(futureOptionalJob); } - @Test(enabled = false, expectedExceptions = IllegalStateException.class) + @Test(expectedExceptions = IllegalStateException.class) public void givenSinglePulledJob_pushBackDifferentJob_verifyPushingRejected() { waitForFutureJob(newJobAsync(broker)); waitForFutureJob(newJobAsync(broker)); @@ -576,7 +576,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { broker.pushBack(myJob); //Should fail } - @Test(enabled = false) + @Test public void givenSingleJob_pushBackModifiedJob_verifyPulledIsVeryVeryTheSame() { final ImmutableMap randomDataForMostRecentJobType = ImmutableMap.of("42", 42, "complex", ImmutableList.of("a", "b", "c")); @@ -603,7 +603,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { .toString(); } - @Test(enabled = false, expectedExceptions = IllegalStateException.class) + @Test(expectedExceptions = IllegalStateException.class) public void givenSingleJob_pushBackTwice_verifyPushingRejected() { waitForFutureJob(newJobAsync(broker)); final Job job = waitForFutureOptionalJob(pullJobAsync(broker)); @@ -612,7 +612,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { broker.pushBack(job); //Should fail } - @Test(enabled = false) + @Test public void addJob_PeekItById_verifySameJobWasPeeked() { String userId = UUID.randomUUID().toString(); Job myJob = createMockJob(userId); @@ -623,7 +623,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { peekedJob.getSharedData().getUserId()); } - @Test(enabled = false, dataProvider = "jobStatusesForSuccessDelete", expectedExceptions = NoJobException.class) + @Test(dataProvider = "jobStatusesForSuccessDelete", expectedExceptions = NoJobException.class) public void givenOneJob_deleteIt_canPeekOnItButCantPull(Job.JobStatus status) { final Job job = waitForFutureJob(newJobAsync(broker, status)); broker.delete(job.getUuid()); @@ -639,7 +639,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { }; } - @Test(enabled = false, + @Test( dataProvider = "jobStatusesForFailedDelete", expectedExceptions = OperationNotAllowedException.class, expectedExceptionsMessageRegExp=DELETE_SERVICE_INFO_STATUS_EXCEPTION_MESSAGE @@ -666,7 +666,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests { }; } - @Test(enabled = false, expectedExceptions = OperationNotAllowedException.class, expectedExceptionsMessageRegExp = DELETE_SERVICE_NOT_EXIST_EXCEPTION_MESSAGE) + @Test(expectedExceptions = OperationNotAllowedException.class, expectedExceptionsMessageRegExp = DELETE_SERVICE_NOT_EXIST_EXCEPTION_MESSAGE) public void deleteJob_notExist_exceptionIsThrown() { waitForFutureJob(newJobAsync(broker, createMockJob("some user id", PENDING))); broker.delete(new UUID(111, 111)); diff --git a/vid-app-common/src/test/resources/WEB-INF/conf/system.properties b/vid-app-common/src/test/resources/WEB-INF/conf/system.properties index ef444944d..268666798 100644 --- a/vid-app-common/src/test/resources/WEB-INF/conf/system.properties +++ b/vid-app-common/src/test/resources/WEB-INF/conf/system.properties @@ -182,6 +182,10 @@ asdc.model.namespace=org.openecomp. sdc.svc.api.path=sdc/v1/catalog/services sdc.resource.api.path=sdc/v1/catalog/resource +#large amount for tests that generated a lot of jobs (more then 20) +mso.maxOpenedInstantiationRequests=200 +mso.asyncPollingIntervalSeconds=0 + # Application base URL has the host and app context only; a proper prefix of the on-boarded URL. # Only required for applications using WebJunction or FE/BE separation. For example: # app_base_url = https://www.e-access.att.com/app_junction/app_context/ -- cgit 1.2.3-korg