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

Mcpods 6535 validate rest against psql #112

Merged

Conversation

Amaneusz
Copy link
Collaborator

No description provided.

Copy link

Code Coverage

Overall Project 31.59% -0.07% 🍏
Files changed 29.03% 🍏

Module Coverage
here-naksha-app-service 51.73% -0.09% 🍏
here-naksha-lib-hub 35.19% -1.28% 🍏
Files
Module File Coverage
here-naksha-app-service NakshaApp.java 67.24% -1.04% 🍏
here-naksha-lib-hub NHSpaceStorage.java 76.51% -4.03% 🍏
NakshaHubConfig.java 57.78% 🍏
NHSpaceStorageReader.java 54.57% 🍏
NakshaHub.java 0.82% -5.57% 🍏
ConfigUtil.java 0% 🍏
NHAdminStorage.java 0% -10.64% 🍏

@Amaneusz Amaneusz force-pushed the MCPODS-6535-validate_rest_against_psql branch from eb5560b to 3782cd1 Compare November 30, 2023 20:00
Copy link

Code Coverage

Overall Project 31.57% -0.07% 🍏
Files changed 13.73% 🍏

Module Coverage
here-naksha-app-service 51.73% -0.09% 🍏
here-naksha-lib-hub 34.95% -1.29% 🍏
Files
Module File Coverage
here-naksha-app-service NakshaApp.java 67.24% -1.04% 🍏
here-naksha-lib-hub NHSpaceStorage.java 76.51% -4.03% 🍏
NakshaHubConfig.java 57.78% 🍏
NakshaHub.java 0.82% -5.57% 🍏
ConfigUtil.java 0% 🍏
NHAdminStorage.java 0% -10.64% 🍏

@Amaneusz Amaneusz marked this pull request as ready for review November 30, 2023 20:02
Copy link
Member

@hirenkp2000 hirenkp2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to review the changes again, once review comments are addressed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just the indention changes, in this file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, some autoformat got applied accidentally - I am reverting this to make review less confusing

@@ -87,7 +92,8 @@ public NakshaHub(
final @Nullable NakshaHubConfig customCfg,
final @Nullable String configId) {
// create storage instance upfront
this.psqlStorage = new PsqlStorage("naksha-admin-db", appName, "TODO", config);
this.psqlStorage =
new PsqlStorage("naksha-admin-db", appName, "local_test_" + System.currentTimeMillis(), config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this was a comment on last PR as well)
We need to support custom schema name supplied to the application as part of DB URL. Current logic of using random schema, won't work in cloud. We preferably fix it as part of this PR itself, OR pick it up immediately after this PR. But, let's not delay it for long, as from this point onwards, we will always be using PostgreSQL.

Once this resolved, we need to remove hubClassName property from cloud-config file (deployment/codedeploy/contents/naksha-hub/.config/cloud-config.json), so that Naksha service in cloud can also start working against actual postgres implementation, using consistent schema.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot about "local_test_" + System.currentTimeMillis() - I'll get on it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I would have also preferred config files into specific sub-directories, it is not straight-forward to work at the moment. For example, try bringing your app on local from CLI and it will break:
java -jar build/libs/naksha-2.0.8-all.jar test-config

If you provide config directory, like this java -jar build/libs/naksha-2.0.8-all.jar config/test-config then it will work, but then it is not an ideal Config ID (due to presence of folder name) and also it will not seamlessly work for custom NAKSHA_CONFIG_PATH environment path and user home directory, due to additional folder name that it requires now.

It is surely possible to fix, but will require more refactoring to support loading config from all the possible places which we support right now and still respecting additional config folder. Right now, couple of options already has stopped working (specifically with custom env path and default user home directory).

Hence, my suggestion is, let's park this for now (if you agree?) and continue with the config files at root resources level itself. We anyways will remove some of these configs very soon, once postgres is fully stable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's park this for now (if you agree?) and continue with the config files at root resources level itself

I'm fine with that if we agree to address it in the future. I will revert this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, absolutely. Let's create a ticket, which will go into next quarter and at that point depending on how many config files we are left with, we can readdress it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will also require few test cases to validate transactional atomicity of REST APIs. But this can be addressed separately. I have raised ticket for the same - https://devzone.it.here.com/jira/browse/MCPODS-6665

Copy link

github-actions bot commented Dec 1, 2023

Code Coverage

Overall Project 31.55% -0.12% 🍏
Files changed 47.45% 🍏

Module Coverage
here-naksha-app-service 51.67% -0.09% 🍏
here-naksha-lib-hub 34.97% -1.22% 🍏
here-naksha-lib-psql 21.26% -0.33% 🍏
Files
Module File Coverage
here-naksha-app-service AbstractApiTask.java 75.25% 🍏
NakshaApp.java 66.78% -1.05% 🍏
here-naksha-lib-hub NHSpaceStorage.java 76.51% -4.03% 🍏
NakshaHubFactory.java 75.61% 🍏
NakshaHubConfig.java 57.78% 🍏
NakshaHubMock.java 26.36% 🍏
NakshaHub.java 0.83% -5.18% 🍏
ConfigUtil.java 0% 🍏
NHAdminStorage.java 0% -10.64% 🍏
here-naksha-lib-psql PsqlStorage.java 0% -4.5% 🍏

Copy link
Member

@hirenkp2000 hirenkp2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use constant for naksha-admin-db. It is already defined in PsqlStorage.ADMIN_STORAGE_ID. Also, local execution is failing as it seems id and app are required as part of DB URL, so we need to specifically change NakshaApp.DEFAULT_URL to add default values for app and id.

Also all tests need to start using actual postgres based custom storage (instead of current mock storage). for example - unit_test_data/ReadFeatures/ByIds/TC0400_ExistingAndMissingIds/create_storage.json

@Amaneusz Amaneusz force-pushed the MCPODS-6535-validate_rest_against_psql branch from 43fe86a to ac07097 Compare December 8, 2023 11:15
@Amaneusz Amaneusz force-pushed the MCPODS-6535-validate_rest_against_psql branch from ac07097 to 7ed7f2f Compare December 8, 2023 14:31
@Amaneusz Amaneusz force-pushed the MCPODS-6535-validate_rest_against_psql branch 2 times, most recently from dcd0280 to 776d71e Compare December 8, 2023 14:56
@Amaneusz Amaneusz force-pushed the MCPODS-6535-validate_rest_against_psql branch from 776d71e to 4b95b47 Compare December 8, 2023 15:00
private static final String DEFAULT_URL =
"jdbc:postgresql://localhost:5432/postgres?user=postgres&password=pswd&schema=naksha";
"jdbc:postgresql://localhost:5432/postgres?user=postgres&password=pswd&schema=" + DEFAULT_SCHEMA;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also include app and id in default URL, else java -jar with default URL won't work on local.

@@ -175,19 +179,24 @@ static class StorageConstructorByClassNameMap extends ConcurrentHashMap<String,
*/
static <CONFIG> @Nullable Fe1<IStorage, CONFIG> wrapStorageConstructor(
@NotNull Constructor<? extends IStorage> constructor, @NotNull Class<CONFIG> configClass) {
log.info("Wrapping constructor: {}", constructor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we convert logs in the method as DEBUG, as tests are stable now? (in cloud we will use INFO logging)

throw unchecked(new Exception(
"Unable to read custom/default config from Admin DB - ResultCursor has no data"));
logger.info("Not found any db configuration in '" + NakshaAdminCollection.CONFIGS
+ "' admin collection");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this step, app must have one config to continue with startup. And if config is not available then App should fail. So, I think we should continue with exception, unless I am missing reason for ignoring it now.

@@ -91,7 +91,10 @@ private static long value(@Nullable Long value, long minValue, long defaultValue
this.logLevel = logLevel == null ? EPsqlLogLevel.OFF : logLevel;
this.masterConfig = masterConfig;
if (masterConfig != null) {
log.info("creating PostgresStorage with masterConfig, storageId: {}, config: {}", storageId, masterConfig);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid logging config object (as it can leak password)

Copy link

github-actions bot commented Dec 8, 2023

Code Coverage

Overall Project 32.52% -0.47% 🍏
Files changed 52.99% 🍏

Module Coverage
here-naksha-app-service 52.67% -0.27% 🍏
here-naksha-lib-core 31.66% -0.26% 🍏
here-naksha-lib-hub 26.29% -4.14% 🍏
here-naksha-lib-psql 21.78% -0.48% 🍏
Files
Module File Coverage
here-naksha-app-service UrlUtil.java 100% 🍏
EventHandlerApiTask.java 94.09% 🍏
StorageApiTask.java 94.09% 🍏
SpaceApiTask.java 94.09% 🍏
WriteFeatureApiTask.java 77.85% 🍏
AbstractApiTask.java 75.25% 🍏
ReadFeatureApiTask.java 73.45% 🍏
NakshaApp.java 65.29% -3.26% 🍏
here-naksha-lib-core Position.java 36.32% 🍏
PluginCache.java 18.62% -10.27% 🍏
StorageException.java 0% 🍏
StorageLockTimeout.java 0% 🍏
StorageNotInitialized.java 0% 🍏
SpaceProperties.java 0% -84.62% 🍏
EventHandlerProperties.java 0% -47.83% 🍏
here-naksha-lib-hub NHSpaceStorage.java 74.51% -7.84% 🍏
NHAdminWriterMock.java 32.2% -1.07% 🍏
NHAdminReaderMock.java 3.25% -2.44% 🍏
NakshaHubConfig.java 1.78% -1.33% 🍏
NakshaHub.java 0.82% -4.53% 🍏
NakshaHubFactory.java 0% -52.44% 🍏
ConfigUtil.java 0% 🍏
NHAdminStorage.java 0% -38.46% 🍏
NakshaHubMock.java 0% -5.68% 🍏
here-naksha-lib-psql PsqlCursor.java 88.82% -2.63% 🍏
PsqlStorage.java 0% -4.5% 🍏
EPsqlState.java 0% -3.17% 🍏

Copy link

github-actions bot commented Dec 8, 2023

Code Coverage

Overall Project 32.55% -0.59% 🍏
Files changed 47.95% 🍏

Module Coverage
here-naksha-app-service 52.67% -0.28% 🍏
here-naksha-lib-core 31.66% -0.26% 🍏
here-naksha-lib-hub 26.73% -6.59% 🍏
here-naksha-lib-psql 21.78% -0.48% 🍏
Files
Module File Coverage
here-naksha-app-service UrlUtil.java 100% 🍏
EventHandlerApiTask.java 94.09% 🍏
StorageApiTask.java 94.09% 🍏
SpaceApiTask.java 94.09% 🍏
WriteFeatureApiTask.java 77.85% 🍏
AbstractApiTask.java 75.25% 🍏
ReadFeatureApiTask.java 73.45% 🍏
NakshaApp.java 65.25% -3.41% 🍏
here-naksha-lib-core Position.java 36.32% 🍏
PluginCache.java 18.62% -10.27% 🍏
StorageException.java 0% 🍏
StorageLockTimeout.java 0% 🍏
StorageNotInitialized.java 0% 🍏
SpaceProperties.java 0% -84.62% 🍏
EventHandlerProperties.java 0% -47.83% 🍏
here-naksha-lib-hub NHSpaceStorage.java 74.51% -7.84% 🍏
NHAdminWriterMock.java 32.2% -1.07% 🍏
NHAdminReaderMock.java 3.25% -2.44% 🍏
NakshaHubConfig.java 1.78% -1.33% 🍏
NakshaHub.java 0.92% -20.82% 🍏
NakshaHubFactory.java 0% -52.44% 🍏
ConfigUtil.java 0% 🍏
NHAdminStorage.java 0% -38.46% 🍏
NakshaHubMock.java 0% -5.68% 🍏
here-naksha-lib-psql PsqlCursor.java 88.82% -2.63% 🍏
PsqlStorage.java 0% -4.5% 🍏
EPsqlState.java 0% -3.17% 🍏

Copy link

github-actions bot commented Dec 8, 2023

Code Coverage

Overall Project 32.54% -0.59% 🍏
Files changed 47.95% 🍏

Module Coverage
here-naksha-app-service 52.67% -0.28% 🍏
here-naksha-lib-core 31.66% -0.26% 🍏
here-naksha-lib-hub 26.71% -6.58% 🍏
here-naksha-lib-psql 21.78% -0.48% 🍏
Files
Module File Coverage
here-naksha-app-service UrlUtil.java 100% 🍏
EventHandlerApiTask.java 94.09% 🍏
StorageApiTask.java 94.09% 🍏
SpaceApiTask.java 94.09% 🍏
WriteFeatureApiTask.java 77.85% 🍏
AbstractApiTask.java 75.25% 🍏
ReadFeatureApiTask.java 73.45% 🍏
NakshaApp.java 65.25% -3.41% 🍏
here-naksha-lib-core Position.java 36.32% 🍏
PluginCache.java 18.62% -10.27% 🍏
StorageException.java 0% 🍏
StorageLockTimeout.java 0% 🍏
StorageNotInitialized.java 0% 🍏
SpaceProperties.java 0% -84.62% 🍏
EventHandlerProperties.java 0% -47.83% 🍏
here-naksha-lib-hub NHSpaceStorage.java 74.51% -7.84% 🍏
NHAdminWriterMock.java 32.2% -1.07% 🍏
NHAdminReaderMock.java 3.25% -2.44% 🍏
NakshaHubConfig.java 1.78% -1.33% 🍏
NakshaHub.java 0.91% -20.68% 🍏
NakshaHubFactory.java 0% -52.44% 🍏
ConfigUtil.java 0% 🍏
NHAdminStorage.java 0% -38.46% 🍏
NakshaHubMock.java 0% -5.68% 🍏
here-naksha-lib-psql PsqlCursor.java 88.82% -2.63% 🍏
PsqlStorage.java 0% -4.5% 🍏
EPsqlState.java 0% -3.17% 🍏

@hirenkp2000 hirenkp2000 merged commit a396744 into Naksha_maintenance Dec 8, 2023
2 checks passed
@hirenkp2000 hirenkp2000 deleted the MCPODS-6535-validate_rest_against_psql branch December 12, 2023 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants