Skip to content

Commit

Permalink
Init global variable to GitHub Actions instead
Browse files Browse the repository at this point in the history
- Change the MySQL setup to use docker-compose
- Add init options of `mysqld`
- Remove global variable initialization from the test code
  • Loading branch information
mirromutth committed Feb 5, 2024
1 parent a2668e4 commit 8eedb75
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/ci-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ jobs:
- name: Shutdown the Default MySQL
run: sudo service mysql stop
- name: Set up MySQL ${{ matrix.mysql-version }}
uses: asyncer-io/mysql-action@trunk
with:
mysql version: ${{ matrix.mysql-version }}
mysql database: r2dbc
mysql root password: r2dbc-password!@
env:
MYSQL_DATABASE: r2dbc
MYSQL_ROOT_PASSWORD: r2dbc-password!@
MYSQL_VERSION: ${{ matrix.mysql-version }}
run: docker-compose -f ${{ github.workspace }}/containers/mysql-compose.yml up -d
- name: Integration test with MySQL ${{ matrix.mysql-version }}
run: ./mvnw -B verify -Dmaven.javadoc.skip=true -Dmaven.surefire.skip=true -Dtest.mysql.password=r2dbc-password!@ -Dtest.mysql.version=${{ matrix.mysql-version }} -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
run: |
./mvnw -B verify -Dmaven.javadoc.skip=true \
-Dmaven.surefire.skip=true \
-Dtest.mysql.password=r2dbc-password!@ \
-Dtest.mysql.version=${{ matrix.mysql-version }} \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
12 changes: 12 additions & 0 deletions containers/mysql-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"

services:
mariadb:
image: mysql:${MYSQL_VERSION}
container_name: mysql_${MYSQL_VERSION}
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
command: mysqld --local-infile=true --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
ports:
- "3306:3306"
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import io.r2dbc.spi.ColumnMetadata;
import io.r2dbc.spi.R2dbcPermissionDeniedException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand All @@ -28,7 +27,6 @@
import org.testcontainers.shaded.com.fasterxml.jackson.databind.node.ObjectNode;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import java.io.IOException;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -62,20 +60,6 @@ class ConnectionIntegrationTest extends IntegrationTestSupport {
super(config);
}

@BeforeAll
static void initGlobalVariables() {
// TODO: move it to GitHub Actions instead of test code
MySqlConnectionFactory.from(config)
.create()
.flatMap(conn -> conn.createStatement("SET GLOBAL local_infile=ON")
.execute()
.flatMap(MySqlResult::getRowsUpdated)
.then(conn.close())
.onErrorResume(e -> conn.close().then(Mono.error(e))))
.as(StepVerifier::create)
.verifyComplete();
}

@Test
void isInTransaction() {
complete(connection -> Mono.<Void>fromRunnable(() -> assertThat(connection.isInTransaction())
Expand Down

0 comments on commit 8eedb75

Please sign in to comment.