exasol / test-db-builder-java

Java library for creating and cleaning up test database structures and contents for integration tests
MIT License
1 stars 1 forks source link

set DEBUG_ADDRESS and LOG_LEVEL based on properties or environment variables #103

Closed ckunki closed 2 years ago

ckunki commented 2 years ago

CREATE VIRTUAL SCHEMA allows to set DEBUG_ADDRESS and LOG_LEVEL in order to debug virtual schemas regarding pushdown statements etc., see logging in documentation.

Currently developers add properties in the source code of the virtual schema they are currently working on, e.g. MySQLVirtualSchemaIntegrationTestSetup.createVirtualSchema():

properties = new HashMap<>(Map.of("DEBUG_ADDRESS", "1.2.3.4:3000", "LOG_LEVEL", "ALL"));

This creates the risk to forget to revert the code changes before merging to git main branch.

The current ticket therefore proposes to support properties or environment variables in order to set DEBUG_ADDRESS and LOG_LEVEL. These properties or environment variables are then outside the code, effect only the local machine of the developer and will not be merged.

Adding this functionality to test-db-builder-java creates immediate benefit for all virtual schemas.

ckunki commented 2 years ago

Sample implementation

private Map<String, String> debugProperties() {
    final String debugAddress = System.getProperty("com.exasol.virtualschema.debug.address");
    if (debugAddress == null) {
        return Collections.emptyMap();
    }
    final String logLevel = System.getProperty("com.exasol.virtualschema.debug.level");
    return Map.of("DEBUG_ADDRESS", debugAddress, "LOG_LEVEL", (logLevel != null ? logLevel : "ALL"));
}
ckunki commented 2 years ago

Class IntegrationTestSetup in https://github.com/exasol/s3-document-files-virtual-schema uses System.getProperty("test.vs-logs") but expects only a boolean value and uses localhost

kaklakariada commented 1 year ago

Use uniform property names:

    private Map<String, String> debugProperties() {
        final String debugHost = System.getProperty("com.exasol.log.host", null);
        if (debugHost == null) {
            return Collections.emptyMap();
        }
        final String debugPort = System.getProperty("com.exasol.log.port", "3000");
        final String logLevel = System.getProperty("com.exasol.log.level", "ALL");
        final String address = debugHost + ":" + debugPort;
        return Map.of("DEBUG_ADDRESS", address, "LOG_LEVEL", logLevel);
    }

See also https://github.com/exasol/google-cloud-storage-document-files-virtual-schema/pull/25