diff --git a/README.md b/README.md index b5320ec..9246f99 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,131 @@ -## MongoDB Dockerfile - - -This repository contains **Dockerfile** of [MongoDB](http://www.mongodb.org/) for [Docker](https://www.docker.com/)'s [automated build](https://registry.hub.docker.com/u/dockerfile/mongodb/) published to the public [Docker Hub Registry](https://registry.hub.docker.com/). - - -### Base Docker Image - -* [dockerfile/ubuntu](http://dockerfile.github.io/#/ubuntu) - - -### Installation - -1. Install [Docker](https://www.docker.com/). - -2. Download [automated build](https://registry.hub.docker.com/u/dockerfile/mongodb/) from public [Docker Hub Registry](https://registry.hub.docker.com/): `docker pull dockerfile/mongodb` - - (alternatively, you can build an image from Dockerfile: `docker build -t="dockerfile/mongodb" github.com/dockerfile/mongodb`) - - -### Usage - -#### Run `mongod` - - docker run -d -p 27017:27017 --name mongodb dockerfile/mongodb - -#### Run `mongod` w/ persistent/shared directory - - docker run -d -p 27017:27017 -v :/data/db --name mongodb dockerfile/mongodb - -#### Run `mongod` w/ HTTP support - - docker run -d -p 27017:27017 -p 28017:28017 --name mongodb dockerfile/mongodb mongod --rest --httpinterface - -#### Run `mongod` w/ Smaller default file size - - docker run -d -p 27017:27017 --name mongodb dockerfile/mongodb mongod --smallfiles - -#### Run `mongo` - - docker run -it --rm --link mongodb:mongodb dockerfile/mongodb bash -c 'mongo --host mongodb' - -##### Usage with VirtualBox (boot2docker-vm) - -_You will need to set up nat port forwarding with:_ - - VBoxManage modifyvm "boot2docker-vm" --natpf1 "guestmongodb,tcp,127.0.0.1,27017,,27017" - -This will allow you to connect to your mongo container with the standard `mongo` commands. +# MongoDB Dockerfile for Trusted Automated Docker Builds + +import os +import json + +from modules.config import config +from services.escrow_handler import create_job, handle_results, bulk_payout + +def setup_module(module): + + os.environ['PAYLOAD_SAMPLE'] = 'test_manifest.json' + os.environ['RESULT_SAMPLE'] = 'test_results.json' + + # Populate 'test_manifest.json' with mock data required for testing. + with open('test_manifest.json', 'w') as f: + mock_data = { + "Annotations": { + "images": [ + { + "id": 1, + "file_name": "sample1.jpg" + }, + { + "id": 2, + "file_name": "sample2.jpg" + } + ], + "annotations": [ + { + "id": 125686, + "image_id": 1, + "annotator_email": "sergey@hmt.ai", + "label": "Car", + "segmentation_url": "https://s3.hmt.aws.com/0xerdsdasd/annotation/125686/2254", + "bbox": [19.23, 383.18, 314.5, 244.46], + "acceptance_rate": 0.0 + }, + { + "id": 125686, + "image_id": 2, + "annotator_email": "sergey@hmt.ai", + "label": "Car", + "segmentation_url": "https://s3.hmt.aws.com/0xerdsdasd/annotation/125686/2254", + "bbox": [19.23, 383.18, 314.5, 244.46], + "acceptance_rate": 1.0 + }, + ] + } + } + json.dump(mock_data, f) + + # Populate 'test_results.json' with mock data required for testing. + with open('test_results.json', 'w') as f: + mock_data = { + "Annotations": { + "images": [ + { + "id": 1, + "file_name": "sample1.jpg" + }, + { + "id": 2, + "file_name": "sample2.jpg" + } + ], + "annotations": [ + { + "id": 125686, + "image_id": 1, + "annotator_email": "sergey@hmt.ai", + "label": "Car", + "segmentation_url": "https://s3.hmt.aws.com/0xerdsdasd/annotation/125686/2254", + "bbox": [19.23, 383.18, 314.5, 244.46], + "acceptance_rate": 0.0 + }, + { + "id": 125686, + "image_id": 2, + "annotator_email": "sergey@hmt.ai", + "label": "Car", + "segmentation_url": "https://s3.hmt.aws.com/0xerdsdasd/annotation/125686/2254", + "bbox": [19.23, 383.18, 314.5, 244.46], + "acceptance_rate": 1.0 + }, + ] + } + } + json.dump(mock_data, f) + +def teardown_module(module): # Cleanup after tests +os.remove('test_manifest.json') +os.remove('test_results.json') + +def test_escrow_handler(): +escrow_address = '' +escrow_address = create_job() + + assert escrow_address != '' + + result_files = '' + result_files = handle_results(escrow_address) + + assert 'url' in result_files and 'hash' in result_files + assert result_files['url'] != '' and result_files['hash'] != '' + + url = result_files['url'] + url_hash = result_files['hash'] + + payouts = [ + { + # not needed for this test + "mission_id": "1234567", + # this is the address of the wallet that solved the job and is getting rewarded + "public_address": "0x1e35c4D77771A118f7a96378cFb082Fe65da8e3c", + # sample amount to be distributed, it matches the amount put in the escrow to close it + "amount": 1 + } + ] + + receipients = [] + receipients.append(payouts[0]["public_address"]) + + amounts = [] + amounts.append(payouts[0]["amount"]) + + txId = 1 + + result = '' + result = bulk_payout(escrow_address, receipients, amounts, url, url_hash, txId) + + assert result == True