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 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
50 changes: 43 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches: [ master ]

jobs:
tests-ce:
tests-cartridge-container:
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
Expand All @@ -26,19 +26,20 @@ jobs:
cache: 'maven'

- name: Build and run unit tests
run: ./mvnw -B verify -Djacoco.destFile=target/jacoco-ce.exec --file pom.xml
run: ./mvnw -B verify -Djacoco.destFile=target/jacoco-cartridge-container.exec --file pom.xml

- name: Run integration tests
env:
TARANTOOL_SERVER_USER: root
TARANTOOL_SERVER_GROUP: root
run: ./mvnw -B test -P integration -Djacoco.destFile=target/jacoco-ce.exec --file pom.xml
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-cartridge-container.exec --file pom.xml

- name: Upload jacoco exec results
uses: actions/upload-artifact@v2
with:
name: tests-ce-jacoco
path: "**/jacoco-ce.exec"
name: tests-cartridge-container-jacoco
path: "**/jacoco-cartridge-container.exec"

tests-ee:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -67,10 +68,40 @@ jobs:
name: tests-ee-jacoco
path: "**/jacoco-ee.exec"

tests-tarantool-container:
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 -Djacoco.destFile=target/jacoco-tarantool-container.exec --file pom.xml

- name: Upload jacoco exec results
uses: actions/upload-artifact@v2
with:
name: tests-tarantool-container-jacoco
path: "**/jacoco-tarantool-container.exec"

merge-jacoco-report:
name: Jacoco Merge Results
needs:
- tests-ce
- tests-cartridge-container
- tests-ee
runs-on: ubuntu-latest
steps:
Expand All @@ -85,14 +116,19 @@ jobs:

- uses: actions/download-artifact@v2
with:
name: tests-ce-jacoco
name: tests-cartridge-container-jacoco
path: .

- uses: actions/download-artifact@v2
with:
name: tests-ee-jacoco
path: .

- uses: actions/download-artifact@v2
with:
name: tests-tarantool-container-jacoco
path: .

- name: merge results
run: |
./mvnw package jacoco:merge jacoco:report -DskipTests -Darguments=-DskipTests
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
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
</includes>
<excludes>
<exclude>**/*EnterpriseIT.java</exclude>
<exclude>**/*TarantoolContainer*IT.java</exclude>
</excludes>
<systemPropertyVariables>
<logback.configurationFile>${logging.config}</logback.configurationFile>
Expand Down Expand Up @@ -364,6 +365,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 @@ -25,6 +25,8 @@ public final class TarantoolContainerClientHelper {
"Executed script %s with exit code %d, stderr: \"%s\", stdout: \"%s\"";
private static final String EXECUTE_COMMAND_ERROR_TEMPLATE =
"Executed command \"%s\" with exit code %d, stderr: \"%s\", stdout: \"%s\"";
// Generates bash command witch creates executable lua file with connection to required node
// and evaluation of needed lua code
private static final String MTLS_COMMAND_TEMPLATE =
"echo \" " +
" print(require('yaml').encode( " +
Expand All @@ -35,7 +37,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 +48,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 +58,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
4 changes: 2 additions & 2 deletions src/main/resources/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG TARANTOOL_VERSION=2.11.0
FROM tarantool/tarantool:${TARANTOOL_VERSION}-centos7 AS cartridge-base
ARG TARANTOOL_VERSION=2.11.2-centos7
FROM tarantool/tarantool:${TARANTOOL_VERSION} AS cartridge-base

# system preparations because docker mount directory as a root
ARG TARANTOOL_SERVER_USER="root"
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,16 @@ 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");
if (tarantoolVersion != null) {
assertTrue(result.get(0).startsWith(String.valueOf(tarantoolVersion.charAt(0))));
}

assertEquals(1, result.size());
assertTrue(result.get(0).startsWith(TarantoolContainer.DEFAULT_IMAGE_VERSION));
}

@Test
Expand Down