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

Fix resource loading for EMR, adjust app-server tests. #129

Merged
merged 5 commits into from
Dec 13, 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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ val jayway_restassured = "com.jayway.restassured:rest-assured:2.9.0"
val assertj_core = "org.assertj:assertj-core:3.24.2"
val awaitility = "org.awaitility:awaitility:4.2.0"
val junit_jupiter = "org.junit.jupiter:junit-jupiter:5.9.2"
val mockito = "org.mockito:mockito-core:3.12.4"
val mockito = "org.mockito:mockito-core:5.8.0"

val flipkart_zjsonpatch = "com.flipkart.zjsonpatch:zjsonpatch:0.4.13"
val json_assert = "org.skyscreamer:jsonassert:1.5.1"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ mavenPassword=YourPassword
# When updating the version, please as well consider:
# - here-naksha-lib-core/INaksha (static property: latest)
# - here-naksha-lib-psql/resources/naksha_plpgsql.sql (method: naksha_version)
version=2.0.9
version=2.0.10
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@
package com.here.naksha.app.common;

import static com.here.naksha.app.service.NakshaApp.newInstance;
import static com.here.naksha.lib.psql.PsqlStorageConfig.configFromFileOrEnv;

import com.here.naksha.app.service.NakshaApp;
import com.here.naksha.lib.hub.NakshaHubConfig;
import com.here.naksha.lib.psql.PsqlStorage;
import com.here.naksha.lib.psql.PsqlStorageConfig;
import java.util.concurrent.atomic.AtomicReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class TestNakshaAppInitializer {

public static final @NotNull PsqlStorageConfig adminDbConfig =
configFromFileOrEnv("test_admin_db.url", "NAKSHA_TEST_ADMIN_DB_URL", "naksha_admin_schema");

public static final @NotNull PsqlStorageConfig dataDbConfig =
configFromFileOrEnv("test_data_db.url", "NAKSHA_TEST_DATA_DB_URL", "naksha_data_schema");

private static final String MOCK_CONFIG_ID = "mock-config";

private static final String TEST_CONFIG_ID = "test-config";

private static final String TEST_SCHEMA = "naksha_test_schema";

public final @Nullable String testDbUrl;
public final @NotNull AtomicReference<NakshaApp> nakshaApp;

Expand Down Expand Up @@ -62,22 +66,6 @@ public static TestNakshaAppInitializer mockedNakshaApp() {
}

public static TestNakshaAppInitializer localPsqlBasedNakshaApp() {
String dbUrl = dbUrl();
return new TestNakshaAppInitializer(dbUrl);
}

private static String dbUrl() {
String dbUrl = System.getenv("TEST_NAKSHA_PSQL_URL");
if (dbUrl != null && !dbUrl.isBlank()) {
return dbUrl;
}
String password = System.getenv("TEST_NAKSHA_PSQL_PASS");
if (password == null || password.isBlank()) {
password = "password";
}
return "jdbc:postgresql://localhost/postgres?user=postgres&password=" + password
+ "&schema=" + TEST_SCHEMA
+ "&app=" + NakshaHubConfig.defaultAppName()
+ "&id=" + PsqlStorage.ADMIN_STORAGE_ID;
return new TestNakshaAppInitializer(dataDbConfig.url());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.here.naksha.lib.core.util.json.Json;
import com.here.naksha.lib.core.view.ViewDeserialize;
import com.here.naksha.lib.hub.NakshaHubConfig;
import com.here.naksha.lib.psql.PsqlStorageConfig;
import java.io.IOException;
import java.net.URLEncoder;
import java.net.http.HttpResponse;
Expand All @@ -42,7 +43,24 @@ private TestUtil() {}

public static String loadFileOrFail(final @NotNull String rootPath, final @NotNull String fileName) {
try {
return new String(Files.readAllBytes(Paths.get(rootPath + fileName)));
String json = new String(Files.readAllBytes(Paths.get(rootPath + fileName)));
final PsqlStorageConfig dataDbConfig = TestNakshaAppInitializer.dataDbConfig;
json = json.replace("${dataDb.host}", dataDbConfig.host());
json = json.replace("${dataDb.port}", Integer.toString(dataDbConfig.port()));
json = json.replace("${dataDb.db}", dataDbConfig.db());
json = json.replace("${dataDb.storageId}", dataDbConfig.storageId());
json = json.replace("${dataDb.schema}", dataDbConfig.schema());
json = json.replace("${dataDb.user}", dataDbConfig.user());
json = json.replace("${dataDb.password}", dataDbConfig.password());
final PsqlStorageConfig adminDbConfig = TestNakshaAppInitializer.adminDbConfig;
json = json.replace("${adminDb.host}", adminDbConfig.host());
json = json.replace("${adminDb.port}", Integer.toString(adminDbConfig.port()));
json = json.replace("${adminDb.db}", adminDbConfig.db());
json = json.replace("${adminDb.storageId}", adminDbConfig.storageId());
json = json.replace("${adminDb.schema}", adminDbConfig.schema());
json = json.replace("${adminDb.user}", adminDbConfig.user());
json = json.replace("${adminDb.password}", adminDbConfig.password());
return json;
} catch (IOException e) {
Assertions.fail("Unable tor read test file " + fileName, e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"className": "com.here.naksha.lib.psql.PsqlStorage",
"properties": {
"master": {
"host": "127.0.0.1",
"db": "postgres",
"user": "postgres",
"password": "password",
"host": "${dataDb.host}",
"db": "${dataDb.db}",
"user": "${dataDb.user}",
"password": "${dataDb.password}",
"readOnly": false
},
"appName": "test-app-name",
"schema": "naksha_test_schema"
"schema": "${dataDb.schema}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"className": "com.here.naksha.lib.psql.PsqlStorage",
"properties": {
"master": {
"host": "127.0.0.1",
"db": "postgres",
"user": "postgres",
"password": "password",
"host": "${dataDb.host}",
"db": "${dataDb.db}",
"user": "${dataDb.user}",
"password": "${dataDb.password}",
"readOnly": false
},
"appName": "test-app-name",
"schema": "naksha_test_schema"
"schema": "${dataDb.schema}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"className": "com.here.naksha.lib.psql.PsqlStorage",
"properties": {
"dbConfig": {
"host": "localhost",
"host": "${dataDb.host}",
"db": "${dataDb.db}",
"user": "${dataDb.user}",
"password": "${dataDb.password}",
"port": 5432,
"db": "postgres",
"user": "postgres",
"password": "password",
"schema": "naksha_moderation_dev",
"schema": "${dataDb.schema}",
"minPoolSize": 5,
"maxPoolSize": 50
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"className": "com.here.naksha.lib.psql.PsqlStorage",
"properties": {
"dbConfig": {
"host": "localhost",
"host": "${dataDb.host}",
"db": "${dataDb.db}",
"user": "${dataDb.user}",
"password": "${dataDb.password}",
"port": 5432,
"db": "postgres",
"user": "postgres",
"password": "password",
"schema": "naksha_moderation_dev",
"schema": "${dataDb.schema}",
"minPoolSize": 5,
"maxPoolSize": 50
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"className": "com.here.naksha.lib.psql.PsqlStorage",
"properties": {
"master": {
"host": "127.0.0.1",
"db": "postgres",
"user": "postgres",
"password": "password",
"host": "${dataDb.host}",
"db": "${dataDb.db}",
"user": "${dataDb.user}",
"password": "${dataDb.password}",
"readOnly": false
},
"appName": "test-app-name",
"schema": "naksha_test_schema"
"schema": "${dataDb.schema}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"className": "com.here.naksha.lib.psql.PsqlStorage",
"properties": {
"master": {
"host": "127.0.0.1",
"db": "postgres",
"user": "postgres",
"password": "password",
"host": "${dataDb.host}",
"db": "${dataDb.db}",
"user": "${dataDb.user}",
"password": "${dataDb.password}",
"readOnly": false
},
"appName": "test-app-name",
"schema": "naksha_test_schema"
"schema": "${dataDb.schema}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ public class NakshaVersion implements Comparable<NakshaVersion> {
public static final String v2_0_7 = "2.0.7";
public static final String v2_0_8 = "2.0.8";
public static final String v2_0_9 = "2.0.9";
public static final String v2_0_10 = "2.0.10";

/**
* The latest version of the naksha-extension stored in the resources.
*/
@AvailableSince(v2_0_5)
public static final NakshaVersion latest = of(v2_0_9);
public static final NakshaVersion latest = of(v2_0_10);

private final int major;
private final int minor;
Expand Down
Loading