use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class AbstractYFlowTest method alterFeatureToggles.
protected void alterFeatureToggles(Boolean isCreateAllowed, Boolean isUpdateAllowed, Boolean isDeleteAllowed, Boolean isModifyYFlowEnabled) {
KildaFeatureTogglesRepository repository = persistenceManager.getRepositoryFactory().createFeatureTogglesRepository();
KildaFeatureToggles toggles = repository.find().orElseGet(() -> {
KildaFeatureToggles newToggles = KildaFeatureToggles.builder().build();
repository.add(newToggles);
return newToggles;
});
if (isCreateAllowed != null) {
toggles.setCreateFlowEnabled(isCreateAllowed);
}
if (isUpdateAllowed != null) {
toggles.setUpdateFlowEnabled(isUpdateAllowed);
}
if (isDeleteAllowed != null) {
toggles.setDeleteFlowEnabled(isDeleteAllowed);
}
if (isModifyYFlowEnabled != null) {
toggles.setModifyYFlowEnabled(isModifyYFlowEnabled);
}
}
use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class AbstractFlowTest method alterFeatureToggles.
protected void alterFeatureToggles(Boolean isCreateAllowed, Boolean isUpdateAllowed, Boolean isDeleteAllowed) {
KildaFeatureTogglesRepository repository = persistenceManager.getRepositoryFactory().createFeatureTogglesRepository();
KildaFeatureToggles toggles = repository.find().orElseGet(() -> {
KildaFeatureToggles newToggles = KildaFeatureToggles.builder().build();
repository.add(newToggles);
return newToggles;
});
if (isCreateAllowed != null) {
toggles.setCreateFlowEnabled(isCreateAllowed);
}
if (isUpdateAllowed != null) {
toggles.setUpdateFlowEnabled(isUpdateAllowed);
}
if (isDeleteAllowed != null) {
toggles.setDeleteFlowEnabled(isDeleteAllowed);
}
}
use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class ActionServiceTest method shouldFailTier1AndDoNotSendRerouteRequestWhenToggleIsFalse.
@Test
public void shouldFailTier1AndDoNotSendRerouteRequestWhenToggleIsFalse() {
transactionManager.doInTransaction(() -> {
KildaFeatureToggles featureToggles = featureTogglesRepository.find().orElseThrow(() -> new IllegalStateException("Feature toggle not found"));
featureToggles.setFlowLatencyMonitoringReactions(false);
});
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, NANOSECOND);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, NANOSECOND);
Duration latency = Duration.ofNanos((long) (flow.getMaxLatency() * (1 + THRESHOLD)) + 5);
for (int i = 0; i < 10; i++) {
clock.adjust(Duration.ofSeconds(10));
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, latency);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, latency.minus(NANOSECOND));
service.processTick();
if (i == 0) {
assertTrue(service.fsms.values().stream().allMatch(fsm -> UNSTABLE.equals(fsm.getCurrentState())));
}
}
assertEquals(2, service.fsms.values().size());
assertTrue(service.fsms.values().stream().allMatch(fsm -> TIER_1_FAILED.equals(fsm.getCurrentState())));
FlowStats actual = flowStatsRepository.findByFlowId(flow.getFlowId()).orElseThrow(() -> new IllegalStateException("Flow not found"));
assertEquals(latency.getNano(), actual.getForwardLatency().intValue());
assertEquals(latency.minus(NANOSECOND).getNano(), actual.getReverseLatency().intValue());
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class FermaKildaFeatureTogglesRepository method getOrDefault.
@Override
public KildaFeatureToggles getOrDefault() {
KildaFeatureToggles result = new KildaFeatureToggles(find().orElse(KildaFeatureToggles.DEFAULTS));
KildaFeatureToggles.FeatureTogglesCloner.INSTANCE.replaceNullProperties(KildaFeatureToggles.DEFAULTS, result);
return result;
}
use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class FermaKildaFeatureTogglesRepositoryTest method shouldCreateAndUpdateFeatureToggles.
@Test
public void shouldCreateAndUpdateFeatureToggles() {
KildaFeatureToggles featureTogglesA = KildaFeatureToggles.builder().flowsRerouteOnIslDiscoveryEnabled(false).createFlowEnabled(false).updateFlowEnabled(false).deleteFlowEnabled(false).useBfdForIslIntegrityCheck(false).floodlightRoutePeriodicSync(false).flowsRerouteUsingDefaultEncapType(false).build();
featureTogglesRepository.add(featureTogglesA);
KildaFeatureToggles foundFeatureToggles = featureTogglesRepository.find().get();
assertEquals(featureTogglesA, foundFeatureToggles);
foundFeatureToggles.setUpdateFlowEnabled(true);
KildaFeatureToggles updatedFeatureToggles = featureTogglesRepository.find().get();
assertTrue(updatedFeatureToggles.getUpdateFlowEnabled());
}
Aggregations