From 5303a37eb036f856dc6cadec76b0532899c62507 Mon Sep 17 00:00:00 2001 From: tharindu1992 <41312286+tharindu1992@users.noreply.github.com> Date: Tue, 18 Sep 2018 16:49:06 +0530 Subject: [PATCH] Get JVM metrics from Windows (#145) * Make jvm metrics collection support in windows * Fix code to change wso2server.bat in windows --- integration-tests/configure_product.py | 33 +++++++++++++++++++------- integration-tests/const.py | 2 +- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/integration-tests/configure_product.py b/integration-tests/configure_product.py index fc66be3d..da0ab8c9 100644 --- a/integration-tests/configure_product.py +++ b/integration-tests/configure_product.py @@ -147,16 +147,31 @@ def modify_pom_files(): def attach_jolokia_agent(spath): logger.info('attaching jolokia agent as a java agent') sp = str(spath) - with open(sp, "r") as in_file: - buf = in_file.readlines() - - with open(sp, "w") as out_file: - for line in buf: - if line == " $JAVACMD \\\n": - line = line + " -javaagent:/opt/wso2/jolokia-jvm-1.6.0-agent.jar=port=8778,host=localhost,protocol=http \\\n" - logger.info(line) - out_file.write(line) + if sys.platform.startswith('win'): + sp = sp + ".bat" + jolokia_agent = "-javaagent:C:\\testgrid\\jolokia-jvm-1.6.0-agent.jar=port=8778,host=localhost,protocol=http " + with open(sp, "r") as in_file: + buf = in_file.readlines() + with open(sp, "w") as out_file: + for line in buf: + if line.startswith("set CMD_LINE_ARGS"): + newline = str(line).replace("CMD_LINE_ARGS=", 'CMD_LINE_ARGS='+jolokia_agent) + line = newline + logger.info(newline) + out_file.write(line) + else: + sp = sp + ".sh" + jolokia_agent = \ + " -javaagent:/opt/wso2/jolokia-jvm-1.6.0-agent.jar=port=8778,host=localhost,protocol=http \\\n" + with open(sp, "r") as in_file: + buf = in_file.readlines() + with open(sp, "w") as out_file: + for line in buf: + if line == " $JAVACMD \\\n": + line = line + jolokia_agent + logger.info(line) + out_file.write(line) def modify_datasources(): """Modify datasources files which are defined in the const.py. DB ulr, uname, pwd, driver class values are modifying. diff --git a/integration-tests/const.py b/integration-tests/const.py index 98caae4d..743d0942 100644 --- a/integration-tests/const.py +++ b/integration-tests/const.py @@ -30,7 +30,7 @@ "product-is": "modules/distribution/target", "product-ei": "modules/distribution/target"} PRODUCT_STORAGE_DIR_NAME = "storage" -WSO2SERVER = "bin/wso2server.sh" +WSO2SERVER = "bin/wso2server" TEST_PLAN_PROPERTY_FILE_NAME = "testplan-props.properties" INFRA_PROPERTY_FILE_NAME = "infrastructure.properties" LOG_FILE_NAME = "integration.log"