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

Bump testcontainers-java-tarantool to 1.2.0 #444

Merged
merged 2 commits into from
Dec 21, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## [Unreleased]
### Internal and API changes

- Bump org.testcontainers:junit-jupiter version to 1.19.3 ([#442](https://github.com/tarantool/cartridge-java/issues/442))
- Bump testcontainers-java-tarantool version to 1.2.0 ([#442](https://github.com/tarantool/cartridge-java/issues/442))

### Features

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.17.4</version>
<version>1.19.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.tarantool</groupId>
<artifactId>testcontainers-java-tarantool</artifactId>
<version>1.0.1</version>
<version>1.2.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ abstract class CartridgeMixedInstancesContainer {
"cartridge-java-test-mixed",
"cartridge/instances_mixed.yml",
"cartridge/topology_mixed.lua")
.withDirectoryBinding("cartridge")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get how this works. Please explain how does a container get needed files?

Copy link
Contributor Author

@nickkkccc nickkkccc Dec 21, 2023

Choose a reason for hiding this comment

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

Previous version of the test containers (e.g., 1.0.1):

  1. Dependencies are downloaded on the system inside the container (gcc and others).
  2. The cartridge folder is a mapping of the /app directory.
  3. The cartridge folder is copied into the image as the /app working directory. This step is where the image is built.
  4. Start the container and run the cartridge build command (dependency rocks are downloaded into the working directory at this point).
  5. Key point: the dependency rocks are downloaded into the /app directory related to the container. But docker looks at the cartridge folder that was mapped earlier in the build phase.

So binding works with 1.0.1

New version of testcontainers:

Copying the /cartridge directory and executing cartridge build happens during the image build phase. Key point: when using the .withDirectoryBinding method at the container startup stage, docker will look at the /cartridge directory that doesn't have the built rocks dependencies in it.

So binding doesn't work with new testcontainers.

.withLogConsumer(new Slf4jLogConsumer(logger))
.waitingFor(Wait.forLogMessage(".*Listening HTTP on.*", 3))
.withStartupTimeout(Duration.ofMinutes(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
*/
public class ClusterDiscoveryIT extends SharedCartridgeContainer {

private static final String TEST_ROUTER1_URI = "localhost:3301";
private static final String TEST_ROUTER2_URI = "localhost:3302";
private static final String TEST_ROUTER1_URI = "0.0.0.0:3301";
private static final String TEST_ROUTER2_URI = "0.0.0.0:3302";

@BeforeAll
public static void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class SharedCartridgeContainer {
"cartridge-java-test",
"cartridge/instances.yml",
"cartridge/topology.lua")
.withDirectoryBinding("cartridge")
.withEnv("TARANTOOL_CLUSTER_COOKIE", "secret-cluster-cookie")
.withLogConsumer(new Slf4jLogConsumer(logger))
.waitingFor(Wait.forLogMessage(".*Listening HTTP on.*", 4))
.withStartupTimeout(Duration.ofMinutes(2));
Expand Down
3 changes: 1 addition & 2 deletions src/test/resources/cartridge/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ local ok, err = cartridge.cfg({
'app.roles.api_router',
'app.roles.api_storage',
'app.roles.custom',
},
cluster_cookie = 'testapp-cluster-cookie',
}
}, {
readahead = 10 * 1024 * 1024, -- 10 MB
net_msg_max = 11140,
Expand Down
10 changes: 5 additions & 5 deletions src/test/resources/cartridge/instances.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
testapp.router:
workdir: ./tmp/db_dev/3301
advertise_uri: localhost:3301
advertise_uri: 0.0.0.0:3301
http_port: 8081

testapp.second-router:
workdir: ./tmp/db_dev/3302
advertise_uri: localhost:3302
advertise_uri: 0.0.0.0:3302
http_port: 8082

testapp.third-router:
workdir: ./tmp/db_dev/3303
advertise_uri: localhost:3303
advertise_uri: 0.0.0.0:3303
http_port: 8083

testapp.s1-storage:
workdir: ./tmp/db_dev/3304
advertise_uri: localhost:3304
advertise_uri: 0.0.0.0:3304
http_port: 8084

testapp.s2-storage:
workdir: ./tmp/db_dev/3305
advertise_uri: localhost:3305
advertise_uri: 0.0.0.0:3305
http_port: 8085
6 changes: 3 additions & 3 deletions src/test/resources/cartridge/instances_mixed.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
testapp.1:
workdir: ./tmp/db_dev/3301
advertise_uri: localhost:3301
advertise_uri: 0.0.0.0:3301
http_port: 8081

testapp.2:
workdir: ./tmp/db_dev/3302
advertise_uri: localhost:3302
advertise_uri: 0.0.0.0:3302
http_port: 8082

testapp.3:
workdir: ./tmp/db_dev/3303
advertise_uri: localhost:3303
advertise_uri: 0.0.0.0:3303
http_port: 8083
4 changes: 2 additions & 2 deletions src/test/resources/cartridge/testapp-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ source = {
dependencies = {
'tarantool',
'lua >= 5.1',
'cartridge == 2.7.3-1',
'crud == 0.14.0-1',
'cartridge == 2.8.3-1',
'crud == 1.3.0-1',
}
build = {
type = 'none';
Expand Down
10 changes: 5 additions & 5 deletions src/test/resources/cartridge/topology.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ cartridge = require('cartridge')
replicasets = { {
alias = 'app-router',
roles = { 'vshard-router', 'app.roles.custom', 'app.roles.api_router' },
join_servers = { { uri = 'localhost:3301' } }
join_servers = { { uri = '0.0.0.0:3301' } }
}, {
alias = 'app-router-second',
roles = { 'vshard-router', 'app.roles.custom', 'app.roles.api_router' },
join_servers = { { uri = 'localhost:3302' } }
join_servers = { { uri = '0.0.0.0:3302' } }
}, {
alias = 'app-router-third',
roles = { 'vshard-router', 'app.roles.custom', 'app.roles.api_router' },
join_servers = { { uri = 'localhost:3303' } }
join_servers = { { uri = '0.0.0.0:3303' } }
}, {
alias = 's1-storage',
roles = { 'vshard-storage', 'app.roles.api_storage' },
join_servers = { { uri = 'localhost:3304' } }
join_servers = { { uri = '0.0.0.0:3304' } }
},
{
alias = 's2-storage',
roles = { 'vshard-storage', 'app.roles.api_storage' },
join_servers = { { uri = 'localhost:3305' } }
join_servers = { { uri = '0.0.0.0:3305' } }
} }
return cartridge.admin_edit_topology({ replicasets = replicasets })
6 changes: 3 additions & 3 deletions src/test/resources/cartridge/topology_mixed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ replicasets = { {
alias = 'mixed-replicasets',
roles = { 'vshard-router', 'app.roles.api_router', 'vshard-storage', 'app.roles.api_storage', 'app.roles.custom' },
join_servers = {
{ uri = 'localhost:3301' },
{ uri = 'localhost:3302' },
{ uri = 'localhost:3303' },
{ uri = '0.0.0.0:3301' },
{ uri = '0.0.0.0:3302' },
{ uri = '0.0.0.0:3303' },
}
} }
return cartridge.admin_edit_topology({ replicasets = replicasets })
Loading