Coder Social home page Coder Social logo

joelittlejohn / lein-embongo Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 33 KB

Leiningen plugin for running 'embedded' MongoDB

Home Page: https://clojars.org/lein-embongo

License: Eclipse Public License 1.0

Clojure 100.00%
clojure lein mongodb embedded integration-testing

lein-embongo's Introduction

lein-embongo (emb[edded m]ongo)

A Leiningen 2 plugin to run an 'embedded' instance of MongoDB during a build (e.g. for integration testing).

The Mongo instance isn't strictly embedded (it's not running within the JVM of your application or lein), but it is a managed instance that exists only for the lifetime of your build.

Usage

Add [lein-embongo "0.2.3"] to the :plugins vector of your project.clj.

Invoke the embongo task, providing the name of some other task that should be run after starting MongoDB, e.g.

$ lein embongo test

Once the task is complete, MongoDB will be stopped.

If for some reason you'd like lein to start the embedded mongo instance and wait, you can invoke the embongo task without providing any further tasks, like:

$ lein embongo

When you want to stop MongoDB just press Ctrl+C.

Additional config

There are a few optional config parameters that control how MongoDB runs:

(defproject my-project "1.0.0-SNAPSHOT"
  :plugins [[lein-embongo "0.2.3"]]
  :embongo {:port 37017 ;optional, default 27017
            :version "2.1.1" ;optional, default 2.4.3
            :data-dir "/tmp/mongo-data-files" ;optional, default is a new dir in java.io.tmpdir
            :download-proxy-host "proxy.mycompany.com" ;optional, default is none
            :download-proxy-port 8080} ;optional, default 80

Notes

  • All mongod output appears in ./embongo.log
  • If you want to run many lein builds in parallel using Jenkins, try the Port Allocator Plugin to avoid port conflicts. If you assign a port to $MONGO_PORT, you can set the :port config option for embongo like:
(defproject my-project "1.0.0-SNAPSHOT"
  :embongo {
  :port ~(Integer. (get (System/getenv) "MONGO_PORT" 27017)) ;uses port 27017 if env var is not set
  ...

License

Copyright © 2017 Joe Littlejohn

Distributed under the Eclipse Public License, the same as Clojure.

lein-embongo's People

Contributors

joelittlejohn avatar minhtuannguyen avatar minhtuannguyen6868 avatar msgodf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

msgodf

lein-embongo's Issues

Large amount of stdout with no way to switch it off

using lein embongo midje, I get about 100x more output from embongo than from midje. And worse, the outputs are interleaved which makes it hard to read. Ideally I'd like a config option to silence embongo completely.

Add support for no-args invocation

So a normal invocation looks like:

$ lein embongo test

and omitting the task produces:

$ lein embongo
Wrong number of arguments to embongo task. 
Expected ()

It would be nice if no-args invocation just ran mongo and waited.

Migrate to refactored embedmongo 1.19 API

As you can see, there is a lot of refactoring in embedmongo project trunk. If you want to switch to a new Version you may need help. Feel free to ask any questions.

Michael:)

Occasional "subprocess failed"

I'm running lein embongo from within Jenkins. Occasionally it succeeds, though frequently it fails with nothing more than "Subprocess failed". Here's a snippet:

  • lein with-profile integration embongo midje :config .midje.clj .midje-junitxml.clj
    Performing task 'embongo' with profile(s): 'integration'
    Oct 1, 2013 1:57:12 PM de.flapdoodle.embed.process.store.ArtifactStoreBuilder build
    SEVERE: Build ArtifactStore(useCache:true)
    Extract /root/.embedmongo/linux/mongodb-linux-x86_64-2.4.5.tgz START
    Extract /root/.embedmongo/linux/mongodb-linux-x86_64-2.4.5.tgz DONE
    Oct 1, 2013 1:58:22 PM de.flapdoodle.embed.mongo.AbstractMongoProcess stop
    INFO: try to stop mongod
    Oct 1, 2013 1:58:22 PM de.flapdoodle.embed.process.io.file.Files forceDelete
    INFO: Could delete /tmp/embedmongo-db-f74d8607-cb2b-4a20-b94c-6cf676ec5187
    Error encountered performing task 'embongo' with profile(s): 'integration'
    Subprocess failed
    Build step 'Execute shell' marked build as failure

The embongo.log output looks clean:

[mongod output] Tue Oct 1 10:01:10.320 [conn105] closing listening socket: 8
[mongod output] Tue Oct 1 10:01:10.320 [conn105] removing socket file: /tmp/mongodb-37017.sock
[mongod output] Tue Oct 1 10:01:10.320 [conn105] shutdown: going to flush diaglog...
[mongod output] Tue Oct 1 10:01:10.320 [conn105] shutdown: going to close sockets...
[mongod output] Tue Oct 1 10:01:10.320 [conn105] shutdown: waiting for fs preallocator...
[mongod output] Tue Oct 1 10:01:10.320 [conn105] shutdown: closing all files...
[mongod output] Tue Oct 1 10:01:10.328 [conn105] closeAllFiles() finished
[mongod output] Tue Oct 1 10:01:10.328 [conn105] shutdown: removing fs lock...
[mongod output] Tue Oct 1 10:01:10.329 dbexit: really exiting now

I know that the "Subprocess failed" message comes from lein, and that more than likely there's not much you can do about this. However, I'm wondering if you have seen this or could otherwise shed insight on what might cause this. I see no other logs to indicate what else might be erroring, and "Subprocess failed" doesn't mean much.

Any ideas?

Thanks much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.