Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adnan Ahmad
YCSB
Commits
1ff7e2b8
Commit
1ff7e2b8
authored
9 years ago
by
nygard_89
Browse files
Options
Downloads
Patches
Plain Diff
[riak] Added test unit.
parent
6ea3666b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
riak/src/test/java/com/yahoo/ycsb/db/RiakKVClientTest.java
+125
-0
125 additions, 0 deletions
riak/src/test/java/com/yahoo/ycsb/db/RiakKVClientTest.java
with
125 additions
and
0 deletions
riak/src/test/java/com/yahoo/ycsb/db/RiakKVClientTest.java
0 → 100644
+
125
−
0
View file @
1ff7e2b8
/**
* Copyright (c) 2016 YCSB contributors All rights reserved.
* Copyright 2014 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package
com.yahoo.ycsb.db
;
import
java.util.*
;
import
com.yahoo.ycsb.ByteIterator
;
import
com.yahoo.ycsb.Status
;
import
com.yahoo.ycsb.StringByteIterator
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Integration tests for the Riak KV client. All tests are configured to return positive.
*/
public
class
RiakKVClientTest
{
private
static
RiakKVClient
riakClient
;
private
static
String
bucket
=
"testBucket"
;
private
static
String
startKey
=
"testKey"
;
private
static
int
recordsToInitiallyInsert
=
10
;
/**
* Creates a cluster for testing purposes.
*/
@BeforeClass
public
static
void
setUpClass
()
throws
Exception
{
riakClient
=
new
RiakKVClient
();
riakClient
.
init
();
HashMap
<
String
,
String
>
values
=
new
HashMap
<>();
// Just add some random values to work on...
for
(
int
i
=
0
;
i
<
recordsToInitiallyInsert
;
i
++)
{
values
.
put
(
"testRecord_1"
,
"testValue_1"
);
values
.
put
(
"testRecord_2"
,
"testValue_2"
);
riakClient
.
insert
(
bucket
,
startKey
+
String
.
valueOf
(
i
),
StringByteIterator
.
getByteIteratorMap
(
values
));
}
}
/**
* Shuts down the cluster created.
*/
@AfterClass
public
static
void
tearDownClass
()
throws
Exception
{
riakClient
.
cleanup
();
}
/**
* Test method for read transaction.
*/
@Test
public
void
testRead
()
{
Set
<
String
>
fields
=
new
HashSet
<>();
fields
.
add
(
"testRecord_1"
);
fields
.
add
(
"testRecord_2"
);
HashMap
<
String
,
ByteIterator
>
results
=
new
HashMap
<>();
assertEquals
(
Status
.
OK
,
riakClient
.
read
(
bucket
,
startKey
+
"1"
,
fields
,
results
));
}
/**
* Test method for scan transaction.
*/
@Test
public
void
testScan
()
{
Vector
<
HashMap
<
String
,
ByteIterator
>>
results
=
new
Vector
<>();
assertEquals
(
Status
.
OK
,
riakClient
.
scan
(
bucket
,
startKey
+
"1"
,
recordsToInitiallyInsert
-
1
,
null
,
results
));
}
/**
* Test method for update transaction.
*/
@Test
public
void
testUpdate
()
{
HashMap
<
String
,
String
>
values
=
new
HashMap
<>();
values
.
put
(
"testRecord_1"
,
"testValue_1_updated"
);
values
.
put
(
"testRecord_2"
,
"testValue_2_updated"
);
assertEquals
(
Status
.
OK
,
riakClient
.
update
(
bucket
,
startKey
+
"0"
,
StringByteIterator
.
getByteIteratorMap
(
values
)));
}
/**
* Test method for insert transaction.
*/
@Test
public
void
testInsert
()
{
HashMap
<
String
,
String
>
values
=
new
HashMap
<>();
values
.
put
(
"testRecord_1"
,
"testValue_1"
);
values
.
put
(
"testRecord_2"
,
"testValue_2"
);
assertEquals
(
Status
.
OK
,
riakClient
.
insert
(
bucket
,
startKey
+
Integer
.
toString
(
recordsToInitiallyInsert
),
StringByteIterator
.
getByteIteratorMap
(
values
)));
}
/**
* Test method for delete transaction.
*/
@Test
public
void
testDelete
()
{
assertEquals
(
Status
.
OK
,
riakClient
.
delete
(
bucket
,
startKey
+
"0"
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment