Skip to content

Commit

Permalink
Docker files for Parity and additional coverage testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jensenbox committed Sep 26, 2017
1 parent cc6f79d commit 65085ee
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 85 deletions.
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
.DS_Store
*.egg-info/
.tox/
local
local/
.cache
node_modules/
.idea
__pycache__/
agent/src/sn_agent_ui/static/vendor/
/geth-data/
/parity-data/
/agent-data/
/agent-web-data/
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ services:
- docker

script:
- ./tools.sh test

after_success:
- coveralls
- docker-compose run agent travis-test
6 changes: 0 additions & 6 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion .coveragerc → agent/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ exclude_lines =
ignore_errors = True

[html]
directory = coverage_html_report
directory = /data/coverage_html_report

File renamed without changes.
1 change: 1 addition & 0 deletions agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM python:3

ENV PYTHONUNBUFFERED 1

WORKDIR /data
WORKDIR /code

ADD requirements.txt /code
Expand Down
4 changes: 2 additions & 2 deletions agent/docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = SingularityNETAgent
SOURCEDIR = .
BUILDDIR = _build
BUILDDIR = /data/html_docs

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 2 additions & 0 deletions agent/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ requests
pytest
pytest-cov
python-coveralls

sphinx
37 changes: 37 additions & 0 deletions agent/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset

function run_tests {
py.test --verbose --cov-config .coveragerc --cov-report html --cov=sn_agent tests
}

case "$1" in

noop)
;;

run)
python agent.py
;;

docs)
cd docs
make html
;;

test)
run_tests
;;

travis-test)
run_tests
coveralls
;;

*) echo 'No operation specified'
exit 0;
;;

esac
43 changes: 31 additions & 12 deletions agent/sn_agent/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,51 @@


def setup_logging():
DEFAULT_LOGGING = {
_logging = {
'version': 1,
'disable_existing_loggers': False,
'disable_existing_loggers': True,

'root': {
'level': 'WARNING',
'handlers': ['console'],
},

'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
}
'format': '[%(asctime)s][%(levelname)s] %(name)s %(filename)s:%(funcName)s:%(lineno)d | %(message)s',
'datefmt': '%H:%M:%S',
},
},

'handlers': {
'default': {
'console': {
'level': 'DEBUG',
'formatter': 'standard',
'class': 'logging.StreamHandler',
'formatter': 'standard'
},
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'standard',
'filename': 'app.log'
},
},

'loggers': {

'': {
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': False,
},

'sn_agent': {
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': False,
},
},
'root': {
'handlers': ['default'],
'level': 'DEBUG',
},
}
}
logging.config.dictConfig(DEFAULT_LOGGING)

logging.config.dictConfig(_logging)

76 changes: 32 additions & 44 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,49 @@ services:
environment:
- SN_AGENT_ID=b545478a-971a-48ec-bc56-4b9b7176799c
- SN_SERVICE_ADAPTER_CONFIG_FILE=service_adapter_config_example.yml
working_dir: /code
command: python agent.py
- PYTHONPATH=/code
ports:
- "8000:8000"
links:
- geth

agent-test:
build: agent
environment:
- SN_AGENT_ID=b545478a-971a-48ec-bc56-4b9b7176799c
- SN_SERVICE_ADAPTER_CONFIG_FILE=service_adapter_config_example.yml
- PYTHONPATH=/code
volumes:
- ./agent-data:/data
working_dir: /code
entrypoint: py.test --cov=sn_agent tests
# command: coveralls
# agent-docs:
# build: agent
# environment:
# - SN_AGENT_ID=b545478a-971a-48ec-bc56-4b9b7176799c
# - SN_SERVICE_ADAPTER_CONFIG_FILE=service_adapter_config_example.yml
# working_dir: /code
# entrypoint: sphinx-build
entrypoint: ./run.sh
command: noop

agent-web:
build: agent-web
ports:
- "8080:8080"
links:
- agent
environment:
- SN_WEB_COOKIE_SECRET=kubr6DvIuYj4GREdgXq5CCoL5qHQWglj8IECTsI79mY=
command: python agent-web.py
entrypoint: ./run.sh
command: noop

geth:
build: geth
ports:
- "8545:8545"
- "8546:8546"
- "30303:30303"
volumes:
- ./geth-data:/geth-data
command: geth --datadir=/geth-data --metrics --shh --rpc --rpcaddr 0.0.0.0 --ws --wsaddr 0.0.0.0 --nat none --verbosity 5 --vmdebug --dev --maxpeers 0 --gasprice 0 --debug --pprof
deploy:
resources:
limits:
cpus: '0.001'
memory: 50M
reservations:
cpus: '0.0001'
memory: 20M
# geth:
# build: geth
# ports:
# - "8545:8545"
# - "8546:8546"
# - "30303:30303"
# volumes:
# - ./geth-data:/geth-data
# entrypoint: ./run.sh
# command: noop
# deploy:
# resources:
# limits:
# cpus: '0.001'
# memory: 50M
# reservations:
# cpus: '0.0001'
# memory: 20M

# parity:
# build: parity

truffle:
build: truffle
entrypoint: truffle
# entrypoint: ./run.sh
# command: noop
#
# truffle:
# build: truffle
# entrypoint: ./run.sh
# command: noop
3 changes: 3 additions & 0 deletions geth/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

geth --datadir=/geth-data --metrics --shh --rpc --rpcaddr 0.0.0.0 --ws --wsaddr 0.0.0.0 --nat none --verbosity 5 --vmdebug --dev --maxpeers 0 --gasprice 0 --debug --pprof
10 changes: 2 additions & 8 deletions parity/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
FROM parity
FROM parity/parity:stable

ENV DEBIAN_FRONTEND noninteractive

RUN \
apt-get update && \
apt-get -y -qq dist-upgrade && \
apt-get -y -qq install software-properties-common && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
bash <(curl https://get.parity.io -L)
RUN ls -lar
22 changes: 22 additions & 0 deletions parity/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -o errexit
set -o verbose
set -o xtrace
set -o nounset

case "$1" in

run)
ls -lar
;;

--help)
echo 'Executing in the default context, specify "run" to actually execute'
;;

*) echo 'No operation specified'
exit 0;
;;

esac
7 changes: 4 additions & 3 deletions tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ create-web-cookie)
;;

docs)
docker-compose run agent-docs
docker-compose create --build --force-recreate agent
docker-compose run agent docs
;;

test)
docker-compose create --build --force-recreate agent-test
docker-compose run agent-test
docker-compose create --build --force-recreate agent
docker-compose run agent test
;;

*) echo 'No operation specified'
Expand Down

0 comments on commit 65085ee

Please sign in to comment.