diff options
author | Arthur Martella <arthur.martella.1@att.com> | 2019-03-26 18:02:52 -0400 |
---|---|---|
committer | Tschaen, Brendan <ctschaen@att.com> | 2019-03-27 12:54:33 -0400 |
commit | dd2937cafd226068dbe518d0b706dc4e6fd164ee (patch) | |
tree | c3658ce8519b1b39ba48679c4350f29974be176e /mdbc-server/src/test | |
parent | a40ee886c28bc28db1794792f1fb312b723d48fb (diff) |
Improve commit log and benchmarks
Attempting to reconcile Enrique's change at
https://gerrit.onap.org/r/#/c/82999/ with the current master.
Change-Id: Id669c267e89d185a18d4dfa9a24852ddefcd83eb
Issue-ID: MUSIC-369
Signed-off-by: Arthur Martella <arthur.martella.1@att.com>
Diffstat (limited to 'mdbc-server/src/test')
5 files changed, 46 insertions, 46 deletions
diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/MusicTxDigestTest.java b/mdbc-server/src/test/java/org/onap/music/mdbc/MusicTxDigestTest.java index 11ec272..7f1c0e1 100644 --- a/mdbc-server/src/test/java/org/onap/music/mdbc/MusicTxDigestTest.java +++ b/mdbc-server/src/test/java/org/onap/music/mdbc/MusicTxDigestTest.java @@ -26,7 +26,7 @@ import java.io.IOException; import java.util.HashMap; import org.junit.Test; -import org.onap.music.mdbc.tables.MusicTxDigest; +import org.onap.music.mdbc.tables.MusicTxDigestDaemon; import org.onap.music.mdbc.tables.StagingTable; diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java b/mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java index 291179a..e5a3252 100755 --- a/mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java +++ b/mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java @@ -20,11 +20,8 @@ package org.onap.music.mdbc; import com.datastax.driver.core.*; -import com.datastax.driver.core.exceptions.QueryExecutionException; -import com.datastax.driver.core.exceptions.SyntaxError; import org.onap.music.exceptions.MDBCServiceException; import org.onap.music.exceptions.MusicLockingException; -import org.onap.music.lockingservice.cassandra.CassaLockStore; import org.onap.music.lockingservice.cassandra.MusicLockState; import org.onap.music.logging.EELFLoggerDelegate; import org.onap.music.main.MusicCore; @@ -38,16 +35,12 @@ import java.util.*; import org.onap.music.mdbc.mixins.MusicInterface; import org.onap.music.mdbc.tables.MusicRangeInformationRow; -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.fail; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class TestUtils { private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(TestUtils.class); - public static DatabasePartition createBasicRow(Range range, MusicInterface mixin, String mdbcServerName){ + public static DatabasePartition createBasicRow(Range range, MusicInterface mixin, String mdbcServerName) + throws MDBCServiceException { final UUID uuid = MDBCUtils.generateTimebasedUniqueKey(); List<Range> ranges = new ArrayList<>(); ranges.add(range); @@ -55,21 +48,14 @@ public class TestUtils { MusicRangeInformationRow newRow = new MusicRangeInformationRow(uuid,dbPartition, new ArrayList<>(), "", mdbcServerName, true); DatabasePartition partition=null; - try { - partition = mixin.createMusicRangeInformation(newRow); - } catch (MDBCServiceException e) { - fail("failure when creating new row"); - } + partition = mixin.createMusicRangeInformation(newRow); return partition; } - public static void unlockRow(String keyspace, String mriTableName, DatabasePartition partition){ + public static void unlockRow(String keyspace, String mriTableName, DatabasePartition partition) + throws MusicLockingException { String fullyQualifiedMriKey = keyspace+"."+ mriTableName+"."+partition.getMRIIndex().toString(); - try { - MusicLockState musicLockState = MusicCore.voluntaryReleaseLock(fullyQualifiedMriKey, partition.getLockId()); - } catch (MusicLockingException e) { - fail("failure when releasing lock"); - } + MusicLockState musicLockState = MusicCore.voluntaryReleaseLock(fullyQualifiedMriKey, partition.getLockId()); } public static void createKeyspace(String keyspace, Session session) { @@ -78,15 +64,7 @@ public class TestUtils { " WITH REPLICATION " + "= {'class':'SimpleStrategy', 'replication_factor':1}; "; ResultSet res=null; - try { - res = session.execute(queryOp); - } - catch(QueryExecutionException e){ - fail("Failure executing creation of keyspace with error: " + e.getMessage()); - } catch(SyntaxError e){ - fail("Failure executing creation of keyspace with syntax error: " + e.getMessage()); - } - assertTrue("Keyspace "+keyspace+" is already being used, please change it to avoid loosing data",res.wasApplied()); + res = session.execute(queryOp); } public static void deleteKeyspace(String keyspace, Session session){ @@ -94,7 +72,6 @@ public class TestUtils { keyspace + ";"; ResultSet res = session.execute(queryBuilder); - assertTrue("Keyspace "+keyspace+" doesn't exist and it should",res.wasApplied()); } public static HashSet<String> getMriColNames(){ @@ -109,14 +86,18 @@ public class TestUtils { ); } - public static HashMap<String, DataType> getMriColTypes(Cluster cluster){ + public static HashMap<String, DataType> getMriColTypes(Cluster cluster) throws Exception { HashMap<String, DataType> expectedTypes = new HashMap<>(); expectedTypes.put("rangeid",DataType.uuid()); expectedTypes.put("keys",DataType.set(DataType.text())); ProtocolVersion currentVer = cluster.getConfiguration().getProtocolOptions().getProtocolVersion(); - assertNotNull("Protocol version for cluster is invalid", currentVer); + if(currentVer != null) { + throw new Exception("Protocol version for cluster is invalid"); + } CodecRegistry registry = cluster.getConfiguration().getCodecRegistry(); - assertNotNull("Codec registry for cluster is invalid", registry); + if(registry!= null) { + throw new Exception("Codec registry for cluster is invalid"); + } expectedTypes.put("txredolog",DataType.list(TupleType.of(currentVer,registry,DataType.text(),DataType.uuid()))); expectedTypes.put("ownerid",DataType.text()); expectedTypes.put("metricprocessid",DataType.text()); @@ -131,15 +112,19 @@ public class TestUtils { } public static void checkDataTypeForTable(List<ColumnMetadata> columnsMeta, HashSet<String> expectedColumns, - HashMap<String,DataType> expectedTypes){ + HashMap<String,DataType> expectedTypes) throws Exception { for(ColumnMetadata cMeta : columnsMeta){ String columnName = cMeta.getName(); DataType type = cMeta.getType(); - assertTrue("Invalid column name: "+columnName,expectedColumns.contains(columnName)); - assertTrue("Fix the contents of expectedtypes for column: "+columnName, - expectedTypes.containsKey(columnName)); - assertEquals("Invalid type for column: "+columnName, - expectedTypes.get(columnName),type); + if(!expectedColumns.contains(columnName)){ + throw new Exception("Invalid column name: "); + } + if(!expectedTypes.containsKey(columnName)){ + throw new Exception("Fix the contents of expectedtypes for column: "+columnName); + } + if(expectedTypes.get(columnName)!=type) { + throw new Exception("Invalid type for column: "+columnName); + } } } diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/mixins/MusicMixinTest.java b/mdbc-server/src/test/java/org/onap/music/mdbc/mixins/MusicMixinTest.java index e8b7511..aba8cb4 100644 --- a/mdbc-server/src/test/java/org/onap/music/mdbc/mixins/MusicMixinTest.java +++ b/mdbc-server/src/test/java/org/onap/music/mdbc/mixins/MusicMixinTest.java @@ -122,8 +122,18 @@ public class MusicMixinTest { // Range range = new Range("TABLE1"); // List<Range> ranges = new ArrayList<>(); // ranges.add(range); -// final DatabasePartition partition = TestUtils.createBasicRow(range, mixin, mdbcServerName); -// TestUtils.unlockRow(keyspace,mriTableName,partition); +// DatabasePartition partition=null; +// try { +// partition = TestUtils.createBasicRow(range, mixin, mdbcServerName); +// } +// catch(Exception e){ +// fail(e.getMessage()); +// } +// try { +// TestUtils.unlockRow(keyspace,mriTableName,partition); +// } catch (MusicLockingException e) { +// fail(e.getMessage()); +// } // // DatabasePartition currentPartition = new DatabasePartition(MDBCUtils.generateTimebasedUniqueKey()); // try { @@ -229,7 +239,6 @@ public class MusicMixinTest { // assertFalse(node3Row.getIsLatest()); // } - @Test public void relinquish() { } diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpointTest.java b/mdbc-server/src/test/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpointTest.java index 7db973c..eb01bcd 100644 --- a/mdbc-server/src/test/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpointTest.java +++ b/mdbc-server/src/test/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpointTest.java @@ -149,6 +149,7 @@ public class OwnershipAndCheckpointTest { Properties properties = new Properties(); properties.setProperty(MusicMixin.KEY_MY_ID,mdbcServerName); properties.setProperty(MusicMixin.KEY_MUSIC_NAMESPACE,keyspace); + properties.setProperty(MusicMixin.KEY_MUSIC_RFACTOR,"1"); //StateManager stateManager = new StateManager("dbUrl", properties, "serverName", "dbName"); ownAndCheck = new OwnershipAndCheckpoint(); musicMixin =new MusicMixin(stateManager, mdbcServerName,properties); @@ -175,7 +176,12 @@ public class OwnershipAndCheckpointTest { TxCommitProgress progressKeeper = new TxCommitProgress(); progressKeeper.createNewTransactionTracker(id ,this.conn); musicMixin.commitLog(partition, null, stagingTable, id, progressKeeper); - TestUtils.unlockRow(keyspace,mriTableName,partition); + try { + TestUtils.unlockRow(keyspace, mriTableName, partition); + } + catch(Exception e){ + fail(e.getMessage()); + } } private OwnershipReturn cleanAndOwnPartition(List<Range> ranges, UUID ownOpId) throws SQLException { @@ -265,4 +271,4 @@ public class OwnershipAndCheckpointTest { private void cleanAlreadyApplied(OwnershipAndCheckpoint ownAndCheck) { ownAndCheck.getAlreadyApplied().clear(); } -}
\ No newline at end of file +} diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/query/QueryProcessorTest.java b/mdbc-server/src/test/java/org/onap/music/mdbc/query/QueryProcessorTest.java index 63147e3..e39cc95 100644 --- a/mdbc-server/src/test/java/org/onap/music/mdbc/query/QueryProcessorTest.java +++ b/mdbc-server/src/test/java/org/onap/music/mdbc/query/QueryProcessorTest.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.List; import org.apache.calcite.sql.parser.SqlParseException; import org.junit.Test; -import org.onap.music.mdbc.tables.MusicTxDigest; +import org.onap.music.mdbc.tables.MusicTxDigestDaemon; import org.onap.music.mdbc.tables.StagingTable; |