-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): run management-api e2e tests with postgresql
- Loading branch information
Showing
24 changed files
with
1,800 additions
and
1,502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...re/src/testFixtures/java/org/eclipse/edc/sql/testfixtures/PostgresqlEndToEndInstance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.sql.testfixtures; | ||
|
||
import org.eclipse.edc.junit.testfixtures.TestUtils; | ||
import org.eclipse.edc.spi.persistence.EdcPersistenceException; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.sql.SQLException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
public interface PostgresqlEndToEndInstance { | ||
|
||
String USER = "postgres"; | ||
String PASSWORD = "password"; | ||
String JDBC_URL_PREFIX = "jdbc:postgresql://localhost:5432/"; | ||
|
||
static void createDatabase(String participantName) { | ||
try { | ||
Class.forName("org.postgresql.Driver"); | ||
} catch (ClassNotFoundException e) { | ||
throw new EdcPersistenceException(e); | ||
} | ||
|
||
var postgres = new PostgresqlLocalInstance(USER, PASSWORD, JDBC_URL_PREFIX, participantName); | ||
postgres.createDatabase(); | ||
|
||
var extensionsFolder = TestUtils.findBuildRoot().toPath().resolve("extensions"); | ||
var scripts = Stream.of( | ||
"control-plane/store/sql/asset-index-sql", | ||
"control-plane/store/sql/contract-definition-store-sql", | ||
"control-plane/store/sql/contract-negotiation-store-sql", | ||
"control-plane/store/sql/policy-definition-store-sql", | ||
"control-plane/store/sql/transfer-process-store-sql", | ||
"data-plane/store/sql/data-plane-store-sql", | ||
"policy-monitor/store/sql/policy-monitor-store-sql" | ||
) | ||
.map(extensionsFolder::resolve) | ||
.map(it -> it.resolve("docs")) | ||
.map(it -> it.resolve("schema.sql")) | ||
.toList(); | ||
|
||
try (var connection = postgres.getConnection(participantName)) { | ||
for (var script : scripts) { | ||
var sql = Files.readString(script); | ||
|
||
try (var statement = connection.createStatement()) { | ||
statement.execute(sql); | ||
} catch (Exception exception) { | ||
throw new EdcPersistenceException(exception.getMessage(), exception); | ||
} | ||
} | ||
} catch (SQLException | IOException e) { | ||
throw new EdcPersistenceException(e); | ||
} | ||
} | ||
|
||
static Map<String, String> defaultDatasourceConfiguration(String name) { | ||
return new HashMap<>() { | ||
{ | ||
put("edc.datasource.default.url", JDBC_URL_PREFIX + name); | ||
put("edc.datasource.default.user", USER); | ||
put("edc.datasource.default.password", PASSWORD); | ||
} | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
...ts/e2e-transfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/PostgresConstants.java
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
...m-tests/e2e-transfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/PostgresUtil.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.