From da9771a042ba867ced7735ec8097674ffc2c9fe3 Mon Sep 17 00:00:00 2001 From: Kalaiyarasiganeshalingam Date: Thu, 21 Nov 2024 13:39:45 +0530 Subject: [PATCH] Print path for testing Add print Update condition Update script Update script Update all test script Add print msg Add print Add additional print msg Update script changes Update the script Update the script Update the script Add another print statement --- distribution/src/scripts/micro-integrator.sh | 12 ++++--- .../carbonserver/CarbonServerManager.java | 13 ++++++++ .../src/test/resources/bin/integrator.sh | 32 +++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 32 +++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 32 +++++++++++++++++++ .../ApiWithConfigurablePropertyTestCase.java | 32 +++++++++++++++++++ .../ESB/serviceCatalog/micro-integrator.sh | 32 +++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 32 +++++++++++++++++++ .../enableCorrelation/micro-integrator.sh | 32 +++++++++++++++++++ .../artifacts/ESB/vfs/micro-integrator.sh | 32 +++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 31 ++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 32 +++++++++++++++++++ .../ESB/server/bin/micro-integrator.sh | 31 ++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 32 +++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 31 ++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 32 +++++++++++++++++++ .../src/test/resources/bin/integrator.sh | 32 +++++++++++++++++++ 17 files changed, 497 insertions(+), 5 deletions(-) diff --git a/distribution/src/scripts/micro-integrator.sh b/distribution/src/scripts/micro-integrator.sh index dd31526efb..1a41b06ecf 100644 --- a/distribution/src/scripts/micro-integrator.sh +++ b/distribution/src/scripts/micro-integrator.sh @@ -132,7 +132,7 @@ export_env_file() { # Read the .env file and export each variable to the environment while IFS='=' read -r key value; do # Ignore lines starting with '#' (comments) or empty lines - if [[ ! "$key" =~ ^# ]] && [[ "$key" != "" ]]; then + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then # Trim surrounding whitespace from key and value key=$(echo "$key" | xargs) value=$(echo "$value" | xargs) @@ -168,11 +168,13 @@ do else args="$args $c" fi + echo "11111111111111111111111111 $c" # Check if the argument starts with --env-file= - if [[ "$c" == --env-file=* ]]; then - # Extract the file path from the argument - file_path="${c#--env-file=}" - export_env_file "$file_path" + if [ "$c" = "--env-file=*" ]; then + echo "_____________________ env file __________" + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" fi done diff --git a/integration/automation-extensions/src/main/java/org/wso2/esb/integration/common/extensions/carbonserver/CarbonServerManager.java b/integration/automation-extensions/src/main/java/org/wso2/esb/integration/common/extensions/carbonserver/CarbonServerManager.java index 58efba38c5..57f3234d92 100644 --- a/integration/automation-extensions/src/main/java/org/wso2/esb/integration/common/extensions/carbonserver/CarbonServerManager.java +++ b/integration/automation-extensions/src/main/java/org/wso2/esb/integration/common/extensions/carbonserver/CarbonServerManager.java @@ -40,6 +40,9 @@ import java.io.File; import java.io.IOException; import java.net.Socket; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; @@ -135,6 +138,16 @@ public synchronized void startServerUsingCarbonHome(String carbonHome, Map commands = new HashMap<>(); + System.out.println("_________________________________"); + System.out.println(FrameworkPathUtil.getSystemResourceLocation() + "test.env"); + System.out.println("_________________________________"); commands.put("--env-file", FrameworkPathUtil.getSystemResourceLocation() + "test.env"); serverConfigurationManager.restartMicroIntegrator(commands); Map headers = new HashMap<>(); @@ -73,6 +96,15 @@ public void testConfigurableProperty() throws IOException, AutomationUtilExcepti commands.put("-Dname", "sys"); commands.put("-Dmsg", "Hi"); commands.put("--env-file", FrameworkPathUtil.getSystemResourceLocation() + "test.env"); + File env = new File(FrameworkPathUtil.getSystemResourceLocation() + "test.env"); + if (env.exists()) { + System.out.println("________--env-file File Exist_____________"); + } + if (env.canRead()) { + System.out.println("________--env-file readable_____________"); + System.out.println(Files.readString(env.toPath(), StandardCharsets.UTF_8)); + } + serverConfigurationManager.restartMicroIntegrator(commands); Map headers = new HashMap<>(); URL endpoint = new URL(getApiInvocationURL("apiConfig/test")); diff --git a/integration/mediation-tests/tests-other/src/test/resources/artifacts/ESB/serviceCatalog/micro-integrator.sh b/integration/mediation-tests/tests-other/src/test/resources/artifacts/ESB/serviceCatalog/micro-integrator.sh index 3d268f53e1..5d6633b92b 100755 --- a/integration/mediation-tests/tests-other/src/test/resources/artifacts/ESB/serviceCatalog/micro-integrator.sh +++ b/integration/mediation-tests/tests-other/src/test/resources/artifacts/ESB/serviceCatalog/micro-integrator.sh @@ -118,6 +118,32 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- + +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -139,6 +165,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-patches-with-smb2/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-patches-with-smb2/src/test/resources/bin/integrator.sh index 2a6a189918..2feff12c2f 100755 --- a/integration/mediation-tests/tests-patches-with-smb2/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-patches-with-smb2/src/test/resources/bin/integrator.sh @@ -136,6 +136,32 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- + +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -159,6 +185,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/passthru/transport/enableCorrelation/micro-integrator.sh b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/passthru/transport/enableCorrelation/micro-integrator.sh index 01ffcb3087..ade15eb339 100644 --- a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/passthru/transport/enableCorrelation/micro-integrator.sh +++ b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/passthru/transport/enableCorrelation/micro-integrator.sh @@ -118,6 +118,32 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- + +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -139,6 +165,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.sh b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.sh index 6c65c36eaa..5e5dc6a4a1 100755 --- a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.sh +++ b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.sh @@ -118,6 +118,32 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- + +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -142,6 +168,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$ARGUMENT" = "car" ]; then diff --git a/integration/mediation-tests/tests-patches/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-patches/src/test/resources/bin/integrator.sh index 2a6a189918..12e6ed5c95 100755 --- a/integration/mediation-tests/tests-patches/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-patches/src/test/resources/bin/integrator.sh @@ -136,6 +136,31 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -159,6 +184,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-platform/tests-rabbitmq/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-platform/tests-rabbitmq/src/test/resources/bin/integrator.sh index 2a6a189918..2feff12c2f 100755 --- a/integration/mediation-tests/tests-platform/tests-rabbitmq/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-platform/tests-rabbitmq/src/test/resources/bin/integrator.sh @@ -136,6 +136,32 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- + +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -159,6 +185,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-platform/tests-userstore/src/test/resources/artifacts/ESB/server/bin/micro-integrator.sh b/integration/mediation-tests/tests-platform/tests-userstore/src/test/resources/artifacts/ESB/server/bin/micro-integrator.sh index 370944c5ed..225cf1b21e 100755 --- a/integration/mediation-tests/tests-platform/tests-userstore/src/test/resources/artifacts/ESB/server/bin/micro-integrator.sh +++ b/integration/mediation-tests/tests-platform/tests-userstore/src/test/resources/artifacts/ESB/server/bin/micro-integrator.sh @@ -118,6 +118,31 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -139,6 +164,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-platform/tests-wso2mb/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-platform/tests-wso2mb/src/test/resources/bin/integrator.sh index 2a6a189918..2feff12c2f 100755 --- a/integration/mediation-tests/tests-platform/tests-wso2mb/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-platform/tests-wso2mb/src/test/resources/bin/integrator.sh @@ -136,6 +136,32 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- + +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -159,6 +185,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-sample/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-sample/src/test/resources/bin/integrator.sh index 2a6a189918..12e6ed5c95 100755 --- a/integration/mediation-tests/tests-sample/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-sample/src/test/resources/bin/integrator.sh @@ -136,6 +136,31 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -159,6 +184,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-service/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-service/src/test/resources/bin/integrator.sh index 2a6a189918..2feff12c2f 100755 --- a/integration/mediation-tests/tests-service/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-service/src/test/resources/bin/integrator.sh @@ -136,6 +136,32 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- + +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -159,6 +185,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then diff --git a/integration/mediation-tests/tests-transport/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-transport/src/test/resources/bin/integrator.sh index 2a6a189918..2feff12c2f 100755 --- a/integration/mediation-tests/tests-transport/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-transport/src/test/resources/bin/integrator.sh @@ -136,6 +136,32 @@ if [ -e "$CARBON_HOME/wso2carbon.pid" ]; then fi # ----- Process the input command ---------------------------------------------- + +# Function to export variables from the given .env file +export_env_file() { + local file_path="$1" + + # Check if the file exists + if [ ! -f "$file_path" ]; then + echo "Error: File '$file_path' not found." + return 1 # Return with an error status + fi + + # Read the .env file and export each variable to the environment + while IFS='=' read -r key value; do + # Ignore lines starting with '#' (comments) or empty lines + if [ ! "$key" =~ ^# ] && [ "$key" != "" ]; then + # Trim surrounding whitespace from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + # Export the key-value pair to the environment + export "$key=$value" + fi + done < "$file_path" + + echo "Environment variables loaded from $file_path." +} + args="" for c in $* do @@ -159,6 +185,12 @@ do else args="$args $c" fi + # Check if the argument starts with --env-file= + if [ "$c" == --env-file=* ]; then + # Extract the file path from the argument + file_path="${c#--env-file=}" + export_env_file "$file_path" + fi done if [ "$CMD" = "--debug" ]; then