From 0556eea16d2719ac3a5e38ed756d24a37904737e Mon Sep 17 00:00:00 2001 From: Moxious Date: Thu, 14 Mar 2019 12:25:44 -0400 Subject: [PATCH 1/5] dockerfile improvements to permit arg passing --- .dockerignore | 1 + Dockerfile | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/Dockerfile b/Dockerfile index bce8999..d9fb91a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ FROM node:9-alpine MAINTAINER David Allen -COPY src /src -RUN cd src && npm install +RUN mkdir /app +COPY . /app +RUN cd app && npm install ENV NEO4J_URI "bolt://localhost" ENV NEO4J_USER "neo4j" ENV NEO4J_PASSWORD "neo4j" ENV CONCURRENCY "10" -WORKDIR /src -CMD ["node", "workload.js"] +WORKDIR /app +ENTRYPOINT ["/usr/local/bin/node", "/app/src/run-workload.js"] From 18cc8d10cee50e650aee0bac8b50faee9bc14daa Mon Sep 17 00:00:00 2001 From: Moxious Date: Thu, 14 Mar 2019 12:25:48 -0400 Subject: [PATCH 2/5] documentation --- README.md | 73 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index d01a9bb..be2eefa 100644 --- a/README.md +++ b/README.md @@ -10,27 +10,57 @@ reads/writes to execute against a database, while keeping track of execution sta You can run workloads timed (i.e. for 5,000 ms) or numbered (i.e. 5,000 runs). -# Running Stand-Alone +# Usage ``` -yarn install -export NEO4J_USER=neo4j -export NEO4J_PASSWORD=supersecret -export NEO4J_URI=bolt+routing://my-cloud-host:7687 -node src/index.js +Usage: run-workload.js -p password + [-a address] + [-u username] + [-n hits] how many total queries to run + [--ms milliseconds] how many milliseconds to test for + [--workload /path/to/workload.json] probability table spec + [--query CYPHER_QUERY] single cypher query to run + [--concurrency c] how many concurrent queries to run (default: 10) + [--checkpoint cn] how often to print results in milliseconds (default: 5000) + [--fail-fast] if specified, the work will stop after encountering one + failure. + +You may only specify one of the options --n or --ms. +You may only specify one of the options --workload or --query + + +Options: + --help Show help [boolean] + --version Show version number [boolean] + -a address to connect to [default: "localhost"] + -u username [default: "neo4j"] + -p password [required] + -n number of hits on the database + --ms number of milliseconds to execute + --workload absolute path to JSON probability table/workload + --query Cypher query to run + --concurrency [default: 10] + --checkpoint [default: 5000] + +Examples: + run-workload.js -a localhost -u neo4j -p Run 10 hits on the local database + secret -n 10 ``` -Alternatively, you can pass some arguments, like this: +# Run in Docker -``` -export NEO4J_USER=neo4j -export NEO4J_PASSWORD=supersecret -export NEO4J_URI=bolt+routing://my-cloud-host:7687 +Simply pass any arguments the command recognizes to the docker container. -node src/index.js --concurrency 10 --n 20 --workload /path/to/read-workload.json +``` +docker run --tty --interactive mdavidallen/graph-workload:latest -a my-neo4j-host.com -u neo4j -p password 2>&1 ``` -This would run the read workload in batches of 20, with 10 concurrent queries. +# Running Stand-Alone from Source + +``` +yarn install +node src/run-workload.js -a localhost -u neo4j -p password +``` See the `workloads` directory for the format of the probability table. @@ -54,23 +84,10 @@ yarn run test # Building Graph Workloads as a Docker Container ``` -docker build -t graph-workload:latest -f Dockerfile . -``` - -# Running - -``` -docker run \ - -e "NEO4J_URI=bolt://foo-host/" \ - -e "NEO4J_USER=neo4j" \ - -e "NEO4J_PASSWORD=secret" \ - -e "CONCURRENCY=10" \ - graph-workload:latest +docker build -t mdavidallen/graph-workload:latest -f Dockerfile . ``` -# Adjusting Workload - -This is not that friendly or configurable from the outside yet. But essentially: +# Defining your own Custom Workload - Stress tester has a number of 'read strategies' and 'write strategies' - There is a probability table; the stress tester rolls random numbers and picks a strategy From 7d9f746fd882ab9e3cd044e96192ff73b15184ba Mon Sep 17 00:00:00 2001 From: Moxious Date: Thu, 14 Mar 2019 12:27:19 -0400 Subject: [PATCH 3/5] bump v0.3.1 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d8c5b4a..85247c0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "graph-workload", - "version": "0.3.0", - "description": "", + "version": "0.3.1", + "description": "Tool for generating workloads running on Neo4j", "main": "src/run-workload.js", "scripts": { "graph-workload": "node src/run-workload.js", From a0a9f9276da1fcec14a0c9b6f8b9927561663010 Mon Sep 17 00:00:00 2001 From: Moxious Date: Thu, 14 Mar 2019 12:30:15 -0400 Subject: [PATCH 4/5] updated build config for docker builds --- .circleci/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index c9bfc2a..126c9d1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,6 +21,19 @@ jobs: - run: name: test command: yarn run test + - run: + name: Build Docker Container + command: docker build -t mdavidallen/graph-workload:latest -f Dockerfile . + - run: + name: Deploy to Docker Hub + command: | + docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + if [ "${CIRCLE_BRANCH}" = "master" ]; then + echo "Pushing docker image" + docker push mdavidallen/graph-workload:latest + else + echo "Not deploying; not master branch." + fi - store_artifacts: path: test-results.xml prefix: tests From 2a10c69e9ef6bd543fe6c08c132745f8f32057d2 Mon Sep 17 00:00:00 2001 From: Moxious Date: Thu, 14 Mar 2019 12:32:26 -0400 Subject: [PATCH 5/5] setup remote docker --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 126c9d1..916fb1d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,6 +6,7 @@ jobs: - image: circleci/node:10-browsers-legacy steps: - checkout + - setup_remote_docker - restore_cache: name: Restore Yarn Package Cache keys: