Skip to content

Commit

Permalink
Fix "unexpected end of stream" error.
Browse files Browse the repository at this point in the history
We check that MariaDB container started, by looking into log and waiting
for special lines. Before that change, we were looking for a line "ready for connections",
which was duplicated and its first appearance was right before a reload
of the container, so in some cases we were trying to connect to
non-working DBMS. Now we use a unique line.
  • Loading branch information
fedinskiy committed Apr 20, 2022
1 parent 9e85f74 commit e8ac02b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.quarkus.ts.spring.web;

public class MariaDBUtils {
public static final int PORT = 3306;
public static final String START_LOG = "socket: '/run/mysqld/mysqld.sock' port: " + PORT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.quarkus.test.services.Container;
import io.quarkus.test.services.QuarkusApplication;
import io.quarkus.ts.spring.web.AbstractDbIT;
import io.quarkus.ts.spring.web.MariaDBUtils;
import io.quarkus.ts.spring.web.boostrap.persistence.model.Book;
import io.restassured.response.Response;

Expand All @@ -25,9 +26,7 @@ public class BookResourceIT extends AbstractDbIT {

private static final String API_ROOT = "/api/books";

static final int MARIADB_PORT = 3306;

@Container(image = "${mariadb.10.image}", port = MARIADB_PORT, expectedLog = "ready for connections")
@Container(image = "${mariadb.10.image}", port = MariaDBUtils.PORT, expectedLog = MariaDBUtils.START_LOG)
static final MariaDbService database = new MariaDbService();

@QuarkusApplication
Expand Down Expand Up @@ -111,7 +110,6 @@ public void whenUpdateCreatedBook_thenUpdated() {
assertEquals(HttpStatus.OK.value(), response.getStatusCode());
assertEquals("newAuthor", response.jsonPath()
.get("author"));

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import io.quarkus.test.services.Container;
import io.quarkus.test.services.QuarkusApplication;
import io.quarkus.ts.spring.web.AbstractDbIT;
import io.quarkus.ts.spring.web.MariaDBUtils;

@QuarkusScenario
public class HomePageIT extends AbstractDbIT {

static final int MARIADB_PORT = 3306;

@Container(image = "${mariadb.10.image}", port = MARIADB_PORT, expectedLog = "ready for connections")
@Container(image = "${mariadb.10.image}", port = MariaDBUtils.PORT, expectedLog = MariaDBUtils.START_LOG)
static final MariaDbService database = new MariaDbService();

@QuarkusApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
import io.quarkus.test.services.Container;
import io.quarkus.test.services.QuarkusApplication;
import io.quarkus.ts.spring.web.AbstractDbIT;
import io.quarkus.ts.spring.web.MariaDBUtils;
import io.restassured.response.Response;

@QuarkusScenario
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class OpenApiIT extends AbstractDbIT {
private static Response response;

static final int MARIADB_PORT = 3306;

@Container(image = "${mariadb.10.image}", port = MARIADB_PORT, expectedLog = "ready for connections")
@Container(image = "${mariadb.10.image}", port = MariaDBUtils.PORT, expectedLog = MariaDBUtils.START_LOG)
static final MariaDbService database = new MariaDbService();

@QuarkusApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public class MultiplePersistenceIT extends AbstractMultiplePersistenceIT {

static final int MARIADB_PORT = 3306;
static final int POSTGRESQL_PORT = 5432;
private static final String MARIADB_START_LOG = "socket: '/run/mysqld/mysqld.sock' port: " + MARIADB_PORT;

@Container(image = "${mariadb.10.image}", port = MARIADB_PORT, expectedLog = "ready for connections")
@Container(image = "${mariadb.10.image}", port = MARIADB_PORT, expectedLog = MARIADB_START_LOG)
static MariaDbService mariadb = new MariaDbService();

@Container(image = "${postgresql.13.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
Expand Down

0 comments on commit e8ac02b

Please sign in to comment.