use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class VoltDBClientTest method insertDeleteAndReadTest.
@Test
public void insertDeleteAndReadTest() {
Assume.assumeTrue(haveDb);
try {
// Create some test data
final String insertKey = INSERT_DELETE_AND_READ_TEST_KEY;
final Set<String> columns = getColumnNameMap();
// Insert row
HashMap<String, ByteIterator> insertMap = new HashMap<String, ByteIterator>();
for (int i = 0; i < NUM_FIELDS; i++) {
insertMap.put(FIELD_PREFIX + i, new StringByteIterator(buildDeterministicValue(insertKey, FIELD_PREFIX + i)));
}
voltClient.insert(TABLE_NAME, insertKey, insertMap);
// Create a object to put retrieved row in...
Map<String, ByteIterator> testResult = new HashMap<String, ByteIterator>();
// Read row...
Status s = voltClient.read(TABLE_NAME, insertKey, columns, testResult);
if (!s.equals(Status.OK)) {
fail("Didn't get OK on read.");
}
if (!compareContents(insertMap, testResult)) {
fail("Returned data not the same as inserted data");
}
voltClient.delete(TABLE_NAME, insertKey);
// Create another object to put retrieved row in...
Map<String, ByteIterator> testResultAfterDelete = new HashMap<String, ByteIterator>();
// Read row...
voltClient.read(TABLE_NAME, insertKey, columns, testResultAfterDelete);
if (testResultAfterDelete.size() > 0) {
fail("testResultAfterDelete has value.");
}
} catch (Exception e) {
e.printStackTrace();
fail("Failed insertDeleteAndReadTest");
}
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class VoltDBClientTest method singleScanReadTest.
private void singleScanReadTest(String startKey, int requestedCount, int expectedCount, String lastKey) {
Assume.assumeTrue(haveDb);
try {
final Set<String> columns = getColumnNameMap();
// Create a object to put retrieved row in...
Vector<HashMap<String, ByteIterator>> testResult = new Vector<HashMap<String, ByteIterator>>();
// Read row...
Status s = voltClient.scan(TABLE_NAME, startKey, expectedCount, columns, testResult);
if (!s.equals(Status.OK)) {
fail("Didn't get OK on read.");
}
if (testResult.size() != expectedCount) {
fail("Failed singleScanReadTest " + startKey + " " + expectedCount + " " + lastKey);
}
} catch (Exception e) {
e.printStackTrace();
fail("Failed singleScanReadTest " + startKey + ". Asked for " + requestedCount + ", expected " + expectedCount + " lastkey=" + lastKey);
}
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class VoltDBClientTest method updateTest.
@Test
public void updateTest() {
Assume.assumeTrue(haveDb);
try {
// Create some test data
final String insertKey = UPDATE_TEST_KEY;
// Insert row
// Insert row
HashMap<String, ByteIterator> insertThenUpdateMap = new HashMap<String, ByteIterator>();
for (int i = 0; i < NUM_FIELDS; i++) {
insertThenUpdateMap.put(FIELD_PREFIX + i, new StringByteIterator(buildDeterministicValue(insertKey, FIELD_PREFIX + i)));
}
voltClient.insert(TABLE_NAME, insertKey, insertThenUpdateMap);
// Change the data we inserted...
for (int i = 0; i < NUM_FIELDS; i++) {
insertThenUpdateMap.put(FIELD_PREFIX + i, new StringByteIterator(FIELD_PREFIX + i + " has changed"));
}
// now do an update
voltClient.update(TABLE_NAME, insertKey, insertThenUpdateMap);
// Create a object to put retrieved row in...
final Set<String> columns = getColumnNameMap();
Map<String, ByteIterator> testResult = new HashMap<String, ByteIterator>();
// Read row...
Status s = voltClient.read(TABLE_NAME, insertKey, columns, testResult);
if (!s.equals(Status.OK)) {
fail("Didn't get OK on read.");
}
if (!compareContents(insertThenUpdateMap, testResult)) {
fail("Returned data not the same as inserted data");
}
} catch (Exception e) {
e.printStackTrace();
fail("Failed updateTest");
}
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class SolrClientBaseTest method testRead.
@Test
public void testRead() throws Exception {
Set<String> fields = MOCK_DATA.keySet();
HashMap<String, ByteIterator> resultParam = new HashMap<>(NUM_RECORDS);
Status result = instance.read(MOCK_TABLE, MOCK_KEY1, fields, resultParam);
assertEquals(Status.OK, result);
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class ScyllaCQLClientTest method testUpdate.
@Test
public void testUpdate() {
insertRow();
final Map<String, String> input = new HashMap<>();
input.put("field0", "new-value1");
input.put("field1", "new-value2");
final Status status = client.update(TABLE, DEFAULT_ROW_KEY, StringByteIterator.getByteIteratorMap(input));
assertThat(status, is(Status.OK));
// Verify result
final Select selectStmt = QueryBuilder.select("field0", "field1").from(TABLE).where(QueryBuilder.eq(ScyllaCQLClient.YCSB_KEY, DEFAULT_ROW_KEY)).limit(1);
final ResultSet rs = session.execute(selectStmt);
final Row row = rs.one();
assertThat(row, notNullValue());
assertThat(rs.isExhausted(), is(true));
assertThat(row.getString("field0"), is("new-value1"));
assertThat(row.getString("field1"), is("new-value2"));
}
Aggregations