World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#216][#217] test: add e2e integration test framework & metalake integration test (#235)
Xun Liub1d57903c6a8
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.ymlindex f72e0789cb..9d181ec59e 100644--- a/.github/workflows/integration.yml+++ b/.github/workflows/integration.yml@@ -40,4 +40,8 @@ jobs:- name: Package Gravitonrun: |gradle build- gradle compileDistribution\ No newline at end of file+ gradle compileDistribution++ - name: Graviton Integration Tests+ run: |+ gradle integrationTest\ No newline at end of filediff --git a/LICENSE b/LICENSEindex ab02b85926..f837ef50d1 100644--- a/LICENSE+++ b/LICENSE@@ -231,3 +231,6 @@Apache Hive./catalog-hive/src/test/resources/hive-schema-3.1.0.derby.sql+ Apache Zeppelin+ ./integration-test/src/test/java/com/datastrato/graviton/integration/util/CommandExecutor.java+ ./integration-test/src/test/java/com/datastrato/graviton/integration/util/ProcessData.javadiff --git a/NOTICE b/NOTICEindex 958cbd098f..91411f95e5 100644--- a/NOTICE+++ b/NOTICE@@ -16,5 +16,8 @@ Copyright 2014 and onwards The Apache Software Foundation.Apache HiveCopyright 2008-2023 The Apache Software Foundation+Apache Zeppelin+Copyright 2016-2023 The Apache Software Foundation+This product includes software developed atThe Apache Software Foundation (http://www.apache.org/).diff --git a/build.gradle.kts b/build.gradle.ktsindex 12a3f2ef8e..a5f1c1c813 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -40,8 +40,11 @@ subprojects {}tasks.configureEach<Test> {- useJUnitPlatform()- finalizedBy(tasks.getByName("jacocoTestReport"))+ // Integration test module are tested sepatately+ if (project.name != "integration-test") {+ useJUnitPlatform()+ finalizedBy(tasks.getByName("jacocoTestReport"))+ }}tasks.withType<JacocoReport> {@@ -59,8 +62,10 @@ subprojects {tasks.withType<Jar> {archiveFileName.set("${rootProject.name.lowercase(Locale.getDefault())}-${project.name}-$version.jar")- exclude("log4j2.properties")- exclude("test/**")+ if (project.name != "integration-test") {+ exclude("log4j2.properties")+ exclude("test/**")+ }}plugins.withType<SpotlessPlugin>().configureEach {@@ -230,25 +235,10 @@ tasks {}}- // Print all dependencies of all subprojects, `./gradlew allDeps`- task("allDeps") {- doLast {- subprojects.forEach { project ->- println("Dependencies for project: ${project.name}")- project.configurations.forEach { configuration ->- configuration.allDependencies.forEach { dependency ->- println("- ${dependency.group}:${dependency.name}:${dependency.version}")- }- }- println()- }- }+ task("integrationTest") {+ dependsOn(":integration-test:integrationTest")}-// assemble {-// finalizedBy(assembleDistribution)-// }-clean {dependsOn(cleanDistribution)}diff --git a/integration-test/build.gradle.kts b/integration-test/build.gradle.ktsnew file mode 100644index 0000000000..f6131a24c4--- /dev/null+++ b/integration-test/build.gradle.kts@@ -0,0 +1,36 @@+/*+ * Copyright 2023 Datastrato.+ * This software is licensed under the Apache License version 2.+ */++plugins {+ `maven-publish`+ id("java")+ id("idea")+ id("com.diffplug.spotless")+}++dependencies {+ implementation(project(":api"))+ implementation(project(":common"))+ implementation(project(":core"))+ implementation(project(":client-java"))+ implementation(project(":server"))++ testCompileOnly(libs.commons.io)+ testCompileOnly(libs.lombok)+ testAnnotationProcessor(libs.lombok)+ testImplementation(libs.guava)+ testImplementation(libs.commons.lang3)+ testImplementation(libs.junit.jupiter.api)+ testImplementation(libs.junit.jupiter.params)+ testImplementation(libs.httpclient5)+ testRuntimeOnly(libs.junit.jupiter.engine)+}++tasks {+ val integrationTest by creating(Test::class) {+ environment("GRAVITON_HOME", rootDir.path + "/distribution/package")+ useJUnitPlatform()+ }+}\ No newline at end of filediff --git a/integration-test/src/test/java/com/datastrato/graviton/integration/e2e/MetalakeIT.java b/integration-test/src/test/java/com/datastrato/graviton/integration/e2e/MetalakeIT.javanew file mode 100644index 0000000000..fa3a7de68f--- /dev/null+++ b/integration-test/src/test/java/com/datastrato/graviton/integration/e2e/MetalakeIT.java@@ -0,0 +1,124 @@+/*+ * Copyright 2023 Datastrato.+ * This software is licensed under the Apache License version 2.+ */+package com.datastrato.graviton.integration.e2e;++import com.datastrato.graviton.MetalakeChange;+import com.datastrato.graviton.NameIdentifier;+import com.datastrato.graviton.client.GravitonMetaLake;+import com.datastrato.graviton.dto.MetalakeDTO;+import com.datastrato.graviton.exceptions.MetalakeAlreadyExistsException;+import com.datastrato.graviton.exceptions.NoSuchMetalakeException;+import com.datastrato.graviton.integration.util.AbstractIT;+import com.datastrato.graviton.integration.util.GravitonITUtils;+import java.util.Arrays;+import java.util.Collections;+import java.util.List;+import java.util.stream.Collectors;+import org.junit.jupiter.api.AfterAll;+import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.BeforeAll;+import org.junit.jupiter.api.MethodOrderer;+import org.junit.jupiter.api.Order;+import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.TestMethodOrder;++@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+public class MetalakeIT extends AbstractIT {+ public static String metalakeName = GravitonITUtils.genRandomName();++ @BeforeAll+ private static void start() {+ // Prepare create a metalake test record,+ // This way it can support `Run all tests` or `Run test in separated` to test `list`, `load`,+ // `alter`, `drop` methods.+ createMetalake();+ }++ @AfterAll+ private static void stop() {+ // Always drop the test record here.+ // This allows metalake to be safe deleted metalake when `Run all tests` or `Run test in+ // separated`+ dropMetalake();+ }++ @Order(1)+ @Test+ public void testListMetalake() {+ GravitonMetaLake[] metaLakes = client.listMetalakes();+ List<MetalakeDTO> result =+ Arrays.stream(metaLakes)+ .filter(metalakeDTO -> metalakeDTO.name().equals(metalakeName))+ .collect(Collectors.toList());++ Assertions.assertEquals(result.size(), 1);+ }++ @Order(2)+ @Test+ public void testLoadMetalake() {+ GravitonMetaLake metaLake = client.loadMetalake(NameIdentifier.of(metalakeName));+ Assertions.assertEquals(metaLake.name(), metalakeName);+ }++ @Order(3)+ @Test+ public void testAlterMetalake() {+ String alterMetalakeName = GravitonITUtils.genRandomName();++ // TODO: Add more test cases for alter metalake+ MetalakeChange[] changes1 =+ new MetalakeChange[] {+ MetalakeChange.rename(alterMetalakeName), MetalakeChange.updateComment("newComment")+ };+ GravitonMetaLake metaLake = client.alterMetalake(NameIdentifier.of(metalakeName), changes1);+ Assertions.assertEquals(alterMetalakeName, metaLake.name());+ Assertions.assertEquals("newComment", metaLake.comment());+ Assertions.assertEquals("graviton", metaLake.auditInfo().creator());++ // Reload metatada from backend to check if the changes are applied+ GravitonMetaLake metaLake1 = client.loadMetalake(NameIdentifier.of(alterMetalakeName));+ Assertions.assertEquals(alterMetalakeName, metaLake1.name());+ Assertions.assertEquals("newComment", metaLake1.comment());+ Assertions.assertEquals("graviton", metaLake1.auditInfo().creator());++ // Test return not found+ Throwable excep =+ Assertions.assertThrows(+ NoSuchMetalakeException.class,+ () -> client.alterMetalake(NameIdentifier.of(metalakeName + "mock"), changes1));+ Assertions.assertTrue(excep.getMessage().contains("does not exist"));++ // Restore test record+ MetalakeChange[] changes2 = new MetalakeChange[] {MetalakeChange.rename(metalakeName)};+ client.alterMetalake(NameIdentifier.of(alterMetalakeName), changes2);+ }++ public static void createMetalake() {+ GravitonMetaLake metaLake =+ client.createMetalake(+ NameIdentifier.parse(metalakeName), "comment", Collections.emptyMap());+ Assertions.assertEquals(metalakeName, metaLake.name());+ Assertions.assertEquals("comment", metaLake.comment());+ Assertions.assertEquals("graviton", metaLake.auditInfo().creator());++ // Test metalake name already exists+ Throwable excep =+ Assertions.assertThrows(+ MetalakeAlreadyExistsException.class,+ () ->+ client.createMetalake(+ NameIdentifier.parse(metalakeName), "comment", Collections.emptyMap()));+ Assertions.assertTrue(excep.getMessage().contains("already exists"));+ }++ public static void dropMetalake() {+ Assertions.assertTrue(client.dropMetalake(NameIdentifier.of(metalakeName)));++ // Reload metatada from backend to check if the drop are applied+ Assertions.assertThrows(+ NoSuchMetalakeException.class, () -> client.loadMetalake(NameIdentifier.of(metalakeName)));+ }+}diff --git a/integration-test/src/test/java/com/datastrato/graviton/integration/util/AbstractIT.java b/integration-test/src/test/java/com/datastrato/graviton/integration/util/AbstractIT.javanew file mode 100644index 0000000000..96bac83af9--- /dev/null+++ b/integration-test/src/test/java/com/datastrato/graviton/integration/util/AbstractIT.java@@ -0,0 +1,51 @@+/*+ * Copyright 2023 Datastrato.+ * This software is licensed under the Apache License version 2.+ */+package com.datastrato.graviton.integration.util;++import static com.datastrato.graviton.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;++import com.datastrato.graviton.Config;+import com.datastrato.graviton.client.GravitonClient;+import com.datastrato.graviton.server.GravitonServer;+import com.datastrato.graviton.server.ServerConfig;+import org.apache.commons.io.FileUtils;+import org.junit.jupiter.api.AfterAll;+import org.junit.jupiter.api.BeforeAll;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++public class AbstractIT {+ public static final Logger LOG = LoggerFactory.getLogger(AbstractIT.class);+ protected static GravitonClient client;++ @BeforeAll+ public static void startIntegrationTest() throws Exception {+ LOG.info("Starting up Graviton Server");++ Config serverConfig = new ServerConfig();+ serverConfig.loadFromFile(GravitonServer.CONF_FILE);++ try {+ FileUtils.deleteDirectory(FileUtils.getFile(serverConfig.get(ENTRY_KV_ROCKSDB_BACKEND_PATH)));+ } catch (Exception e) {+ // Ignore+ }++ GravitonITUtils.startGravitonServer();+ String uri =+ "http://"+ + serverConfig.get(ServerConfig.WEBSERVER_HOST)+ + ":"+ + serverConfig.get(ServerConfig.WEBSERVER_HTTP_PORT);+ client = GravitonClient.builder(uri).build();+ }++ @AfterAll+ public static void stopIntegrationTest() {+ client.close();+ GravitonITUtils.stopGravitonServer();+ LOG.info("Tearing down Graviton Server");+ }+}diff --git a/integration-test/src/test/java/com/datastrato/graviton/integration/util/CommandExecutor.java b/integration-test/src/test/java/com/datastrato/graviton/integration/util/CommandExecutor.javanew file mode 100644index 0000000000..084e112916--- /dev/null+++ b/integration-test/src/test/java/com/datastrato/graviton/integration/util/CommandExecutor.java@@ -0,0 +1,75 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF 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. You may obtain a copy of the License at+ *+ * 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 com.datastrato.graviton.integration.util;++import java.io.IOException;+import java.util.ArrayList;+import java.util.Arrays;+import java.util.List;+import org.apache.commons.lang3.StringUtils;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++// zeppelin-integration/src/test/java/org/apache/zeppelin/CommandExecutor.java+public class CommandExecutor {+ public static final Logger LOG = LoggerFactory.getLogger(CommandExecutor.class);++ public enum IGNORE_ERRORS {+ TRUE,+ FALSE+ }++ public static int NORMAL_EXIT = 0;++ private static IGNORE_ERRORS DEFAULT_BEHAVIOUR_ON_ERRORS = IGNORE_ERRORS.TRUE;++ public static Object executeCommandLocalHost(+ String[] command,+ boolean printToConsole,+ ProcessData.TypesOfData type,+ IGNORE_ERRORS ignore_errors) {+ List<String> subCommandsAsList = new ArrayList<>(Arrays.asList(command));+ String mergedCommand = StringUtils.join(subCommandsAsList, " ");++ LOG.info("Sending command \"" + mergedCommand + "\" to localhost");++ ProcessBuilder processBuilder = new ProcessBuilder(command);+ Process process = null;+ try {+ process = processBuilder.start();+ } catch (IOException e) {+ throw new RuntimeException(e);+ }++ ProcessData dataOfProcess = new ProcessData(process, printToConsole);+ Object outputOfProcess = dataOfProcess.getData(type);+ int exit_code = dataOfProcess.getExitCodeValue();++ if (!printToConsole) LOG.trace(outputOfProcess.toString());+ else LOG.debug(outputOfProcess.toString());+ if (ignore_errors == IGNORE_ERRORS.FALSE && exit_code != NORMAL_EXIT) {+ LOG.error(String.format("Command '%s' failed with exit code %s", mergedCommand, exit_code));+ }+ return outputOfProcess;+ }++ public static Object executeCommandLocalHost(+ String command, boolean printToConsole, ProcessData.TypesOfData type) {+ return executeCommandLocalHost(+ new String[] {"bash", "-c", command}, printToConsole, type, DEFAULT_BEHAVIOUR_ON_ERRORS);+ }+}diff --git a/integration-test/src/test/java/com/datastrato/graviton/integration/util/GravitonITUtils.java b/integration-test/src/test/java/com/datastrato/graviton/integration/util/GravitonITUtils.javanew file mode 100644index 0000000000..eeac312144--- /dev/null+++ b/integration-test/src/test/java/com/datastrato/graviton/integration/util/GravitonITUtils.java@@ -0,0 +1,50 @@+/*+ * Copyright 2023 Datastrato.+ * This software is licensed under the Apache License version 2.+ */+package com.datastrato.graviton.integration.util;++import java.util.UUID;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++public class GravitonITUtils {+ public static final Logger LOG = LoggerFactory.getLogger(GravitonITUtils.class);++ public static void startGravitonServer() {+ CommandExecutor.executeCommandLocalHost(+ System.getenv("GRAVITON_HOME") + "/bin/graviton.sh start",+ false,+ ProcessData.TypesOfData.OUTPUT);+ // wait for server to start.+ sleep(100, false);+ }++ public static void stopGravitonServer() {+ CommandExecutor.executeCommandLocalHost(+ System.getenv("GRAVITON_HOME") + "/bin/graviton.sh stop",+ false,+ ProcessData.TypesOfData.OUTPUT);+ // wait for server to stop.+ sleep(100, false);+ }++ public static void sleep(long millis, boolean logOutput) {+ if (logOutput) {+ LOG.info("Starting sleeping for " + millis + " milliseconds ...");+ LOG.info("Caller: " + Thread.currentThread().getStackTrace()[2]);+ }+ try {+ Thread.sleep(millis);+ } catch (InterruptedException e) {+ LOG.error("Exception in sleep() ", e);+ }+ if (logOutput) {+ LOG.info("Finished.");+ }+ }++ public static String genRandomName() {+ return UUID.randomUUID().toString().replace("-", "");+ }+}diff --git a/integration-test/src/test/java/com/datastrato/graviton/integration/util/ProcessData.java b/integration-test/src/test/java/com/datastrato/graviton/integration/util/ProcessData.javanew file mode 100644index 0000000000..b9caffd65a--- /dev/null+++ b/integration-test/src/test/java/com/datastrato/graviton/integration/util/ProcessData.java@@ -0,0 +1,297 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF 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. You may obtain a copy of the License at+ *+ * 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 com.datastrato.graviton.integration.util;++import java.io.BufferedReader;+import java.io.IOException;+import java.io.InputStream;+import java.io.InputStreamReader;+import java.io.PrintWriter;+import java.io.StringWriter;+import java.util.concurrent.TimeUnit;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++// zeppelin-integration/src/test/java/org/apache/zeppelin/ProcessData.java+public class ProcessData {+ public enum TypesOfData {+ OUTPUT,+ ERROR,+ EXIT_CODE,+ STREAMS_MERGED,+ PROCESS_DATA_OBJECT+ }++ public static final Logger LOG = LoggerFactory.getLogger(ProcessData.class);++ private Process checkedProcess;+ private boolean printToConsole = false;++ public ProcessData(+ Process connected_process, boolean printToConsole, int silenceTimeout, TimeUnit timeUnit) {+ this.checkedProcess = connected_process;+ this.printToConsole = printToConsole;+ this.silenceTimeout = TimeUnit.MILLISECONDS.convert(silenceTimeout, timeUnit);+ }++ public ProcessData(Process connected_process, boolean printToConsole, int silenceTimeoutSec) {+ this.checkedProcess = connected_process;+ this.printToConsole = printToConsole;+ this.silenceTimeout = TimeUnit.MILLISECONDS.convert(silenceTimeoutSec, TimeUnit.SECONDS);+ }++ public ProcessData(Process connected_process, boolean printToConsole) {+ this.checkedProcess = connected_process;+ this.printToConsole = printToConsole;+ }++ public ProcessData(Process connectedProcess) {+ this.checkedProcess = connectedProcess;+ this.printToConsole = true;+ }++ boolean returnCodeRetrieved = false;++ private String outPutStream = null;+ private String errorStream = null;+ private int returnCode;+ private long silenceTimeout = 10 * 60 * 1000;+ private final long unconditionalExitDelayMinutes = 30;++ public static boolean isRunning(Process process) {+ try {+ process.exitValue();+ return false;+ } catch (IllegalThreadStateException e) {+ return true;+ }+ }++ public Object getData(TypesOfData type) {+ // TODO get rid of Pseudo-terminal will not be allocated because stdin is not a terminal.+ switch (type) {+ case OUTPUT:+ {+ return this.getOutPutStream();+ }+ case ERROR:+ {+ return this.getErrorStream();+ }+ case EXIT_CODE:+ {+ return this.getExitCodeValue();+ }+ case STREAMS_MERGED:+ {+ return this.getOutPutStream() + "\n" + this.getErrorStream();+ }+ case PROCESS_DATA_OBJECT:+ {+ this.getErrorStream();+ return this;+ }+ default:+ {+ throw new IllegalArgumentException("Data Type " + type + " not supported yet!");+ }+ }+ }++ public int getExitCodeValue() {+ try {+ if (!returnCodeRetrieved) {+ this.checkedProcess.waitFor();+ this.returnCode = this.checkedProcess.exitValue();+ this.returnCodeRetrieved = true;+ this.checkedProcess.destroy();+ }+ } catch (Exception inter) {+ throw new RuntimeException(+ "Couldn't finish waiting for process " + this.checkedProcess + " termination", inter);+ }+ return this.returnCode;+ }++ public String getOutPutStream() {+ if (this.outPutStream == null) {+ try {+ buildOutputAndErrorStreamData();+ } catch (Exception e) {+ throw new RuntimeException(+ "Couldn't retrieve Output Stream data from process: " + this.checkedProcess.toString(),+ e);+ }+ }+ this.outPutStream =+ this.outPutStream.replace(+ "Pseudo-terminal will not be allocated because stdin is not a terminal.", "");+ this.errorStream =+ this.errorStream.replace(+ "Pseudo-terminal will not be allocated because stdin is not a terminal.", "");+ return this.outPutStream;+ }++ public String getErrorStream() {+ if (this.errorStream == null) {+ try {+ buildOutputAndErrorStreamData();+ } catch (Exception e) {+ throw new RuntimeException(+ "Couldn't retrieve Error Stream data from process: " + this.checkedProcess.toString(),+ e);+ }+ }+ this.outPutStream =+ this.outPutStream.replace(+ "Pseudo-terminal will not be allocated because stdin is not a terminal.", "");+ this.errorStream =+ this.errorStream.replace(+ "Pseudo-terminal will not be allocated because stdin is not a terminal.", "");+ return this.errorStream;+ }++ public String toString() {+ return String.format("[OUTPUT STREAM]\n%s\n", this.outPutStream)+ + String.format("[ERROR STREAM]\n%s\n", this.errorStream)+ + String.format("[EXIT CODE]\n%d", this.returnCode);+ }++ private void buildOutputAndErrorStreamData() throws IOException {+ StringBuilder sbInStream = new StringBuilder();+ StringBuilder sbErrorStream = new StringBuilder();++ try {+ InputStream in = this.checkedProcess.getInputStream();+ InputStream inErrors = this.checkedProcess.getErrorStream();+ BufferedReader inReader = new BufferedReader(new InputStreamReader(in));+ BufferedReader inReaderErrors = new BufferedReader(new InputStreamReader(inErrors));+ LOG.trace("Started retrieving data from streams of attached process: " + this.checkedProcess);++ // Store start time to be able to finish method if command hangs+ long lastStreamDataTime = System.currentTimeMillis();++ // Stop after 'unconditionalExitDelayMinutes' even if process is alive and sending output+ long unconditionalExitTime =+ System.currentTimeMillis()+ + TimeUnit.MILLISECONDS.convert(unconditionalExitDelayMinutes, TimeUnit.MINUTES);+ final int BUFFER_LEN = 300;+ char[] charBuffer =+ new char[BUFFER_LEN]; // Use char buffer to read output, size can be tuned.+ boolean outputProduced = true; // Flag to check if previous iteration produced any output++ // Continue if process is alive or some output was produced on previous iteration+ // and there may be still some data to read.+ while (isRunning(this.checkedProcess) || outputProduced) {+ outputProduced = false;++ // Some local commands can exit fast, but immediate stream reading will give no output and+ // after iteration, 'while' condition will be false so we will not read out any output while+ // it is still there, just need to wait for some time for it to appear in streams.+ GravitonITUtils.sleep(100, false);++ StringBuilder tempSB = new StringBuilder();+ while (inReader.ready()) {+ tempSB.setLength(0); // clean temporary StringBuilder+ int readCount =+ inReader.read(charBuffer, 0, BUFFER_LEN); // read up to 'BUFFER_LEN' chars to buffer+ if (readCount < 1) { // if nothing read or error occurred+ break;+ }+ tempSB.append(charBuffer, 0, readCount);++ sbInStream.append(tempSB);+ if (tempSB.length() > 0) {+ // set flag to know that we read something and there may be moire data, even if process+ // already exited+ outputProduced = true;+ }++ // remember last time data was read from streams to be sure we are not looping infinitely+ lastStreamDataTime = System.currentTimeMillis();+ }++ tempSB = new StringBuilder(); // Same, but for error stream+ while (inReaderErrors.ready()) {+ tempSB.setLength(0);+ int readCount = inReaderErrors.read(charBuffer, 0, BUFFER_LEN);+ if (readCount < 1) {+ break;+ }+ tempSB.append(charBuffer, 0, readCount);+ sbErrorStream.append(tempSB);+ if (tempSB.length() > 0) {+ outputProduced = true;+ String temp = new String(tempSB);+ temp =+ temp.replaceAll(+ "Pseudo-terminal will not be allocated because stdin is not a terminal.", "");+ // TODO : error stream output need to be improved, because it outputs downloading+ // information.+ if (printToConsole) {+ if (!temp.trim().equals("")) {+ if (temp.toLowerCase().contains("error") || temp.toLowerCase().contains("failed")) {+ LOG.warn(temp.trim());+ } else {+ LOG.debug(temp.trim());+ }+ }+ }+ }+ lastStreamDataTime = System.currentTimeMillis();+ }++ // Exit if silenceTimeout ms has passed from last stream read. Means process is alive but+ // not sending any data.+ if ((System.currentTimeMillis() - lastStreamDataTime > silenceTimeout)+ ||+ // Exit unconditionally - guards against alive process continuously sending data.+ (System.currentTimeMillis() > unconditionalExitTime)) {++ LOG.info(+ "Conditions: "+ + (System.currentTimeMillis() - lastStreamDataTime > silenceTimeout)+ + " "+ + (System.currentTimeMillis() > unconditionalExitTime));+ this.checkedProcess.destroy();+ try {+ if ((System.currentTimeMillis() > unconditionalExitTime)) {+ LOG.error(+ "!Unconditional exit occured!\nsome process hag up for more than "+ + unconditionalExitDelayMinutes+ + " minutes.");+ }+ LOG.error("!##################################!");+ StringWriter sw = new StringWriter();+ Exception e = new Exception("Exited from buildOutputAndErrorStreamData by timeout");+ e.printStackTrace(new PrintWriter(sw)); // Get stack trace+ LOG.error(String.valueOf(e), e);+ } catch (Exception ignore) {+ LOG.info("Exception in ProcessData while buildOutputAndErrorStreamData ", ignore);+ }+ break;+ }+ }++ in.close();+ inErrors.close();+ } finally {+ this.outPutStream = sbInStream.toString();+ this.errorStream = sbErrorStream.toString();+ }+ }+}diff --git a/integration-test/src/test/java/resources/log4j2.properties b/integration-test/src/test/java/resources/log4j2.propertiesnew file mode 100644index 0000000000..d4b8355d89--- /dev/null+++ b/integration-test/src/test/java/resources/log4j2.properties@@ -0,0 +1,22 @@+#+# Copyright 2023 Datastrato.+# This software is licensed under the Apache License version 2.+#++# Set to debug or trace if log4j initialization is failing+status = warn++# Name of the configuration+name = ConsoleLogConfigDemo++# Console appender configuration+appender.console.type = Console+appender.console.name = consoleLogger+appender.console.layout.type = PatternLayout+appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n++# Root logger level+rootLogger.level = debug++# Root logger referring to console appender+rootLogger.appenderRef.stdout.ref = consoleLogger\ No newline at end of filediff --git a/server/src/main/java/com/datastrato/graviton/server/GravitonServer.java b/server/src/main/java/com/datastrato/graviton/server/GravitonServer.javaindex 6f838824ca..0c8f3dc760 100644--- a/server/src/main/java/com/datastrato/graviton/server/GravitonServer.java+++ b/server/src/main/java/com/datastrato/graviton/server/GravitonServer.java@@ -23,7 +23,7 @@ public class GravitonServer extends ResourceConfig {private static final Logger LOG = LoggerFactory.getLogger(GravitonServer.class);- private static final String CONF_FILE = "graviton.conf";+ public static final String CONF_FILE = "graviton.conf";private final ServerConfig serverConfig;diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 78ec653c0e..746e40a723 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -4,4 +4,4 @@*/rootProject.name = "graviton"-include("api", "client-java", "common", "core", "meta", "server", "catalog-hive")+include("api", "client-java", "common", "core", "meta", "server", "catalog-hive", "integration-test")