Mercurial > stress-tester
changeset 1054:a8dda9af38cf
PgSqlMetricTest
author | Devel 2 |
---|---|
date | Wed, 15 Apr 2020 11:08:13 +0200 |
parents | 6b8d78ecdeba |
children | 2f945e8445a0 |
files | stress-tester/src/test/java/com/passus/st/client/pgsql/PgSqlMetricTest.java |
diffstat | 1 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/test/java/com/passus/st/client/pgsql/PgSqlMetricTest.java Wed Apr 15 11:08:13 2020 +0200 @@ -0,0 +1,33 @@ +package com.passus.st.client.pgsql; + +import org.apache.commons.lang3.mutable.MutableInt; +import org.testng.annotations.Test; + +import java.util.Map; + +import static org.testng.Assert.assertEquals; + +public class PgSqlMetricTest { + + @Test + public void testAddQuery() { + PgSqlMetric m = new PgSqlMetric(); + try { + m.activate(); + + m.addQuery("SELECT * from test"); + m.addQuery("select * from test"); + m.addQuery("CREATE USER"); + m.addQuery("CREATE TABLE"); + m.addQuery("start transaction"); + + Map<String, MutableInt> queryTypeCount = m.getQueryTypeCount(); + assertEquals(2, queryTypeCount.get("SELECT").intValue()); + assertEquals(1, queryTypeCount.get("CREATE USER").intValue()); + assertEquals(1, queryTypeCount.get("CREATE TABLE").intValue()); + assertEquals(1, queryTypeCount.get("START TRANSACTION").intValue()); + } finally { + m.deactivate(); + } + } +} \ No newline at end of file