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
5a3d9763
Commit
5a3d9763
authored
9 years ago
by
Robert J. Moore
Browse files
Options
Downloads
Patches
Plain Diff
Fix #284 - Switch to travis starting the test mongod instance.
parent
8b7decb0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.travis.yml
+4
-0
4 additions, 0 deletions
.travis.yml
mongodb/pom.xml
+0
-6
0 additions, 6 deletions
mongodb/pom.xml
mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java
+30
-61
30 additions, 61 deletions
.../src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java
with
34 additions
and
67 deletions
.travis.yml
+
4
−
0
View file @
5a3d9763
...
...
@@ -10,3 +10,7 @@ jdk:
install
:
mvn install -q -DskipTests=true
script
:
mvn test -q
# Services to start for tests.
services
:
-
mongodb
This diff is collapsed.
Click to expand it.
mongodb/pom.xml
+
0
−
6
View file @
5a3d9763
...
...
@@ -42,12 +42,6 @@
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
de.flapdoodle.embed
</groupId>
<artifactId>
de.flapdoodle.embed.mongo
</artifactId>
<version>
1.47.3
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
...
...
This diff is collapsed.
Click to expand it.
mongodb/src/test/java/com/yahoo/ycsb/db/AbstractDBTestCases.java
+
30
−
61
View file @
5a3d9763
...
...
@@ -17,20 +17,21 @@
package
com.yahoo.ycsb.db
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
hamcrest
.
CoreMatchers
.
notNullValue
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assume
.
assumeNoException
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.Socket
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Set
;
import
java.util.Vector
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
...
...
@@ -38,79 +39,47 @@ import com.yahoo.ycsb.ByteArrayByteIterator;
import
com.yahoo.ycsb.ByteIterator
;
import
com.yahoo.ycsb.DB
;
import
de.flapdoodle.embed.mongo.Command
;
import
de.flapdoodle.embed.mongo.MongodExecutable
;
import
de.flapdoodle.embed.mongo.MongodProcess
;
import
de.flapdoodle.embed.mongo.MongodStarter
;
import
de.flapdoodle.embed.mongo.config.ArtifactStoreBuilder
;
import
de.flapdoodle.embed.mongo.config.IMongodConfig
;
import
de.flapdoodle.embed.mongo.config.MongodConfigBuilder
;
import
de.flapdoodle.embed.mongo.config.Net
;
import
de.flapdoodle.embed.mongo.config.RuntimeConfigBuilder
;
import
de.flapdoodle.embed.mongo.distribution.Version
;
import
de.flapdoodle.embed.process.io.directories.FixedPath
;
import
de.flapdoodle.embed.process.runtime.Network
;
/**
* MongoDbClientTest provides runs the basic DB test cases.
* <p>
* The tests will be skipped if MongoDB is not running on port 27017 on the
* local machine. See the README.md for how to get MongoDB running.
* </p>
*/
@SuppressWarnings
(
"boxing"
)
public
abstract
class
AbstractDBTestCases
{
/** The running Mongodb process. */
private
static
MongodProcess
ourMongod
=
null
;
/** The handle to the running server. */
private
static
MongodExecutable
ourMongodExecutable
=
null
;
/** The directory to download the MongoDB executables to. */
private
static
final
File
TMP_DIR
=
new
File
(
"target/mongodb"
);
/** The default port for MongoDB. */
private
static
final
int
MONGODB_DEFAULT_PORT
=
27017
;
/**
* Start a test mongd instance.
* Verifies the mongod process (or some process) is running on port 27017,
* if not the tests are skipped.
*/
@BeforeClass
public
static
void
setUpBeforeClass
()
{
TMP_DIR
.
mkdirs
();
MongodStarter
starter
=
MongodStarter
.
getInstance
(
new
RuntimeConfigBuilder
()
.
defaults
(
Command
.
MongoD
)
.
artifactStore
(
new
ArtifactStoreBuilder
()
.
defaults
(
Command
.
MongoD
)
.
useCache
(
false
)
.
tempDir
(
new
FixedPath
(
TMP_DIR
.
getAbsolutePath
())))
.
build
());
int
port
=
27017
;
// Test if we can connect.
Socket
socket
=
null
;
try
{
IMongodConfig
mongodConfig
=
new
MongodConfigBuilder
()
.
version
(
Version
.
Main
.
PRODUCTION
)
.
net
(
new
Net
(
port
,
Network
.
localhostIsIPv6
())).
build
();
ourMongodExecutable
=
starter
.
prepare
(
mongodConfig
);
ourMongod
=
ourMongodExecutable
.
start
();
// Connect
socket
=
new
Socket
(
InetAddress
.
getLocalHost
(),
MONGODB_DEFAULT_PORT
);
assertThat
(
"Socket is not bound."
,
socket
.
getLocalPort
(),
not
(-
1
));
}
catch
(
IOException
error
)
{
assumeNoException
(
error
);
catch
(
IOException
connectFailed
)
{
assumeNoException
(
"MongoDB is not running. Skipping tests."
,
connectFailed
);
}
}
/**
* Stops the test server.
*/
@AfterClass
public
static
void
tearDownAfterClass
()
{
if
(
ourMongod
!=
null
)
{
ourMongod
.
stop
();
ourMongod
=
null
;
}
if
(
ourMongodExecutable
!=
null
)
{
ourMongodExecutable
.
stop
();
ourMongodExecutable
=
null
;
finally
{
if
(
socket
!=
null
)
{
try
{
socket
.
close
();
}
catch
(
IOException
ignore
)
{
// Ignore.
}
}
socket
=
null
;
}
}
...
...
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