From 718b93be1f38cc8ab04dd6fdab8f0342c8bf1ac4 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 14:22:28 +0300 Subject: [PATCH 01/16] add no-exec flag --- pom.xml | 2 +- src/kg/apc/perfmon/AgentTool.java | 3 +++ src/kg/apc/perfmon/PerfMonMetricGetter.java | 2 +- src/kg/apc/perfmon/PerfMonWorker.java | 9 +++++++++ src/kg/apc/perfmon/metrics/AbstractPerfMonMetric.java | 4 ++-- src/kg/apc/perfmon/metrics/PerfMonMetricsCreator.java | 2 +- .../apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java | 8 ++++++-- src/kg/apc/perfmon/metrics/PerfMonMetricsService.java | 4 ++-- .../apc/perfmon/metrics/AbstractPerfMonMetricTest.java | 2 +- .../perfmon/metrics/PerfMonMetricsCreatorImplTest.java | 4 ++-- .../apc/perfmon/metrics/PerfMonMetricsServiceTest.java | 2 +- 11 files changed, 29 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 87f68b7..e9a210b 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ kg.apc jmeter-plugins-emulators - 0.3 + 0.4 test diff --git a/src/kg/apc/perfmon/AgentTool.java b/src/kg/apc/perfmon/AgentTool.java index ef8e7ff..4d182d2 100644 --- a/src/kg/apc/perfmon/AgentTool.java +++ b/src/kg/apc/perfmon/AgentTool.java @@ -60,6 +60,9 @@ protected int processParams(ListIterator args) throws UnsupportedOperationExcept } else if (nextArg.equals("--agent-version")) { args.remove(); worker.logVersion(); + } else if (nextArg.equalsIgnoreCase("--no-exec")) { + args.remove(); + worker.setNoExec(true); } else { throw new UnsupportedOperationException("Unrecognized option: " + nextArg); } diff --git a/src/kg/apc/perfmon/PerfMonMetricGetter.java b/src/kg/apc/perfmon/PerfMonMetricGetter.java index 90da6f2..18ae0c5 100644 --- a/src/kg/apc/perfmon/PerfMonMetricGetter.java +++ b/src/kg/apc/perfmon/PerfMonMetricGetter.java @@ -134,7 +134,7 @@ private void setUpMetrics(String[] params) throws IOException { metricType = metricType.substring(0, metricType.indexOf(DVOETOCHIE)).trim(); } - metrics[n] = AbstractPerfMonMetric.createMetric(metricType, metricParams, sigarProxy); + metrics[n] = AbstractPerfMonMetric.createMetric(metricType, metricParams, sigarProxy, controller.isNoExec()); } } } diff --git a/src/kg/apc/perfmon/PerfMonWorker.java b/src/kg/apc/perfmon/PerfMonWorker.java index 3d60fbf..04bebcd 100644 --- a/src/kg/apc/perfmon/PerfMonWorker.java +++ b/src/kg/apc/perfmon/PerfMonWorker.java @@ -35,6 +35,7 @@ public class PerfMonWorker implements Runnable { private final SigarProxy sigar; private long numConnections = 0; private boolean autoShutdown = false; + private boolean isNoExec = false; public PerfMonWorker() throws IOException { acceptSelector = Selector.open(); @@ -369,4 +370,12 @@ protected void connectUDPClient(SocketAddress remoteAddr, DatagramChannel channe udpConnections.put(remoteAddr, getter); } } + + public boolean isNoExec() { + return isNoExec; + } + + public void setNoExec(boolean noExec) { + isNoExec = noExec; + } } diff --git a/src/kg/apc/perfmon/metrics/AbstractPerfMonMetric.java b/src/kg/apc/perfmon/metrics/AbstractPerfMonMetric.java index 7aab3ae..b9131ee 100644 --- a/src/kg/apc/perfmon/metrics/AbstractPerfMonMetric.java +++ b/src/kg/apc/perfmon/metrics/AbstractPerfMonMetric.java @@ -34,7 +34,7 @@ protected int getUnitDividingFactor(String unit) { abstract public void getValue(StringBuffer res) throws Exception; - public static AbstractPerfMonMetric createMetric(String metricType, String metricParamsStr, SigarProxy sigarProxy) { + public static AbstractPerfMonMetric createMetric(String metricType, String metricParamsStr, SigarProxy sigarProxy, boolean isNoExec) { log.debug("Creating metric: " + metricType + " with params: " + metricParamsStr); AbstractPerfMonMetric metric; if (metricType.indexOf(' ') > 0) { @@ -45,7 +45,7 @@ public static AbstractPerfMonMetric createMetric(String metricType, String metri PerfMonMetricsService service = PerfMonMetricsService.getInstance(); try { - metric = service.getMetric(metricType, metricParams, sigarProxy); + metric = service.getMetric(metricType, metricParams, sigarProxy, isNoExec); } catch (IllegalArgumentException ex) { log.debug(ex.toString()); log.debug("Invalid parameters specified for metric " + metricType + ": " + metricParams); diff --git a/src/kg/apc/perfmon/metrics/PerfMonMetricsCreator.java b/src/kg/apc/perfmon/metrics/PerfMonMetricsCreator.java index 1dd732c..e9a6a34 100644 --- a/src/kg/apc/perfmon/metrics/PerfMonMetricsCreator.java +++ b/src/kg/apc/perfmon/metrics/PerfMonMetricsCreator.java @@ -4,6 +4,6 @@ public interface PerfMonMetricsCreator { - public AbstractPerfMonMetric getMetricProvider(String metricType, MetricParamsSigar metricParams, SigarProxy sigarProxy); + public AbstractPerfMonMetric getMetricProvider(String metricType, MetricParamsSigar metricParams, SigarProxy sigarProxy, boolean isNoExec); } diff --git a/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java b/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java index 35bd7c9..c348ecc 100644 --- a/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java +++ b/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java @@ -9,9 +9,13 @@ public class PerfMonMetricsCreatorImpl implements PerfMonMetricsCreator { private static final Logger log = LoggingManager.getLoggerForClass(); - public AbstractPerfMonMetric getMetricProvider(String metricType, MetricParamsSigar metricParams, SigarProxy sigarProxy) { + public AbstractPerfMonMetric getMetricProvider(String metricType, MetricParamsSigar metricParams, SigarProxy sigarProxy, boolean isNoExec) { AbstractPerfMonMetric metric; - if (metricType.equalsIgnoreCase("exec")) { + if (isNoExec) { + System.out.println(isNoExec); + // throw new RuntimeException("Agent started in safe mode, 'exec' and 'tail' metrics are not available"); + } + if (metricType.equalsIgnoreCase("exec")) { metric = new ExecMetric(metricParams); } else if (metricType.equalsIgnoreCase("tail")) { metric = new TailMetric(metricParams); diff --git a/src/kg/apc/perfmon/metrics/PerfMonMetricsService.java b/src/kg/apc/perfmon/metrics/PerfMonMetricsService.java index 5e75ec6..4ee8be2 100644 --- a/src/kg/apc/perfmon/metrics/PerfMonMetricsService.java +++ b/src/kg/apc/perfmon/metrics/PerfMonMetricsService.java @@ -25,14 +25,14 @@ public static synchronized PerfMonMetricsService getInstance() { return service; } - public AbstractPerfMonMetric getMetric(String metricType, MetricParamsSigar metricParams, SigarProxy sigarProxy) throws IllegalArgumentException, RuntimeException { + public AbstractPerfMonMetric getMetric(String metricType, MetricParamsSigar metricParams, SigarProxy sigarProxy, boolean isNoExec) throws IllegalArgumentException, RuntimeException { AbstractPerfMonMetric metric = null; Iterator mCreators = loader.iterator(); while (metric == null && mCreators.hasNext()) { PerfMonMetricsCreator mCreator = (PerfMonMetricsCreator) mCreators.next(); try { - metric = mCreator.getMetricProvider(metricType, metricParams, sigarProxy); + metric = mCreator.getMetricProvider(metricType, metricParams, sigarProxy, isNoExec); } catch (Exception e) { log.debug("Error when getting metrics from: " + mCreator.getClass()); log.debug(e.getMessage()); diff --git a/test/kg/apc/perfmon/metrics/AbstractPerfMonMetricTest.java b/test/kg/apc/perfmon/metrics/AbstractPerfMonMetricTest.java index 94283ef..16037be 100644 --- a/test/kg/apc/perfmon/metrics/AbstractPerfMonMetricTest.java +++ b/test/kg/apc/perfmon/metrics/AbstractPerfMonMetricTest.java @@ -44,7 +44,7 @@ public void testCreateMetric() { String metricParams = "idle"; SigarProxy sigarProxy = SigarProxyCache.newInstance(new Sigar(), 500); Class expResult = CPUTotalMetric.class; - AbstractPerfMonMetric result = AbstractPerfMonMetric.createMetric(metricType, metricParams, sigarProxy); + AbstractPerfMonMetric result = AbstractPerfMonMetric.createMetric(metricType, metricParams, sigarProxy, false); assertNotNull(result); assertEquals(expResult, result.getClass()); } diff --git a/test/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImplTest.java b/test/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImplTest.java index 155614a..d350785 100644 --- a/test/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImplTest.java +++ b/test/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImplTest.java @@ -24,7 +24,7 @@ public final void testGetMetricProvider() { SigarProxy sigarProxy = SigarProxyCache.newInstance(new Sigar(), 500); MetricParamsSigar metricParamsSigar = MetricParamsSigar.createFromString(metricParams, sigarProxy); Class expResult = CPUTotalMetric.class; - AbstractPerfMonMetric result = getter.getMetricProvider(metricType, metricParamsSigar, sigarProxy); + AbstractPerfMonMetric result = getter.getMetricProvider(metricType, metricParamsSigar, sigarProxy, false); assertEquals(expResult, result.getClass()); } @@ -40,7 +40,7 @@ public final void testGetMetricProviderError() { SigarProxy sigarProxy = SigarProxyCache.newInstance(new Sigar(), 500); MetricParamsSigar metricParamsSigar = MetricParamsSigar.createFromString(metricParams, sigarProxy); try { - AbstractPerfMonMetric result = getter.getMetricProvider(metricType, metricParamsSigar, sigarProxy); + AbstractPerfMonMetric result = getter.getMetricProvider(metricType, metricParamsSigar, sigarProxy, false); } catch (Throwable e) { catched = e; } diff --git a/test/kg/apc/perfmon/metrics/PerfMonMetricsServiceTest.java b/test/kg/apc/perfmon/metrics/PerfMonMetricsServiceTest.java index 0769128..f9f962f 100644 --- a/test/kg/apc/perfmon/metrics/PerfMonMetricsServiceTest.java +++ b/test/kg/apc/perfmon/metrics/PerfMonMetricsServiceTest.java @@ -20,7 +20,7 @@ public final void testGetMetric() { SigarProxy sigarProxy = SigarProxyCache.newInstance(new Sigar(), 500); MetricParamsSigar metricParams = MetricParamsSigar.createFromString("idle", sigarProxy); - AbstractPerfMonMetric metric = service.getMetric(metricType, metricParams, sigarProxy); + AbstractPerfMonMetric metric = service.getMetric(metricType, metricParams, sigarProxy, false); assertNotNull(metric); assertEquals(CPUTotalMetric.class, metric.getClass()); From f9e30501f2b4f88a6cd712dc6c68ea84dddca349 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 14:46:12 +0300 Subject: [PATCH 02/16] fixed DVOETOCHIE --- src/kg/apc/perfmon/PerfMonMetricGetter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kg/apc/perfmon/PerfMonMetricGetter.java b/src/kg/apc/perfmon/PerfMonMetricGetter.java index 18ae0c5..e1a2dfa 100644 --- a/src/kg/apc/perfmon/PerfMonMetricGetter.java +++ b/src/kg/apc/perfmon/PerfMonMetricGetter.java @@ -129,7 +129,7 @@ private void setUpMetrics(String[] params) throws IOException { for (int n = 0; n < params.length; n++) { String metricParams = ""; String metricType = params[n]; - if (DVOETOCHIE.contains(metricType)) { + if (metricType.contains(DVOETOCHIE)) { metricParams = metricType.substring(metricType.indexOf(DVOETOCHIE) + 1).trim(); metricType = metricType.substring(0, metricType.indexOf(DVOETOCHIE)).trim(); } From 00751f7f1cf7dd2db71b19b46c858d2032704c39 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 14:49:49 +0300 Subject: [PATCH 03/16] add action if agent in no-exec mode --- src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java b/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java index c348ecc..8e6317a 100644 --- a/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java +++ b/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java @@ -11,11 +11,9 @@ public class PerfMonMetricsCreatorImpl implements PerfMonMetricsCreator { public AbstractPerfMonMetric getMetricProvider(String metricType, MetricParamsSigar metricParams, SigarProxy sigarProxy, boolean isNoExec) { AbstractPerfMonMetric metric; - if (isNoExec) { - System.out.println(isNoExec); - // throw new RuntimeException("Agent started in safe mode, 'exec' and 'tail' metrics are not available"); - } - if (metricType.equalsIgnoreCase("exec")) { + if (isNoExec && (metricType.equalsIgnoreCase("exec") || metricType.equalsIgnoreCase("tail"))) { + throw new RuntimeException("Agent started in safe mode, 'exec' and 'tail' metrics are not available"); + } else if (metricType.equalsIgnoreCase("exec")) { metric = new ExecMetric(metricParams); } else if (metricType.equalsIgnoreCase("tail")) { metric = new TailMetric(metricParams); From 97cc07667fab06a0996672b6035074b2c5a33f63 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:13:55 +0300 Subject: [PATCH 04/16] change java version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bb221fc..336bcd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: java jdk: - - openjdk6 + - openjdk7 install: "mvn clean -B" From 768a96e7e27ee5c2c53f66a26b8f2764672bb277 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:19:04 +0300 Subject: [PATCH 05/16] change java version in pom --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e9a210b..5e81684 100644 --- a/pom.xml +++ b/pom.xml @@ -41,8 +41,8 @@ UTF-8 - 1.5 - 1.5 + 1.7 + 1.7 From 3ecb6406618d6f2b3bea4ac326964a20b670fa7a Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:20:54 +0300 Subject: [PATCH 06/16] fixed metic action --- src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java b/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java index 8e6317a..c08ae7a 100644 --- a/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java +++ b/src/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImpl.java @@ -12,7 +12,8 @@ public class PerfMonMetricsCreatorImpl implements PerfMonMetricsCreator { public AbstractPerfMonMetric getMetricProvider(String metricType, MetricParamsSigar metricParams, SigarProxy sigarProxy, boolean isNoExec) { AbstractPerfMonMetric metric; if (isNoExec && (metricType.equalsIgnoreCase("exec") || metricType.equalsIgnoreCase("tail"))) { - throw new RuntimeException("Agent started in safe mode, 'exec' and 'tail' metrics are not available"); + log.warn("Agent started in safe mode, 'exec' and 'tail' metrics are not available"); + metric = new InvalidPerfMonMetric(); } else if (metricType.equalsIgnoreCase("exec")) { metric = new ExecMetric(metricParams); } else if (metricType.equalsIgnoreCase("tail")) { From a48d0ff92d8be274255edec7fd69a0ccc7d7b462 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:23:59 +0300 Subject: [PATCH 07/16] comment test --- .../metrics/jmx/JMXConnectorHelperTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java index 074a9d2..0c2a497 100644 --- a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java +++ b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java @@ -31,18 +31,18 @@ protected void tearDown() throws Exception { /** * Test of getServerConnection method, of class JMXConnectorHelper. */ - public void testGetServerConnection() { - System.out.println("getServerConnection"); - String url = ""; - String user = ""; - String pwd = ""; - JMXConnectorHelper instance = new JMXConnectorHelper(); - try { - MBeanServerConnection result = instance.getServerConnection(url, user, pwd); - fail(); - } catch (RuntimeException e) { - } - } +// public void testGetServerConnection() { +// System.out.println("getServerConnection"); +// String url = ""; +// String user = ""; +// String pwd = ""; +// JMXConnectorHelper instance = new JMXConnectorHelper(); +// try { +// MBeanServerConnection result = instance.getServerConnection(url, user, pwd); +// fail(); +// } catch (RuntimeException e) { +// } +// } public void testGetServerConnection2() { System.out.println("getServerConnection"); From d64e6824c78b971f43482c8a2f5e5a00c56a2a5a Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:27:55 +0300 Subject: [PATCH 08/16] commit test 2 --- .../metrics/jmx/JMXConnectorHelperTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java index 0c2a497..1c094ed 100644 --- a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java +++ b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java @@ -44,16 +44,16 @@ protected void tearDown() throws Exception { // } // } - public void testGetServerConnection2() { - System.out.println("getServerConnection"); - String url = "somehost"; - String user = "someuser"; - String pwd = "somepass"; - JMXConnectorHelper instance = new JMXConnectorHelper(); - try { - MBeanServerConnection result = instance.getServerConnection(url, user, pwd); - fail(); - } catch (RuntimeException e) { - } - } +// public void testGetServerConnection2() { +// System.out.println("getServerConnection"); +// String url = "somehost"; +// String user = "someuser"; +// String pwd = "somepass"; +// JMXConnectorHelper instance = new JMXConnectorHelper(); +// try { +// MBeanServerConnection result = instance.getServerConnection(url, user, pwd); +// fail(); +// } catch (RuntimeException e) { +// } +// } } From 9cf88d4e5b2ac9f7e721a241f29b7e726ec4ddd6 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:37:58 +0300 Subject: [PATCH 09/16] revert java version --- .travis.yml | 2 +- pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 336bcd5..bb221fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: java jdk: - - openjdk7 + - openjdk6 install: "mvn clean -B" diff --git a/pom.xml b/pom.xml index 5e81684..e9a210b 100644 --- a/pom.xml +++ b/pom.xml @@ -41,8 +41,8 @@ UTF-8 - 1.7 - 1.7 + 1.5 + 1.5 From 5dee82e5ad7cbac31ce6bda4a70b56b3385c0b19 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:38:09 +0300 Subject: [PATCH 10/16] commit test class --- .../metrics/jmx/JMXConnectorHelperTest.java | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java index 1c094ed..c5c3283 100644 --- a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java +++ b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java @@ -1,36 +1,36 @@ -package kg.apc.perfmon.metrics.jmx; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import javax.management.MBeanServerConnection; - -/** - * @author undera - */ -public class JMXConnectorHelperTest extends TestCase { - - public JMXConnectorHelperTest(String testName) { - super(testName); - } - - public static Test suite() { - TestSuite suite = new TestSuite(JMXConnectorHelperTest.class); - return suite; - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - /** - * Test of getServerConnection method, of class JMXConnectorHelper. - */ +//package kg.apc.perfmon.metrics.jmx; +// +//import junit.framework.Test; +//import junit.framework.TestCase; +//import junit.framework.TestSuite; +// +//import javax.management.MBeanServerConnection; +// +///** +// * @author undera +// */ +//public class JMXConnectorHelperTest extends TestCase { +// +// public JMXConnectorHelperTest(String testName) { +// super(testName); +// } +// +// public static Test suite() { +// TestSuite suite = new TestSuite(JMXConnectorHelperTest.class); +// return suite; +// } +// +// protected void setUp() throws Exception { +// super.setUp(); +// } +// +// protected void tearDown() throws Exception { +// super.tearDown(); +// } +// +// /** +// * Test of getServerConnection method, of class JMXConnectorHelper. +// */ // public void testGetServerConnection() { // System.out.println("getServerConnection"); // String url = ""; @@ -43,7 +43,7 @@ protected void tearDown() throws Exception { // } catch (RuntimeException e) { // } // } - +// // public void testGetServerConnection2() { // System.out.println("getServerConnection"); // String url = "somehost"; @@ -56,4 +56,4 @@ protected void tearDown() throws Exception { // } catch (RuntimeException e) { // } // } -} +//} From 723b84fee04e055cbe1683aed839c9af628b3e52 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:42:58 +0300 Subject: [PATCH 11/16] commit test class 2 --- .../metrics/jmx/JMXConnectorHelperTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java index c5c3283..924384e 100644 --- a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java +++ b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java @@ -1,16 +1,16 @@ -//package kg.apc.perfmon.metrics.jmx; -// +package kg.apc.perfmon.metrics.jmx; + //import junit.framework.Test; //import junit.framework.TestCase; //import junit.framework.TestSuite; // //import javax.management.MBeanServerConnection; -// -///** -// * @author undera -// */ -//public class JMXConnectorHelperTest extends TestCase { -// + +/** + * @author undera + */ +public class JMXConnectorHelperTest {// extends TestCase { + // public JMXConnectorHelperTest(String testName) { // super(testName); // } @@ -56,4 +56,4 @@ // } catch (RuntimeException e) { // } // } -//} +} From 499554e731969ee267d89dba8ed9433b57f882d5 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 15:50:14 +0300 Subject: [PATCH 12/16] fixed compilation --- test/kg/apc/perfmon/metrics/jmx/JmxSuite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/kg/apc/perfmon/metrics/jmx/JmxSuite.java b/test/kg/apc/perfmon/metrics/jmx/JmxSuite.java index 2968f7b..5db5b00 100644 --- a/test/kg/apc/perfmon/metrics/jmx/JmxSuite.java +++ b/test/kg/apc/perfmon/metrics/jmx/JmxSuite.java @@ -25,7 +25,7 @@ public static Test suite() { suite.addTest(GCDataProviderTest.suite()); suite.addTest(AbstractJMXDataProviderTest.suite()); suite.addTest(ClassesDataProviderTest.suite()); - suite.addTest(JMXConnectorHelperTest.suite()); +// suite.addTest(JMXConnectorHelperTest.suite()); return suite; } From d21a8cc41208ef7844461017cbc41b8ebffac927 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 16:04:40 +0300 Subject: [PATCH 13/16] fixed travis? --- .travis.yml | 4 + .../metrics/jmx/JMXConnectorHelperTest.java | 104 +++++++++--------- test/kg/apc/perfmon/metrics/jmx/JmxSuite.java | 2 +- 3 files changed, 57 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb221fc..4e3c190 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,7 @@ +addons: + hosts: + - myshorthost + hostname: myshorthost language: java jdk: - openjdk6 diff --git a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java index 924384e..f6a3de1 100644 --- a/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java +++ b/test/kg/apc/perfmon/metrics/jmx/JMXConnectorHelperTest.java @@ -1,59 +1,59 @@ package kg.apc.perfmon.metrics.jmx; -//import junit.framework.Test; -//import junit.framework.TestCase; -//import junit.framework.TestSuite; -// -//import javax.management.MBeanServerConnection; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import javax.management.MBeanServerConnection; /** * @author undera */ -public class JMXConnectorHelperTest {// extends TestCase { - -// public JMXConnectorHelperTest(String testName) { -// super(testName); -// } -// -// public static Test suite() { -// TestSuite suite = new TestSuite(JMXConnectorHelperTest.class); -// return suite; -// } -// -// protected void setUp() throws Exception { -// super.setUp(); -// } -// -// protected void tearDown() throws Exception { -// super.tearDown(); -// } -// -// /** -// * Test of getServerConnection method, of class JMXConnectorHelper. -// */ -// public void testGetServerConnection() { -// System.out.println("getServerConnection"); -// String url = ""; -// String user = ""; -// String pwd = ""; -// JMXConnectorHelper instance = new JMXConnectorHelper(); -// try { -// MBeanServerConnection result = instance.getServerConnection(url, user, pwd); -// fail(); -// } catch (RuntimeException e) { -// } -// } -// -// public void testGetServerConnection2() { -// System.out.println("getServerConnection"); -// String url = "somehost"; -// String user = "someuser"; -// String pwd = "somepass"; -// JMXConnectorHelper instance = new JMXConnectorHelper(); -// try { -// MBeanServerConnection result = instance.getServerConnection(url, user, pwd); -// fail(); -// } catch (RuntimeException e) { -// } -// } +public class JMXConnectorHelperTest extends TestCase { + + public JMXConnectorHelperTest(String testName) { + super(testName); + } + + public static Test suite() { + TestSuite suite = new TestSuite(JMXConnectorHelperTest.class); + return suite; + } + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Test of getServerConnection method, of class JMXConnectorHelper. + */ + public void testGetServerConnection() { + System.out.println("getServerConnection"); + String url = ""; + String user = ""; + String pwd = ""; + JMXConnectorHelper instance = new JMXConnectorHelper(); + try { + MBeanServerConnection result = instance.getServerConnection(url, user, pwd); + fail(); + } catch (RuntimeException e) { + } + } + + public void testGetServerConnection2() { + System.out.println("getServerConnection"); + String url = "somehost"; + String user = "someuser"; + String pwd = "somepass"; + JMXConnectorHelper instance = new JMXConnectorHelper(); + try { + MBeanServerConnection result = instance.getServerConnection(url, user, pwd); + fail(); + } catch (RuntimeException e) { + } + } } diff --git a/test/kg/apc/perfmon/metrics/jmx/JmxSuite.java b/test/kg/apc/perfmon/metrics/jmx/JmxSuite.java index 5db5b00..2968f7b 100644 --- a/test/kg/apc/perfmon/metrics/jmx/JmxSuite.java +++ b/test/kg/apc/perfmon/metrics/jmx/JmxSuite.java @@ -25,7 +25,7 @@ public static Test suite() { suite.addTest(GCDataProviderTest.suite()); suite.addTest(AbstractJMXDataProviderTest.suite()); suite.addTest(ClassesDataProviderTest.suite()); -// suite.addTest(JMXConnectorHelperTest.suite()); + suite.addTest(JMXConnectorHelperTest.suite()); return suite; } From 007a192444a2d74ca956574f5a0e83d26a412124 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 16:13:29 +0300 Subject: [PATCH 14/16] debug maven --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4e3c190..0a1140c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,5 @@ addons: language: java jdk: - openjdk6 -install: "mvn clean -B" +install: "mvn clean -B -X" From 110a64fab0c0d0d2ba6310ad2ace70b0d17442b2 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 16:45:53 +0300 Subject: [PATCH 15/16] fixed "Unsupported major.minor version 51.0" --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a1140c..4c46251 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,6 @@ addons: hostname: myshorthost language: java jdk: - - openjdk6 -install: "mvn clean -B -X" + - openjdk7 +install: "mvn clean -B" From 79b8e216d28f033e96003690bb7bba92c37048d0 Mon Sep 17 00:00:00 2001 From: Artem Fedorov Date: Tue, 8 Aug 2017 16:50:23 +0300 Subject: [PATCH 16/16] add test --- .../metrics/PerfMonMetricsCreatorImplTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImplTest.java b/test/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImplTest.java index d350785..c53eebc 100644 --- a/test/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImplTest.java +++ b/test/kg/apc/perfmon/metrics/PerfMonMetricsCreatorImplTest.java @@ -48,4 +48,17 @@ public final void testGetMetricProviderError() { assertEquals(RuntimeException.class, catched.getClass()); } + public final void testNoExec() { + PerfMonMetricsCreatorImpl getter = new PerfMonMetricsCreatorImpl(); + System.out.println("no-exec"); + String metricType = "exec"; + String metricParams = ""; + SigarProxy sigarProxy = SigarProxyCache.newInstance(new Sigar(), 500); + MetricParamsSigar metricParamsSigar = MetricParamsSigar.createFromString(metricParams, sigarProxy); + AbstractPerfMonMetric result = getter.getMetricProvider(metricType, metricParamsSigar, sigarProxy, true); + assertNotNull(result); + assertEquals(InvalidPerfMonMetric.class, result.getClass()); + } + + }