Search in sources :

Example 6 with Properties

use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.

the class PropertiesServiceTest method testCreationAndRetrieval.

@Test
void testCreationAndRetrieval() {
    Map<String, Object> propertyMap = new HashMap<>() {

        {
            put("abc", "val");
            put(PCP_CORE_POOL_SIZE, 10);
            put(PCP_MAX_POOL_SIZE, 150);
            put(PCP_SCALE_TO_MAX_TIME, 900);
            put(MAINTENANCE_MODE, "false");
            put(ZIP_SUPPORT_ON, "false");
            put(WORKER_ENGAGEMENT, "engaged");
            put(HPMS_INGESTION_ENGAGEMENT, "engaged");
            put(COVERAGE_SEARCH_DISCOVERY, "idle");
            put(COVERAGE_SEARCH_QUEUEING, "idle");
            put(COVERAGE_SEARCH_UPDATE_MONTHS, "1");
            put(COVERAGE_SEARCH_STUCK_HOURS, "24");
            put(COVERAGE_SEARCH_OVERRIDE, "false");
        }
    };
    List<Properties> propertyListBeforeInsert = propertiesService.getAllProperties();
    int beforeCount = propertyListBeforeInsert.size();
    Properties properties = new Properties();
    properties.setKey("abc");
    properties.setValue("val");
    propertiesRepository.save(properties);
    List<Properties> propertiesList = propertiesService.getAllProperties();
    assertEquals(propertiesList.size(), beforeCount + 1);
    for (Properties propertiesToCheck : propertiesList) {
        Object propertyValue = propertyMap.get(propertiesToCheck.getKey());
        assertNotNull(propertyValue);
        assertEquals(propertyValue.toString(), propertiesToCheck.getValue());
    }
}
Also used : HashMap(java.util.HashMap) Properties(gov.cms.ab2d.common.model.Properties) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with Properties

use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.

the class BFDHealthCheckTest method testBfdGoingDownPastLimitAndComingBackUp.

@Test
public void testBfdGoingDownPastLimitAndComingBackUp() throws IOException {
    MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta-unknown-status.xml", MOCK_SERVER_PORT);
    for (int i = 0; i < consecutiveFailuresToTakeDown + 1; i++) {
        bfdHealthCheck.checkBFDHealth();
    }
    Properties maintenanceProperties = propertiesService.getPropertiesByKey(MAINTENANCE_MODE);
    assertEquals("true", maintenanceProperties.getValue());
    MockBfdServiceUtils.reset(MOCK_SERVER_PORT);
    MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta.xml", MOCK_SERVER_PORT);
    for (int i = 0; i < consecutiveSuccessesToBringUp; i++) {
        bfdHealthCheck.checkBFDHealth();
    }
    maintenanceProperties = propertiesService.getPropertiesByKey(MAINTENANCE_MODE);
    assertEquals("false", maintenanceProperties.getValue());
}
Also used : Properties(gov.cms.ab2d.common.model.Properties) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with Properties

use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.

the class BFDHealthCheckTest method testBfdGoingUpAndDown.

@Test
public void testBfdGoingUpAndDown() throws IOException {
    MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta-unknown-status.xml", MOCK_SERVER_PORT);
    for (int i = 0; i < consecutiveFailuresToTakeDown - 1; i++) {
        bfdHealthCheck.checkBFDHealth();
    }
    MockBfdServiceUtils.reset(MOCK_SERVER_PORT);
    MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta.xml", MOCK_SERVER_PORT);
    for (int i = 0; i < consecutiveSuccessesToBringUp - 1; i++) {
        bfdHealthCheck.checkBFDHealth();
    }
    MockBfdServiceUtils.reset(MOCK_SERVER_PORT);
    MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta-unknown-status.xml", MOCK_SERVER_PORT);
    bfdHealthCheck.checkBFDHealth();
    Properties maintenanceProperties = propertiesService.getPropertiesByKey(MAINTENANCE_MODE);
    assertEquals("false", maintenanceProperties.getValue());
    for (int i = 0; i < consecutiveFailuresToTakeDown - 1; i++) {
        bfdHealthCheck.checkBFDHealth();
    }
    maintenanceProperties = propertiesService.getPropertiesByKey(MAINTENANCE_MODE);
    assertEquals("true", maintenanceProperties.getValue());
    // Cleanup
    MockBfdServiceUtils.reset(MOCK_SERVER_PORT);
    MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta.xml", MOCK_SERVER_PORT);
    for (int i = 0; i < consecutiveSuccessesToBringUp; i++) {
        bfdHealthCheck.checkBFDHealth();
    }
}
Also used : Properties(gov.cms.ab2d.common.model.Properties) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with Properties

use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.

the class BFDHealthCheckTest method testBfdGoingDown.

@Test
public void testBfdGoingDown() throws IOException {
    MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta-unknown-status.xml", MOCK_SERVER_PORT);
    Properties maintenanceProperties = propertiesService.getPropertiesByKey(MAINTENANCE_MODE);
    assertEquals("false", maintenanceProperties.getValue());
    for (int i = 0; i < consecutiveFailuresToTakeDown; i++) {
        bfdHealthCheck.checkBFDHealth();
    }
    maintenanceProperties = propertiesService.getPropertiesByKey(MAINTENANCE_MODE);
    assertEquals("true", maintenanceProperties.getValue());
    // Cleanup
    MockBfdServiceUtils.reset(MOCK_SERVER_PORT);
    MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta.xml", MOCK_SERVER_PORT);
    for (int i = 0; i < consecutiveSuccessesToBringUp; i++) {
        bfdHealthCheck.checkBFDHealth();
    }
}
Also used : Properties(gov.cms.ab2d.common.model.Properties) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with Properties

use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.

the class CoverageDriverUnitTest method failureToLockCausesExceptions.

@DisplayName("When locking fails throws exceptions")
@Test
void failureToLockCausesExceptions() {
    when(lockWrapper.getCoverageLock()).thenReturn(tryLockFalse);
    Properties monthsProp = new Properties();
    monthsProp.setValue("3");
    when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_UPDATE_MONTHS))).thenReturn(monthsProp);
    Properties stuckProp = new Properties();
    stuckProp.setValue("72");
    when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_STUCK_HOURS))).thenReturn(stuckProp);
    Properties overrideProp = new Properties();
    overrideProp.setValue("false");
    when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_OVERRIDE))).thenReturn(overrideProp);
    CoverageDriver driver = new CoverageDriverImpl(null, null, coverageService, propertiesService, null, lockWrapper, null);
    CoverageDriverException exception = assertThrows(CoverageDriverException.class, driver::discoverCoveragePeriods);
    assertTrue(exception.getMessage().contains("could not retrieve lock"));
    exception = assertThrows(CoverageDriverException.class, driver::queueStaleCoveragePeriods);
    assertTrue(exception.getMessage().contains("could not retrieve lock"));
}
Also used : Properties(gov.cms.ab2d.common.model.Properties) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Properties (gov.cms.ab2d.common.model.Properties)13 Test (org.junit.jupiter.api.Test)12 DisplayName (org.junit.jupiter.api.DisplayName)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 JobExecutionException (org.quartz.JobExecutionException)4 PropertiesService (gov.cms.ab2d.common.service.PropertiesService)3 CoverageDriverStub (gov.cms.ab2d.worker.processor.coverage.CoverageDriverStub)3 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)1 PropertiesDTO (gov.cms.ab2d.common.dto.PropertiesDTO)1 Job (gov.cms.ab2d.common.model.Job)1 OffsetDateTime (java.time.OffsetDateTime)1 HashMap (java.util.HashMap)1