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());
}
}
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());
}
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();
}
}
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();
}
}
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"));
}
Aggregations