npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bucket-service

v1.0.1

Published

Add buckets to tests to easily run subsets of tests.

Readme

Bucket Service

The bucket service is useful for enabling or disabling tests without a code change. It is also useful for running a subset of tests based on which tests are in a specific bucket. This is extremely useful if your pipeline is blocked due to a failing test, but you still want to move forward. Instead of having to make a commit and rebuilding your project, you could use this service to remove that test from running. To get this to work, you will need MongoDB to store all the data.

The purpose of the bucket service is to allow you to run certain tests that are part of a bucket. This also allows you to disable and enable tests without making a code change. For example, you may add the bucket [dt_chrome_regression] to all tests that should run as part of your desktop chrome regression test suite. You can add as many buckets to a test as you like. One test may have [dt_chrome_regression] and [dt_firefox_regression], and another test may have [dt_ie_regression]. This means that you can run all tests with the bucket [dt_chrome_regression], and it would not run the tests without that bucket.

Configuration

The following environment variables are used. Change them if you would like different values.

|Environment Variable|Description |Default | |--------------------|-------------------------------------------------------------------|---------- |BUCKET_MONGOHOST |This is the MongoDB hostname. |localhost| |BUCKET_MONGODB |This is the MongoDB database. |test | |NODE_PORT |This is the port that the bucket service will run on. |8080 |

Requirements

Node.js

We have tested this on Node 8.9.0 and 10.15.0. We use async/await, so you will need at least Node 8 or greater.

MongoDB

You will need at least MongoDB 3.0 or greater. Anything lower is not compatible with the version of Mongoose used and Node.js needed.

All of the data from the bucket service is stored in a MongoDB. To get a MongoDB setup using docker, follow these steps (Requires Docker) :

mkdir ~/data
docker run -d -p 27017:27017 -v ~/data:/data/db mongo

Docker

Docker is not required, however if you would like to use the MongoDB docker image, you will need docker.

Installing Docker

https://docs.docker.com/docker-for-mac/install/
https://docs.docker.com/docker-for-windows/install/
https://docs.docker.com/install/linux/docker-ce/ubuntu/

Start Bucket Service

After starting MongoDB, you can start the bucket service:

npm run cicd-build
npm run start

Bucket Service Usage:

Steps to use bucket service

  1. Create a project in the bucket service ( POST /projects ) See the 1st API request
  2. Add test to the bucket service under a specific project ( POST /projects/{project}/tests ) See the 2nd API request
  3. When running the tests, fetch all tests for desired bucket ( GET /projects/{project}/tests/bucket?q={bucket} ) See the 3rd API request

Calling the bucket service API

Sample in javascript:

  • First npm install axios
const axios = require('axios');
const fs = require('fs');

const bucket_service_url = 'http://localhost:8080';
const project = encodeURIComponent(process.env.PROJECT);
const bucket = encodeURIComponent(process.env.BUCKET);
const uuid = encodeURIComponent(process.env.UUID);

// 1st API request - Creates a project in the bucket service
async function addProject() {
  const projectData = {
    name: project,
    description: 'Example Project Barracuda'
  };
  return axios.post(`${bucket_service_url}/projects`, projectData);
}

// 2nd API request - Adds a test to the project in the bucket service
async function addTest() {
  const testData = {
    bucket: `[${bucket}]`,
    name: 'Example Test Name',
    uuid
  };
  return axios.post(`${bucket_service_url}/projects/${project}/tests`, testData);
}

// 3rd API request - Retrieves all tests in the specified bucket
async function getTests() {
  return axios.get(`${bucket_service_url}/projects/${project}/tests/search/bucket?q=[${bucket}]`);
}

async function main() {
  let r = await addProject();
  console.log(`Response from Adding Project : ${JSON.stringify(r.data, null, 2)}`);
  r = await addTest();
  console.log(`Response from Adding Test : ${JSON.stringify(r.data, null, 2)}`);
  r = await getTests();
  // Write examples to file, to be read by shell script that runs the tests
  let examples = '';
  const tests = r.data.tests;
  console.log(`Response from Get Tests : ${JSON.stringify(tests, null, 2)}`);
  for (let i = 0; i < tests.length; i++) {
    examples += `--example ${tests[i].uuid}`;
  }
  fs.writeFile('examples.txt', examples, function(err) {
    if (err) {
      return console.log(err);
    }
  });
}

main();

Run the above like : PROJECT=Barracuda BUCKET=dt_chrome_regression UUID=test-00001 node <your file name here>.js

See this example in Ruby, Python

Shell script to run ruby tests

#!/bin/bash

BUCKET=dt_chrome_regression PROJECT=Barracuda python3 <your python file name here>.py
EXAMPLES=`cat examples.txt` # Filename from python script above

if [[ ! -z "${EXAMPLES}" ]]; then
  bundle exec rspec spec/features/ ${EXAMPLES} --profile 3 --format documentation --format RspecJunitFormatter --out build/test/results.xml &
  
  chromepid=$!

  wait $chromepid
  chromecode=$?

  if [ $chromecode -ne 0 ]; then
    exit 1
  fi
fi

Run the above like : <your shell script file name here>.sh

Swagger Docs

First start the server then access http://localhost:8080/docs/

GoDaddy Specifics

git clone https://github.com/godaddy/bucket-service.git
cd bucket-service
git remote add internal [email protected]:PC/bucket-service.git

* The bucket service is originally from https://github.com/azweb76/node-test-api/