Code Monkey home page Code Monkey logo

xk6-mongo's Introduction

MongoDB k6 extension

K6 extension to perform tests on mongo.

Currently Supported Commands

  • Supports inserting a document.
  • Supports inserting document batch.
  • Supports find a document based on filter.
  • Supports find all documents of a collection.
  • Supports delete first document based on filter.
  • Supports deleting all documents for a specific filter.
  • Supports dropping a collection.

xk6-mongo

A k6 extension for interacting with mongoDb while testing.

Build

To build a custom k6 binary with this extension, first ensure you have the prerequisites:

  1. Download xk6:

    go install go.k6.io/xk6/cmd/xk6@latest
  2. Build the k6 binary:

    xk6 build --with  github.com/tbruccoleri/xk6-mongo

    This will create a k6 binary that includes the xk6-mongo extension in your local folder. This k6 binary can now run a k6 test.

Development

To make development a little smoother, use the Makefile in the root folder. The default target will format your code, run tests, and create a k6 binary with your local code rather than from GitHub.

git clone [email protected]/tbruccoleri/xk6-mongo.git
cd xk6-mongo
make build

Using the k6 binary with xk6-mongo, run the k6 test as usual:

./k6 run test.js

Examples:

Document Insertion Test

import xk6_mongo from 'k6/x/mongo';


const client = xk6_mongo.newClient('mongodb://localhost:27017');
export default ()=> {

    let doc = {
        correlationId: `test--mongodb`,
        title: 'Perf test experiment',
        url: 'example.com',
        locale: 'en',
        time: `${new Date(Date.now()).toISOString()}`
    };

    client.insert("testdb", "testcollection", doc);
}

xk6-mongo's People

Contributors

ghmartingit avatar bhavyagupta3006 avatar prateekkamra avatar samof76 avatar dependabot[bot] avatar thotasrinath avatar mstoykov avatar tbruccoleri avatar

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.