Search in sources :

Example 1 with KildaFeatureToggles

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);
    }
}
Also used : KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles) KildaFeatureTogglesRepository(org.openkilda.persistence.repositories.KildaFeatureTogglesRepository)

Example 2 with KildaFeatureToggles

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);
    }
}
Also used : KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles) KildaFeatureTogglesRepository(org.openkilda.persistence.repositories.KildaFeatureTogglesRepository)

Example 3 with KildaFeatureToggles

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);
}
Also used : FlowDirection(org.openkilda.server42.messaging.FlowDirection) Arrays(java.util.Arrays) FlowStats(org.openkilda.model.FlowStats) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) HEALTHY(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.State.HEALTHY) Mock(org.mockito.Mock) FlowStatsRepository(org.openkilda.persistence.repositories.FlowStatsRepository) RunWith(org.junit.runner.RunWith) KildaFeatureTogglesRepository(org.openkilda.persistence.repositories.KildaFeatureTogglesRepository) PathNodePayload(org.openkilda.messaging.payload.flow.PathNodePayload) TIER_2_FAILED(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.State.TIER_2_FAILED) TIER_1_FAILED(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.State.TIER_1_FAILED) FlowLatencyMonitoringFsm(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm) Flow(org.openkilda.model.Flow) KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) UNSTABLE(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.State.UNSTABLE) FlowDefaults(org.openkilda.persistence.dummy.FlowDefaults) Duration(java.time.Duration) FlowPathDto(org.openkilda.messaging.model.FlowPathDto) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) PersistenceDummyEntityFactory(org.openkilda.persistence.dummy.PersistenceDummyEntityFactory) Before(org.junit.Before) FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowOperationsCarrier(org.openkilda.wfm.topology.flowmonitoring.bolt.FlowOperationsCarrier) PathComputationStrategy(org.openkilda.model.PathComputationStrategy) ManualClock(org.openkilda.stubs.ManualClock) UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.verify(org.mockito.Mockito.verify) SwitchId(org.openkilda.model.SwitchId) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) FlowStats(org.openkilda.model.FlowStats) KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles) Duration(java.time.Duration) FlowEndpoint(org.openkilda.model.FlowEndpoint) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 4 with KildaFeatureToggles

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;
}
Also used : KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles)

Example 5 with KildaFeatureToggles

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());
}
Also used : KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

KildaFeatureToggles (org.openkilda.model.KildaFeatureToggles)14 Test (org.junit.Test)6 SwitchId (org.openkilda.model.SwitchId)5 KildaFeatureTogglesRepository (org.openkilda.persistence.repositories.KildaFeatureTogglesRepository)5 ArrayList (java.util.ArrayList)3 Switch (org.openkilda.model.Switch)3 SwitchProperties (org.openkilda.model.SwitchProperties)3 String.format (java.lang.String.format)2 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Before (org.junit.Before)2 SwitchRulesDeleteRequest (org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest)2 SwitchRulesInstallRequest (org.openkilda.messaging.command.switches.SwitchRulesInstallRequest)2 ErrorData (org.openkilda.messaging.error.ErrorData)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2 ErrorType (org.openkilda.messaging.error.ErrorType)2