diff --git a/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java b/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java index 25ab72be3d0..f6ad4a73733 100644 --- a/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java +++ b/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java @@ -93,11 +93,11 @@ static class SimpleStoreRuntimeEventListener implements RuleRuntimeEventListener } public void objectInserted(ObjectInsertedEvent ev) { - // no-op + // no-op. The object is already added in the storage by addHandle } public void objectDeleted(ObjectDeletedEvent ev) { - // no-op + // no-op. The object is already removed in the storage by removeHandle } public void objectUpdated(ObjectUpdatedEvent ev) { diff --git a/drools-reliability/drools-reliability-infinispan/infinispan-remote-config/infinispan-local.xml b/drools-reliability/drools-reliability-infinispan/infinispan-remote-config/infinispan-local.xml new file mode 100644 index 00000000000..b6f6b768516 --- /dev/null +++ b/drools-reliability/drools-reliability-infinispan/infinispan-remote-config/infinispan-local.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drools-reliability/drools-reliability-infinispan/pom.xml b/drools-reliability/drools-reliability-infinispan/pom.xml index efc2da48db5..bbb795cda68 100644 --- a/drools-reliability/drools-reliability-infinispan/pom.xml +++ b/drools-reliability/drools-reliability-infinispan/pom.xml @@ -163,6 +163,61 @@ + + default + + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + default-test + + + **/*SmokeTest.java + + + + + smoke-tests-remote + + + REMOTE + + + **/smoke/remote/*SmokeTest.java + + + + test + + + + smoke-tests-remote-proto + + + REMOTE + PROTOSTREAM + org.drools.reliability.infinispan.proto.TestProtoStreamSchemaImpl + + + **/smoke/proto/*SmokeTest.java + + + + test + + + + + + + remote diff --git a/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/ReliabilityTestBasics.java b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/ReliabilityTestBasics.java index 26bab51edf9..ba1d4737143 100644 --- a/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/ReliabilityTestBasics.java +++ b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/ReliabilityTestBasics.java @@ -95,7 +95,9 @@ static Stream strategyProviderFull() public void setUp() { if (((TestableStorageManager) StorageManagerFactory.get().getStorageManager()).isRemote()) { LOG.info("Starting InfinispanContainer"); - container = new InfinispanContainer(); + container = new InfinispanContainer() + .withFileSystemBind("infinispan-remote-config", "/user-config") + .withCommand("-c /user-config/infinispan-local.xml"); container.start(); LOG.info("InfinispanContainer started"); // takes about 10 seconds InfinispanStorageManager cacheManager = (InfinispanStorageManager) StorageManagerFactory.get().getStorageManager(); diff --git a/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/BaseSmokeTest.java b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/BaseSmokeTest.java new file mode 100644 index 00000000000..d7b4b1e9dab --- /dev/null +++ b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/BaseSmokeTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2023 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.drools.reliability.infinispan.smoke; + +import org.drools.reliability.infinispan.BeforeAllMethodExtension; +import org.drools.reliability.infinispan.ReliabilityTestBasics; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.kie.api.runtime.conf.PersistedSessionOption; +import org.test.domain.Person; + +import static org.assertj.core.api.Assertions.assertThat; + +@ExtendWith(BeforeAllMethodExtension.class) +public class BaseSmokeTest extends ReliabilityTestBasics { + + private static final String BASIC_RULE = + "import " + Person.class.getCanonicalName() + ";" + + "global java.util.List results;" + + "rule X when\n" + + " $s: String()\n" + + " $p: Person( getName().startsWith($s) )\n" + + "then\n" + + " results.add( $p.getName() );\n" + + "end"; + + @ParameterizedTest + @MethodSource("strategyProviderStoresOnlyWithExplicitSafepoints") + void insertFailoverInsertFire_shouldRecoverFromFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy) { + createSession(BASIC_RULE, persistenceStrategy, safepointStrategy); + + insertString("M"); + insertMatchingPerson("Matching Person One", 37); + + //-- 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(); + + restoreSession(BASIC_RULE, persistenceStrategy, safepointStrategy); + + insertNonMatchingPerson("Toshiya", 35); + insertMatchingPerson("Matching Person Two", 40); + + session.fireAllRules(); + + assertThat(getResults()).containsExactlyInAnyOrder("Matching Person One", "Matching Person Two"); + } +} diff --git a/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/proto/ProtoSmokeTest.java b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/proto/ProtoSmokeTest.java new file mode 100644 index 00000000000..c7978f623d8 --- /dev/null +++ b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/proto/ProtoSmokeTest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2023 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.drools.reliability.infinispan.smoke.proto; + +import org.drools.reliability.infinispan.BeforeAllMethodExtension; +import org.drools.reliability.infinispan.smoke.BaseSmokeTest; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.extension.ExtendWith; + +import static org.junit.jupiter.api.condition.OS.WINDOWS; + +@DisabledOnOs(WINDOWS) +@ExtendWith(BeforeAllMethodExtension.class) +class ProtoSmokeTest extends BaseSmokeTest { + +} diff --git a/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/remote/RemoteSmokeTest.java b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/remote/RemoteSmokeTest.java new file mode 100644 index 00000000000..b405030c38c --- /dev/null +++ b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/smoke/remote/RemoteSmokeTest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2023 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.drools.reliability.infinispan.smoke.remote; + +import org.drools.reliability.infinispan.BeforeAllMethodExtension; +import org.drools.reliability.infinispan.smoke.BaseSmokeTest; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.extension.ExtendWith; + +import static org.junit.jupiter.api.condition.OS.WINDOWS; + +@DisabledOnOs(WINDOWS) +@ExtendWith(BeforeAllMethodExtension.class) +class RemoteSmokeTest extends BaseSmokeTest { + +}