Skip to content

Commit

Permalink
Merge branch 'release/35.x'
Browse files Browse the repository at this point in the history
* release/35.x:
  No issue: Test against additional DB versions
  • Loading branch information
reckart committed Feb 3, 2025
2 parents 2dd25b0 + ed37e5e commit cee4803
Show file tree
Hide file tree
Showing 9 changed files with 365 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@
import static de.tudarmstadt.ukp.inception.support.deployment.DeploymentModeService.PROFILE_PRODUCTION_MODE;
import static java.util.Arrays.asList;

import java.lang.invoke.MethodHandles;
import java.util.zip.ZipFile;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down Expand Up @@ -62,10 +67,14 @@
PROFILE_INTERNAL_SERVER, //
PROFILE_PRODUCTION_MODE })
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = { INCEpTION.class })
@SpringBootTest( //
classes = { INCEpTION.class }, //
properties = { "spring.main.banner-mode=off" })
@ContextConfiguration(initializers = { InceptionApplicationContextInitializer.class })
public abstract class InceptionIntegrationTest_ImplBase
{
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

@Autowired
ProjectService projectService;

Expand All @@ -87,14 +96,22 @@ public abstract class InceptionIntegrationTest_ImplBase
@Autowired
LearningRecordService learningRecordService;

@BeforeAll
static void setupClass(TestInfo aInfo)
{
LOG.info("============================================================");
LOG.info("= Running {}", aInfo.getTestClass().get().getSimpleName());
LOG.info("============================================================");
}

@BeforeEach
void setupClass()
void setup()
{
MDC.put(Logging.KEY_REPOSITORY_PATH, repositoryProperties.getPath().toString());
}

@AfterEach
void tearDownClass()
void tearDown()
{
MDC.clear();
}
Expand Down Expand Up @@ -149,16 +166,19 @@ void testDeletingSourceDocumentWithLearningRecordAttached() throws Exception
var project = Project.builder() //
.withName("test") //
.build();

var layer = AnnotationLayer.builder() //
.withProject(project) //
.withName("Layer") //
.withUiName("Layer") //
.withType(SpanLayerSupport.TYPE) //
.build();

var doc = SourceDocument.builder() //
.withProject(project) //
.withName("Blah") //
.build();

var learningRecord = LearningRecord.builder() //
.withLayer(layer) //
.withSourceDocument(doc) //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.testcontainers.utility.DockerImageName;

@Testcontainers(disabledWithoutDocker = true)
class InceptionMSSQLServerIntegrationTest
class InceptionMSSQLServer_2022_IntegrationTest
{
static final DockerImageName image = DockerImageName.parse("mcr.microsoft.com/mssql/server")
.withTag("2022-latest");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Licensed to the Technische Universität Darmstadt under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The Technische Universität Darmstadt
* licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.tudarmstadt.ukp.inception.db;

import java.nio.file.Path;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.MariaDBContainer;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers(disabledWithoutDocker = true)
class InceptionMariadb_10_11_IntegrationTest
{
@SuppressWarnings("resource")
static final MariaDBContainer<?> dbContainer = new MariaDBContainer<>("mariadb:10.11.10") //
.withDatabaseName("testdb") //
.withUsername("test") //
.withPassword("test");

static @TempDir Path tempDir;

static ConfigurableApplicationContext appContext;

@BeforeAll
static void setupClass()
{
dbContainer.start();
}

@AfterAll
static void tearDownClass()
{
if (appContext != null) {
appContext.close();
}

if (dbContainer != null && dbContainer.isRunning()) {
dbContainer.stop();
}
}

@Nested
class SpringApplcationContext
extends InceptionIntegrationTest_ImplBase
{
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry)
{
registry.add("database.url", dbContainer::getJdbcUrl);
registry.add("database.username", dbContainer::getUsername);
registry.add("database.password", dbContainer::getPassword);
registry.add("inception.home", () -> tempDir.toString());
}

@BeforeEach
void setup(ConfigurableApplicationContext aAppContext)
{
appContext = aAppContext;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers(disabledWithoutDocker = true)
class InceptionMariadbIntegrationTest
class InceptionMariadb_11_4_IntegrationTest
{
@SuppressWarnings("resource")
static final MariaDBContainer<?> dbContainer = new MariaDBContainer<>("mariadb:11.4.2") //
static final MariaDBContainer<?> dbContainer = new MariaDBContainer<>("mariadb:11.4.4") //
.withDatabaseName("testdb") //
.withUsername("test") //
.withPassword("test");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Licensed to the Technische Universität Darmstadt under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The Technische Universität Darmstadt
* licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.tudarmstadt.ukp.inception.db;

import java.nio.file.Path;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.MariaDBContainer;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers(disabledWithoutDocker = true)
class InceptionMariadb_11_6_IntegrationTest
{
@SuppressWarnings("resource")
static final MariaDBContainer<?> dbContainer = new MariaDBContainer<>("mariadb:11.6.2") //
.withDatabaseName("testdb") //
.withUsername("test") //
.withPassword("test");

static @TempDir Path tempDir;

static ConfigurableApplicationContext appContext;

@BeforeAll
static void setupClass()
{
dbContainer.start();
}

@AfterAll
static void tearDownClass()
{
if (appContext != null) {
appContext.close();
}

if (dbContainer != null && dbContainer.isRunning()) {
dbContainer.stop();
}
}

@Nested
class SpringApplcationContext
extends InceptionIntegrationTest_ImplBase
{
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry)
{
registry.add("database.url", dbContainer::getJdbcUrl);
registry.add("database.username", dbContainer::getUsername);
registry.add("database.password", dbContainer::getPassword);
registry.add("inception.home", () -> tempDir.toString());
}

@BeforeEach
void setup(ConfigurableApplicationContext aAppContext)
{
appContext = aAppContext;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Licensed to the Technische Universität Darmstadt under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The Technische Universität Darmstadt
* licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.tudarmstadt.ukp.inception.db;

import java.nio.file.Path;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.MySQLContainer;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers(disabledWithoutDocker = true)
class InceptionMySql_8_0_IntegrationTest
{
@SuppressWarnings("resource")
static final MySQLContainer<?> dbContainer = new MySQLContainer<>("mysql:8.0") //
.withDatabaseName("testdb") //
.withUsername("test") //
.withPassword("test");

static @TempDir Path tempDir;

static ConfigurableApplicationContext appContext;

@BeforeAll
static void setupClass()
{
dbContainer.start();
}

@AfterAll
static void tearDownClass()
{
if (appContext != null) {
appContext.close();
}

if (dbContainer != null && dbContainer.isRunning()) {
dbContainer.stop();
}
}

@Nested
class SpringApplcationContext
extends InceptionIntegrationTest_ImplBase
{
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry)
{
registry.add("database.url", dbContainer::getJdbcUrl);
registry.add("database.username", dbContainer::getUsername);
registry.add("database.password", dbContainer::getPassword);
registry.add("inception.home", () -> tempDir.toString());
}

@BeforeEach
void setup(ConfigurableApplicationContext aAppContext)
{
appContext = aAppContext;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers(disabledWithoutDocker = true)
class InceptionPostgresqlIntegrationTest
class InceptionPostgresql_16_3_IntegrationTest
{
// static DockerImageName image = DockerImageName.parse("pgvector/pgvector:pg16")
// .asCompatibleSubstituteFor("postgres");
@SuppressWarnings("resource")
static final PostgreSQLContainer<?> dbContainer = new PostgreSQLContainer<>(
"postgres:16.3-alpine") //
"postgres:16.6-alpine") //
.withDatabaseName("testdb") //
.withUsername("test") //
.withPassword("test");
Expand Down
Loading

0 comments on commit cee4803

Please sign in to comment.