Skip to content

Add Tarantool 3 support and matrix tests #114

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

Merged
merged 6 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
env:
TARANTOOL_SERVER_USER: root
TARANTOOL_SERVER_GROUP: root
TARANTOOL_VERSION: "2.11.2-centos7"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why didn't you delete this job? It's duplicate as a part of matrix tests

Copy link
Contributor Author

@iDneprov iDneprov Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'v removed TrantoolCintainer classes from integration profile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Then rename jobs, it's confusing because matrix tests are also integration tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests-tarantool-container

tests-cartridge-container

tests-ee

run: ./mvnw -B test -P integration -Djacoco.destFile=target/jacoco-ce.exec --file pom.xml

- name: Upload jacoco exec results
Expand Down Expand Up @@ -67,6 +68,30 @@ jobs:
name: tests-ee-jacoco
path: "**/jacoco-ee.exec"

tests-matrix:
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
matrix:
tarantool-version: [ "1.x-centos7", "2.11.2-centos7", "3.0.1" ]
fail-fast: false
steps:
- uses: actions/checkout@v4

- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
cache: 'maven'

- name: Build and run integration matrix tests
env:
TARANTOOL_VERSION: ${{ matrix.tarantool-version }}
TARANTOOL_SERVER_USER: root
TARANTOOL_SERVER_GROUP: root
run: ./mvnw -B test -P tarantool-container --file pom.xml

merge-jacoco-report:
name: Jacoco Merge Results
needs:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
([#55](https://github.com/tarantool/testcontainers-java-tarantool/issues/55))
- Change private modifier to protected modifier for fields and methods in TarantoolCartridgeContainer
- Add `TARANTOOL_VERSION` environment variable support to TarantoolCartridgeContainer
`tarantool/tarantool:<TARANTOOL_VERSION>-centos7` if image name is omitted
`tarantool/tarantool:<TARANTOOL_VERSION>` if image name is omitted
([#102](https://github.com/tarantool/testcontainers-java-tarantool/pull/102))

## [1.1.0] - 2023-12-12
Expand Down
22 changes: 22 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,28 @@
</plugins>
</build>
</profile>
<profile>
<id>tarantool-container</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/*TarantoolContainer*IT.java</include>
</includes>
<systemPropertyVariables>
<logback.configurationFile>${logging.config}</logback.configurationFile>
<logLevel>${logging.logLevel}</logLevel>
</systemPropertyVariables>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class TarantoolContainer extends GenericContainer<TarantoolContainer>
implements TarantoolContainerOperations<TarantoolContainer> {

public static final String TARANTOOL_IMAGE = "tarantool/tarantool";
public static final String DEFAULT_IMAGE_VERSION = "2.10.5";
public static final String DEFAULT_TARANTOOL_BASE_IMAGE = String.format("%s:%s-centos7", TARANTOOL_IMAGE, DEFAULT_IMAGE_VERSION);
public static final String DEFAULT_IMAGE_VERSION = "2.11.2-centos7";
public static final String DEFAULT_TARANTOOL_BASE_IMAGE = String.format("%s:%s", TARANTOOL_IMAGE, DEFAULT_IMAGE_VERSION);


private static final String DEFAULT_HOST = "localhost";
Expand Down Expand Up @@ -386,7 +386,7 @@ public <T> T executeCommandDecoded(String command) throws Exception {
private void setImageNameFromEnv() {
String version = System.getenv("TARANTOOL_VERSION");
if (version != null && !version.trim().isEmpty()) {
setDockerImageName(String.format("%s:%s-centos7", TARANTOOL_IMAGE, version));
setDockerImageName(String.format("%s:%s", TARANTOOL_IMAGE, version));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public final class TarantoolContainerClientHelper {
" ):eval('%s')}) " +
" ); " +
" os.exit(); " +
"\" | tarantool";
"\" > container-tmp.lua &&" +
" tarantool container-tmp.lua";
private static final String SSL_COMMAND_TEMPLATE =
"echo \" " +
" print(require('yaml').encode( " +
Expand All @@ -45,7 +46,8 @@ public final class TarantoolContainerClientHelper {
" ):eval('%s')}) " +
" ); " +
" os.exit(); " +
"\" | tarantool";
"\" > container-tmp.lua &&" +
" tarantool container-tmp.lua";
Comment on lines +51 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe this in comments if you didn't

private static final String COMMAND_TEMPLATE = "echo \" " +
" print(require('yaml').encode( " +
" {require('net.box').connect( " +
Expand All @@ -54,7 +56,8 @@ public final class TarantoolContainerClientHelper {
" ):eval('%s')}) " +
" ); " +
" os.exit(); " +
"\" | tarantool";
"\" > container-tmp.lua &&" +
" tarantool container-tmp.lua";

TarantoolContainerClientHelper(TarantoolContainerOperations<? extends Container<?>> container) {
this.container = container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
* @author Ivan Dneprov
*/
@Testcontainers
public class TarantoolStaticContainerIT {
public class StaticTarantoolContainerIT {
protected static final String tarantoolVersion = System.getenv().get("TARANTOOL_VERSION");

@Container
private static final TarantoolContainer container = new TarantoolContainer();
protected static final TarantoolContainer container = new TarantoolContainer();

@Test
public void testExecuteCommand() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class TarantoolContainerIT {

private static final String ENV_TARANTOOL_VERSION = "TARANTOOL_VERSION";
protected static final String tarantoolVersion = System.getenv(ENV_TARANTOOL_VERSION);

private void addEnv(String key, String value) throws NoSuchFieldException, IllegalAccessException {
Class<?> classOfMap = System.getenv().getClass();
Expand Down Expand Up @@ -73,31 +74,14 @@ public void testContainerWithParameters() throws Exception {

@Test
public void testContainerWithTrueVersion() throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In matrix tests env var TARANTOOL_VERSION always set. So this test is redundant.

final String version = "2.11.0";
addEnv(ENV_TARANTOOL_VERSION, version);

List<String> result;
try (TarantoolContainer container = new TarantoolContainer()) {
container.start();
result = container.executeCommandDecoded("return _TARANTOOL");
}

removeEnv(ENV_TARANTOOL_VERSION, version);
assertEquals(1, result.size());
assertTrue(result.get(0).startsWith(version));
}

@Test
public void testContainerWithDefaultVersionVersion() throws Exception {

List<String> result;
try (TarantoolContainer container = new TarantoolContainer()) {
container.start();
result = container.executeCommandDecoded("return _TARANTOOL");
}

assertEquals(1, result.size());
assertTrue(result.get(0).startsWith(TarantoolContainer.DEFAULT_IMAGE_VERSION));
assertTrue(result.get(0).startsWith(String.valueOf(tarantoolVersion.charAt(0))));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if these are not CI tests with predefined Tarantool versions, and there is no TARANTOOL_VERSION variable on the system on which the test runs? It seems that a NullPointerException is possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added if statement

}

@Test
Expand Down