diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..e5ace55ada --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,82 @@ +#!groovy + +@Library('SovrinHelpers') _ + +def name = 'plenum' + +def testUbuntu = { + try { + echo 'Ubuntu Test: Checkout csm' + checkout scm + + echo 'Ubuntu Test: Build docker image' + orientdb.start() + + def testEnv = dockerHelpers.build(name) + + testEnv.inside('--network host') { + echo 'Ubuntu Test: Install dependencies' + testHelpers.installDeps() + + echo 'Ubuntu Test: Test' + sh 'python runner.py --pytest \"python -m pytest\" --output "test-result.txt"' + } + } + finally { + echo 'Ubuntu Test: Cleanup' + orientdb.stop() + step([$class: 'WsCleanup']) + } +} + +def testWindows = { + echo 'TODO: Implement me' + + /* win2016 for now (03-23-2017) is not supported by Docker for Windows + * (Hyper-V version), so we can't use linux containers + * https://github.com/docker/for-win/issues/448#issuecomment-276328342 + * + * possible solutions: + * - use host-installed OrientDB (trying this one) + * - wait until Docker support will be provided for win2016 + */ + + //try { + // echo 'Windows Test: Checkout csm' + // checkout scm + + // echo 'Windows Test: Build docker image' + // dockerHelpers.buildAndRunWindows(name, testHelpers.installDepsWindowsCommands() + ["cd C:\\test && python -m pytest -k orientdb --junit-xml=C:\\testOrig\\$testFile"] /*testHelpers.testJunitWindowsCommands()*/) + // junit 'test-result.xml' + //} + //finally { + // echo 'Windows Test: Cleanup' + // step([$class: 'WsCleanup']) + //} +} + +def testWindowsNoDocker = { + try { + echo 'Windows No Docker Test: Checkout csm' + checkout scm + + echo 'Windows No Docker Test: drop orientdb databases' + orientdb.cleanupWindows() + + testHelpers.createVirtualEnvAndExecute({ python, pip -> + echo 'Windows No Docker Test: Install dependencies' + testHelpers.installDepsBat(python, pip) + + echo 'Windows No Docker Test: Test' + bat "${python} runner.py --pytest \"${python} -m pytest\" --output \"test-result.txt\"" + }) + } + finally { + echo 'Windows No Docker Test: Cleanup' + step([$class: 'WsCleanup']) + } +} + + + +testAndPublish(name, [ubuntu: testUbuntu, windows: testWindowsNoDocker, windowsNoDocker: testWindowsNoDocker]) diff --git a/README.md b/README.md index bb66ca23c2..c731dec0d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Plenum Byzantine Fault Tolerant Protocol +# Plenum Byzantine Fault Tolerant Protocol + +[![Build Status](https://jenkins.evernym.com/buildStatus/icon?job=Plenum/master)](https://jenkins.evernym.com/job/Plenum/job/master/) Plenum makes extensive use of coroutines and the async/await keywords in Python, and as such, requires Python version 3.5.0 or later. Plenum also diff --git a/ci/ubuntu.dockerfile b/ci/ubuntu.dockerfile new file mode 100644 index 0000000000..52dfbc2da9 --- /dev/null +++ b/ci/ubuntu.dockerfile @@ -0,0 +1,26 @@ +# Development +FROM ubuntu:16.04 + +ARG uid=1000 + +# Install environment +RUN apt-get update -y +RUN apt-get install -y \ + git \ + wget \ + python3.5 \ + python3-pip \ + python-setuptools \ + python3-nacl +RUN pip3 install -U \ + pip \ + setuptools \ + virtualenv +RUN useradd -ms /bin/bash -u $uid sovrin +USER sovrin +RUN virtualenv -p python3.5 /home/sovrin/test +USER root +RUN ln -sf /home/sovrin/test/bin/python /usr/local/bin/python +RUN ln -sf /home/sovrin/test/bin/pip /usr/local/bin/pip +USER sovrin +WORKDIR /home/sovrin diff --git a/ci/windows.dockerfile b/ci/windows.dockerfile new file mode 100644 index 0000000000..2f52f2610a --- /dev/null +++ b/ci/windows.dockerfile @@ -0,0 +1,50 @@ +FROM microsoft/windowsservercore + +LABEL Description="plenum" Vendor="Evernym" + +# Install environment + +# Python +RUN powershell.exe -Command \ + $ErrorActionPreference = 'Stop'; \ + wget https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -OutFile c:\python-3.5.1.exe; \ + Start-Process c:\python-3.5.1.exe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait; \ + Remove-Item c:\python-3.5.1.exe -Force + +# Chocolate +RUN powershell.exe -Command \ + $ErrorActionPreference = 'Stop'; \ + "iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex" + +# Git (using Chocolate) +RUN powershell.exe -Command \ + $ErrorActionPreference = 'Stop'; \ + choco install git -ArgumentList '-params /GitAndUnixTllsOnPath' -y -Wait + +# PIP deps +RUN powershell.exe -Command \ + $ErrorActionPreference = 'Stop'; \ + pip install -U pip pytest + + +# MS Visual C++ Build Tools (using Chocolate) +RUN powershell.exe -Command \ + $ErrorActionPreference = 'Stop'; \ + choco install microsoft-build-tools -y -Wait + + +# unzip using chocolate +RUN powershell.exe -Command \ + $ErrorActionPreference = 'Stop'; \ + choco install unzip -y -Wait + + +# orientdb +#RUN powershell.exe -Command \ +# $ErrorActionPreference = 'Stop'; \ +# wget http://mkt.orientdb.com/CE-2217-windows -OutFile c:\orientdb-community.zip; \ +# unzip c:\orientdb-community.zip +# Start-Process c:\python-3.5.1.exe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait; \ +# Remove-Item c:\orientdb-community.zip -Force; \ +# Remove-Item orientdb-community* -Force; \ + diff --git a/plenum/__init__.py b/plenum/__init__.py index 452f8a2627..242074b2b6 100644 --- a/plenum/__init__.py +++ b/plenum/__init__.py @@ -5,15 +5,11 @@ from __future__ import absolute_import, division, print_function import sys - import plenum -from plenum.common.pkg_util import check_deps if sys.version_info < (3, 5, 0): raise ImportError("Python 3.5.0 or later required.") - import importlib from .__metadata__ import * -check_deps(plenum) diff --git a/plenum/__metadata__.py b/plenum/__metadata__.py index 77a47a0a1f..a397681c3b 100644 --- a/plenum/__metadata__.py +++ b/plenum/__metadata__.py @@ -1,13 +1,9 @@ """ plenum package metadata """ -__version_info__ = (0, 2) +__version_info__ = (0, 3) __version__ = '.'.join(map(str, __version_info__)) __author__ = "Evernym, Inc." __license__ = "Apache 2.0" __all__ = ['__version_info__', '__version__', '__author__', '__license__'] - -__dependencies__ = { - "ledger": ">=0.0.34" -} diff --git a/runner.py b/runner.py index 779756154b..d58b30f0c9 100644 --- a/runner.py +++ b/runner.py @@ -1,12 +1,13 @@ import os import re import sys +import argparse -def run(): - log("Preparing test suite") +def run(pytest, output_file): + log("Preparing test suite with {}".format(pytest)) testListFile = "test_list.txt" - os.system('pytest --collect-only > {}'.format(testListFile)) + os.system('{} --collect-only > {}'.format(pytest, testListFile)) log("Reading collected modules file") collectedData = open(testListFile).read() os.remove(testListFile) @@ -37,7 +38,7 @@ def run(): for test in testList: # testRep = '{}.rep'.format(test.split("/")[-1]) log("Going to run {}".format(test)) - r = os.system('pytest -k "{}" > {}'.format(test, testRep)) + r = os.system('{} -k "{}" > {}'.format(pytest, test, testRep)) reportLines = open(testRep).readlines() output = ''.join(reportLines) pas = passPat.search(output) @@ -110,9 +111,9 @@ def run(): for fm, fn in allErrorTests: log('{}:{}'.format(fm, fn)) - if failureData: + if failureData and output_file: log("Writing failure data in Test-Report.txt") - with open('../Test-Report.txt', 'w') as f: + with open(output_file, 'w') as f: f.write(summaryMsg) f.write(''.join(failureData)) @@ -128,5 +129,10 @@ def log(msg): if __name__ == "__main__": - r = run() + parser = argparse.ArgumentParser() + parser.add_argument('--pytest', type=str, help='pytest instance', default='python -m pytest') + parser.add_argument('--output', type=str, help='result file', default='../Test-Report.txt') + parser.add_argument('--nooutput', help='no result file', action="store_true") + args = parser.parse_args() + r = run(pytest=args.pytest, output_file=args.output if not args.nooutput else None) sys.exit(0 if r == 0 else 1) diff --git a/setup.py b/setup.py index c178de8bc8..5fb8424ec2 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ os.makedirs(BASE_DIR) setup( - name='plenum', + name='plenum-dev', version=__version__, description='Plenum Byzantine Fault Tolerant Protocol', long_description='Plenum Byzantine Fault Tolerant Protocol', @@ -61,8 +61,9 @@ data_files=[( (BASE_DIR, ['data/pool_transactions_sandbox', ]) )], - install_requires=['raet', 'jsonpickle', 'portalocker==0.5.7', - 'prompt_toolkit==0.57', 'pyorient', 'pygments', 'ledger', + install_requires=['ledger-dev', + 'raet', 'jsonpickle', 'portalocker==0.5.7', + 'prompt_toolkit==0.57', 'pyorient', 'pygments', 'ioflo==1.5.4', 'semver', 'base58', 'orderedset', 'sortedcontainers==1.5.7', 'psutil'], extras_require={