Skip to content

Commit

Permalink
[DROOLS-7485] StoresOnly Strategy - multiple kieSession from the same…
Browse files Browse the repository at this point in the history
… KieBase test

- Parameterize multiple ksession tests to use multiple kbases or one kbase
  • Loading branch information
tkobayas committed Jul 12, 2023
1 parent ac7544a commit 21fed7d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ void insertAdvanceFireFailoverExpire_shouldExpireAfterFailover(PersistedSessionO
}

@ParameterizedTest
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepoints")
void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy) {
KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepointsAndKieBaseCache")
void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy, boolean useKieBaseCache) {
KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);

SessionPseudoClock clock1 = getSessionClock(session1);
SessionPseudoClock clock2 = getSessionClock(session2);
Expand All @@ -182,9 +182,9 @@ void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailov
//-- Assume JVM down here. Fail-over to other JVM or rebooted JVM
//-- ksession and kbase are lost. CacheManager is recreated. Client knows only "id"
failover();
session1=restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session1=restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock1 = getSessionClock(session1);
session2=restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session2=restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock2 = getSessionClock(session2);

assertThat(fireAllRules(session1)).isEqualTo(1);
Expand All @@ -202,9 +202,9 @@ void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailov
insert(session2, new StockTick("ACME"));

failover();
session1=restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session1=restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock1 = getSessionClock(session1);
session2=restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session2=restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock2 = getSessionClock(session2);

assertThat(fireAllRules(session1)).isEqualTo(0);
Expand All @@ -218,11 +218,11 @@ void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailov
}

@ParameterizedTest
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepoints")
void multipleKieSessions_insertAdvanceFailoverExpireFire_shouldExpireAfterFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy) {
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepointsAndKieBaseCache")
void multipleKieSessions_insertAdvanceFailoverExpireFire_shouldExpireAfterFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy, boolean useKieBaseCache) {

KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);

SessionPseudoClock clock1 = getSessionClock(session1);
SessionPseudoClock clock2 = getSessionClock(session2);
Expand All @@ -236,9 +236,9 @@ void multipleKieSessions_insertAdvanceFailoverExpireFire_shouldExpireAfterFailov
insert(session2, new StockTick("ACME"));

failover();
session1 = restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session1 = restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock1 = getSessionClock(session1);
session2 = restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session2 = restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock2 = getSessionClock(session2);

clock1.advanceTime(58, TimeUnit.SECONDS);
Expand All @@ -254,12 +254,12 @@ void multipleKieSessions_insertAdvanceFailoverExpireFire_shouldExpireAfterFailov
}

@ParameterizedTest
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepoints")
void multipleKieSessions_insertAdvanceFireFailoverExpire_shouldExpireAfterFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy) {
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepointsAndKieBaseCache")
void multipleKieSessions_insertAdvanceFireFailoverExpire_shouldExpireAfterFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy, boolean useKieBaseCache) {

KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
SessionPseudoClock clock1 = getSessionClock(session1);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
SessionPseudoClock clock2 = getSessionClock(session2);

insert(session1, new StockTick("DROO"));
Expand All @@ -274,9 +274,9 @@ void multipleKieSessions_insertAdvanceFireFailoverExpire_shouldExpireAfterFailov
assertThat(fireAllRules(session2)).isEqualTo(0);

failover();
session1 = restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session1 = restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock1 = getSessionClock(session1);
session2 = restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session2 = restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock2 = getSessionClock(session2);

clock1.advanceTime(58, TimeUnit.SECONDS);
Expand Down
Loading

0 comments on commit 21fed7d

Please sign in to comment.