This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
191 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,29 @@ | ||
language: python | ||
python: "2.7" | ||
|
||
services: | ||
- rabbitmq | ||
- redis | ||
|
||
env: | ||
global: | ||
- PTERO_PETRI_HOST=localhost | ||
- PTERO_PETRI_PORT=5000 | ||
- PTERO_FORK_HOST=localhost | ||
- PTERO_FORK_PORT=6000 | ||
- PTERO_PETRI_HOME=ptero-petri | ||
- PTERO_FORK_HOME=ptero-shell-command-fork | ||
|
||
install: pip install tox gunicorn git+https://github.com/nickstenning/honcho.git | ||
install: pip install tox | ||
|
||
before_script: | ||
- sudo rabbitmq-plugins disable rabbitmq_management | ||
- git clone --depth 1 https://github.com/mark-burnett/ptero-petri.git | ||
- pushd ptero-petri | ||
- git --no-pager show -s | ||
- pip install -r requirements.txt | ||
- python setup.py install | ||
- PTERO_CONFIG_PATH=config ptero configure-rabbitmq | ||
- honcho start --port 5000 > /dev/null & | ||
- popd | ||
|
||
- git clone --depth 1 https://github.com/mark-burnett/ptero-shell-command-fork.git | ||
- pushd ptero-shell-command-fork | ||
- git --no-pager show -s | ||
- pip install -r requirements.txt | ||
- python setup.py install | ||
- honcho start --port 6000 > /dev/null & | ||
- popd | ||
|
||
- sleep 3 | ||
|
||
script: | ||
- tox | ||
|
||
after_success: | ||
- pip install coveralls | ||
- coveralls | ||
|
||
after_script: | ||
- ps -efl > var/log/ps.out | ||
- bash -c 'for f in var/log/*; do echo; echo "============================================"; echo $f; echo "============================================"; cat $f; done' | ||
|
||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
honcho | ||
nose >= 1.3.0 | ||
nose-cov | ||
psutil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import errno | ||
import os | ||
import psutil | ||
import signal | ||
import sys | ||
import time | ||
|
||
|
||
instance = None | ||
|
||
|
||
def mkdir_p(path): | ||
try: | ||
os.makedirs(path) | ||
except OSError as exc: | ||
if exc.errno == errno.EEXIST and os.path.isdir(path): | ||
pass | ||
else: | ||
raise | ||
|
||
|
||
def wait_time(): | ||
if os.environ.get('TRAVIS'): | ||
return 15 | ||
else: | ||
return 3 | ||
|
||
def this_dir(): | ||
return os.path.dirname(__file__) | ||
|
||
def procfile_path(): | ||
return os.path.join(this_dir(), 'scripts', 'Procfile') | ||
|
||
def service_command_line(): | ||
return ['honcho', '-f', procfile_path(), 'start'] | ||
|
||
|
||
def setUp(): | ||
global instance | ||
|
||
logdir = 'var/log' | ||
mkdir_p(logdir) | ||
outlog = open(os.path.join(logdir, 'honcho.out'), 'w') | ||
errlog = open(os.path.join(logdir, 'honcho.err'), 'w') | ||
|
||
if not os.environ.get('SKIP_PROCFILE'): | ||
instance = psutil.Popen(service_command_line(), | ||
shell=False, stdout=outlog, stderr=errlog) | ||
time.sleep(wait_time()) | ||
if instance.poll() is not None: | ||
raise RuntimeError("honcho instance terminated prematurely") | ||
|
||
def signal_processes(processes, sig): | ||
signaled_someone = False | ||
for p in processes: | ||
try: | ||
p.send_signal(sig) | ||
signaled_someone = True | ||
except psutil.NoSuchProcess: | ||
pass | ||
|
||
return signaled_someone | ||
|
||
def get_descendents(): | ||
return psutil.Process(instance.pid).get_children(recursive=True) | ||
|
||
def cleanup(): | ||
descendents = get_descendents() | ||
|
||
instance.send_signal(signal.SIGINT) | ||
try: | ||
instance.wait(timeout=10) | ||
except psutil.TimeoutExpired: | ||
pass | ||
|
||
if not signal_processes(descendents, signal.SIGINT): | ||
return | ||
|
||
time.sleep(3) | ||
signal_processes(descendents, signal.SIGKILL) | ||
|
||
|
||
# NOTE If this doesn't run then honcho will be orphaned... | ||
def tearDown(): | ||
if not os.environ.get('SKIP_PROCFILE'): | ||
cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fork: cd $PTERO_FORK_HOME; honcho start -f tests/scripts/Procfile -c worker=4 | ||
petri: cd $PTERO_PETRI_HOME; honcho start -f tests/scripts/Procfile -c orchestrator=2 | ||
web: PTERO_WORKFLOW_DB_STRING=sqlite:///var/workflow.sqlite tests/scripts/sigterm_wrapper coverage run ptero_workflow/api/wsgi.py --port $PTERO_WORKFLOW_PORT |
Oops, something went wrong.