Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
d53f3b33
Commit
d53f3b33
authored
8 years ago
by
Jaemyoun
Browse files
Options
Downloads
Patches
Plain Diff
Add Test code
parent
5693bec8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rados/pom.xml
+9
-3
9 additions, 3 deletions
rados/pom.xml
rados/src/test/java/com/yahoo/ycsb/db/RadosClientTest.java
+142
-0
142 additions, 0 deletions
rados/src/test/java/com/yahoo/ycsb/db/RadosClientTest.java
with
151 additions
and
3 deletions
rados/pom.xml
+
9
−
3
View file @
d53f3b33
...
...
@@ -43,9 +43,15 @@ LICENSE file.
</dependency>
<dependency>
<groupId>
org.json
</groupId>
<artifactId>
json
</artifactId>
<version>
${json.version}
</version>
</dependency>
<artifactId>
json
</artifactId>
<version>
${json.version}
</version>
</dependency>
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<version>
6.1.1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<properties>
...
...
This diff is collapsed.
Click to expand it.
rados/src/test/java/com/yahoo/ycsb/db/RadosClientTest.java
0 → 100644
+
142
−
0
View file @
d53f3b33
/**
* Copyright (c) 2016 YCSB contributors. All rights reserved.
*
* 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
static
org
.
testng
.
AssertJUnit
.
assertEquals
;
import
com.yahoo.ycsb.ByteIterator
;
import
com.yahoo.ycsb.DBException
;
import
com.yahoo.ycsb.Status
;
import
com.yahoo.ycsb.StringByteIterator
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.AfterMethod
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.UUID
;
/**
* Test for the binding of <a href="http://ceph.org/">RADOS of Ceph</a>.
*
* See {@code rados/README.md} for details.
*/
public
class
RadosClientTest
{
private
static
RadosClient
radosclient
;
public
static
final
String
POOL_PROPERTY
=
"rados.pool"
;
public
static
final
String
POOL_TEST
=
"rbd"
;
private
static
final
String
TABLE_NAME
=
"table0"
;
private
static
final
String
KEY0
=
"key0"
;
private
static
final
String
KEY1
=
"key0"
;
private
static
final
HashMap
<
String
,
ByteIterator
>
DATA
;
static
{
DATA
=
new
HashMap
<
String
,
ByteIterator
>(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
DATA
.
put
(
"key"
+
UUID
.
randomUUID
(),
new
StringByteIterator
(
"data"
+
UUID
.
randomUUID
()));
}
}
@BeforeClass
public
void
setupClass
()
throws
DBException
{
radosclient
=
new
RadosClient
();
Properties
p
=
new
Properties
();
p
.
setProperty
(
POOL_PROPERTY
,
POOL_TEST
);
radosclient
.
setProperties
(
p
);
radosclient
.
init
();
}
@AfterClass
public
void
teardownClass
()
throws
DBException
{
if
(
radosclient
!=
null
)
{
radosclient
.
cleanup
();
}
}
@BeforeMethod
public
void
setUp
()
{
radosclient
.
insert
(
TABLE_NAME
,
KEY0
,
DATA
);
}
@AfterMethod
public
void
tearDown
()
{
radosclient
.
delete
(
TABLE_NAME
,
KEY0
);
}
@Test
public
void
insertTest
()
{
Status
result
=
radosclient
.
insert
(
TABLE_NAME
,
KEY1
,
DATA
);
assertEquals
(
Status
.
OK
,
result
);
}
@Test
public
void
updateTest
()
{
HashMap
<
String
,
ByteIterator
>
newDATA
=
new
HashMap
<
String
,
ByteIterator
>(
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
newDATA
.
put
(
"key"
+
UUID
.
randomUUID
(),
new
StringByteIterator
(
"new data"
+
UUID
.
randomUUID
()));
}
Status
result
=
radosclient
.
update
(
TABLE_NAME
,
KEY0
,
newDATA
);
assertEquals
(
Status
.
OK
,
result
);
HashMap
<
String
,
ByteIterator
>
ret
=
new
HashMap
<
String
,
ByteIterator
>(
10
);
radosclient
.
read
(
TABLE_NAME
,
KEY0
,
DATA
.
keySet
(),
ret
);
compareMap
(
ret
);
}
@Test
public
void
readTest
()
{
HashMap
<
String
,
ByteIterator
>
ret
=
new
HashMap
<
String
,
ByteIterator
>(
10
);
Status
result
=
radosclient
.
read
(
TABLE_NAME
,
KEY0
,
DATA
.
keySet
(),
ret
);
assertEquals
(
Status
.
OK
,
result
);
compareMap
(
ret
);
}
private
void
compareMap
(
HashMap
<
String
,
ByteIterator
>
ret
)
{
Set
setDATA
=
DATA
.
entrySet
();
Set
setReturn
=
ret
.
entrySet
();
Iterator
itDATA
=
setDATA
.
iterator
();
Iterator
itReturn
=
setReturn
.
iterator
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Map
.
Entry
entryDATA
=
(
Map
.
Entry
)
itDATA
.
next
();
Map
.
Entry
entryReturn
=
(
Map
.
Entry
)
itReturn
.
next
();
assertEquals
(
entryDATA
.
getKey
(),
entryReturn
.
getKey
());
assertEquals
(
entryDATA
.
getValue
(),
entryReturn
.
getValue
());
}
}
@Test
public
void
deleteTest
()
{
Status
result
=
radosclient
.
delete
(
TABLE_NAME
,
KEY0
);
assertEquals
(
Status
.
OK
,
result
);
}
}
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