Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DROOLS-7442] Smoke tests for Remote and ProtoStream #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:14.0 https://infinispan.org/schemas/infinispan-config-14.0.xsd
urn:infinispan:server:14.0 https://infinispan.org/schemas/infinispan-server-14.0.xsd"
xmlns="urn:infinispan:config:14.0"
xmlns:server="urn:infinispan:server:14.0">

<cache-container name="default" statistics="true">
<!-- no transport = local cache -->
<security>
<authorization/>
</security>
</cache-container>

<server xmlns="urn:infinispan:server:14.0">
<interfaces>
<interface name="public">
<inet-address value="${infinispan.bind.address:127.0.0.1}"/>
</interface>
</interfaces>

<socket-bindings default-interface="public" port-offset="${infinispan.socket.binding.port-offset:0}">
<socket-binding name="default" port="${infinispan.bind.port:11222}"/>
<socket-binding name="memcached" port="11221"/>
</socket-bindings>

<security>
<credential-stores>
<credential-store name="credentials" path="credentials.pfx">
<clear-text-credential clear-text="secret"/>
</credential-store>
</credential-stores>
<security-realms>
<security-realm name="default">
<!-- Uncomment to enable TLS on the realm -->
<!-- server-identities>
<ssl>
<keystore path="application.keystore"
password="password" alias="server"
generate-self-signed-certificate-host="localhost"/>
</ssl>
</server-identities-->
<properties-realm groups-attribute="Roles">
<user-properties path="users.properties"/>
<group-properties path="groups.properties"/>
</properties-realm>
</security-realm>
</security-realms>
</security>

<endpoints socket-binding="default" security-realm="default" />
</server>
</infinispan>
55 changes: 55 additions & 0 deletions drools-reliability/drools-reliability-infinispan/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,61 @@
</build>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<!-- override default-test for embedded -->
<id>default-test</id>
<configuration>
<excludes>
<exclude>**/*SmokeTest.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>smoke-tests-remote</id>
<configuration>
<systemPropertyVariables>
<drools.reliability.storage.infinispan.mode>REMOTE</drools.reliability.storage.infinispan.mode>
</systemPropertyVariables>
<includes>
<include>**/smoke/remote/*SmokeTest.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
<execution>
<id>smoke-tests-remote-proto</id>
<configuration>
<systemPropertyVariables>
<drools.reliability.storage.infinispan.mode>REMOTE</drools.reliability.storage.infinispan.mode>
<drools.reliability.storage.infinispan.marshaller>PROTOSTREAM</drools.reliability.storage.infinispan.marshaller>
<drools.reliability.storage.infinispan.serialization.context.initializer>org.drools.reliability.infinispan.proto.TestProtoStreamSchemaImpl</drools.reliability.storage.infinispan.serialization.context.initializer>
</systemPropertyVariables>
<includes>
<include>**/smoke/proto/*SmokeTest.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>remote</id>
<activation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ static Stream<PersistedSessionOption.PersistenceStrategy> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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 {

}
Original file line number Diff line number Diff line change
@@ -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 {

}