General cleanup
- Remove unused Dockerfiles
- Simplify Makefile
- Use tox.ini to store nose config
- Bump version of voltha-protos and fix test
Change-Id: I8d6a1e8dfafd84bd21f495b0f6b96885f829c208
diff --git a/.gitignore b/.gitignore
index 5f49275..ff89877 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,76 +1,10 @@
-# PyCharm
-.idea
-exportToHTML
-
-# Emacs
-*~
-.#*
-
-# Any vi swap files
-*.swp
-
-# Editors
-*.bak
-*.project
-*.pydevproject
-
-# Protobuf output files
-pyvoltha/**/*.desc
-**/*_pb2.py
-**/*_pb2_grpc.py
-
-### Python template
-# Byte-compiled / optimized / DLL files
-__pycache__/
-*.py[cod]
-*$py.class
-
-# C extensions
-*.so
-
-# Distribution / packaging
-.Python
-build/
-develop-eggs/
-dist/
-downloads/
-eggs/
-.eggs/
-lib/
-lib64/
-parts/
-sdist/
-var/
-wheels/
-*.egg-info/
-.installed.cfg
-*.egg
-MANIFEST
-
-# PyInstaller
-# Usually these files are written by a python script from a template
-# before PyInstaller builds the exe, so as to inject date/other infos into it.
-*.manifest
-*.spec
-
-# Installer logs
-pip-log.txt
-pip-delete-this-directory.txt
-
-# Unit test / coverage reports
-htmlcov/
-.tox/
+# testing related
.coverage
-.coverage.*
-.cache
-nosetests.xml
-coverage.xmlcd
-*.cover
+.tox/
+coverage.xml
+nose-results.xml
+test/unit/tmp
-# Virtualenv
-venv
-venv-darwin
-venv-linux
-
-# junit-coverage file
-**/junit-coverage.xml
+# python distribution related
+dist
+*.egg-info
diff --git a/Makefile b/Makefile
index f6cf50a..8fbbfb9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,3 @@
-#
# Copyright 2018 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,152 +11,46 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
-ifeq ($(TAG),)
-TAG := latest
-endif
+# Configure shell
+SHELL = bash -eu -o pipefail
-ifeq ($(TARGET_TAG),)
-TARGET_TAG := latest
-endif
-
-ifneq ($(http_proxy)$(https_proxy),)
-# Include proxies from the environment
-DOCKER_PROXY_ARGS = \
- --build-arg http_proxy=$(http_proxy) \
- --build-arg https_proxy=$(https_proxy) \
- --build-arg ftp_proxy=$(ftp_proxy) \
- --build-arg no_proxy=$(no_proxy) \
- --build-arg HTTP_PROXY=$(HTTP_PROXY) \
- --build-arg HTTPS_PROXY=$(HTTPS_PROXY) \
- --build-arg FTP_PROXY=$(FTP_PROXY) \
- --build-arg NO_PROXY=$(NO_PROXY)
-endif
-
-DOCKER_BUILD_ARGS = \
- --build-arg TAG=$(TAG) \
- --build-arg REGISTRY=$(REGISTRY) \
- --build-arg REPOSITORY=$(REPOSITORY) \
- $(DOCKER_PROXY_ARGS) $(DOCKER_CACHE_ARG) \
- --rm --force-rm \
- $(DOCKER_BUILD_EXTRA_ARGS)
-
-DOCKER_IMAGE_LIST = \
- pyvoltha-base \
- pyvoltha
-
-VENVDIR := venv-$(shell uname -s | tr '[:upper:]' '[:lower:]')
-
-VENV_BIN ?= virtualenv
-VENV_OPTS ?=
-
-.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 venv rebuild-venv clean distclean build test docker_base_img docker_image
+default: help
# This should to be the first and default target in this Makefile
help:
@echo "Usage: make [<target>]"
@echo "where available targets are:"
@echo
- @echo "dist : Create the python package"
- @echo "docker_base_img : Build a base docker image with a modern version of pip and requirements.txt installed"
- @echo "docker_image : Build a docker image with pyvoltha installed"
- @echo "utest : Run all unit test"
- @echo "utest-with-coverage : Run all unit test with coverage reporting"
@echo "clean : Remove files created by the build and tests"
- @echo "distclean : Remove venv directory"
+ @echo "dist : Create source distribution of the python package"
@echo "help : Print this help"
- @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
- @echo "venv : Build local Python virtualenv if did not exist yet"
+ @echo "test : Run all unit test"
+ @echo "upload : Upload test version of python package to test.pypi.org"
@echo
-## New directories can be added here
-#DIRS:=
+# ignore these directories
+.PHONY: test dist
-## If one directory depends on another directory that
-## dependency can be expressed here
-##
-## For example, if the Tibit directory depended on the eoam
-## directory being built first, then that can be expressed here.
-## driver/tibit: eoam
-
-# Parallel Build
-$(DIRS):
- @echo " MK $@"
- $(Q)$(MAKE) -C $@
-
-# Parallel Clean
-DIRS_CLEAN = $(addsuffix .clean,$(DIRS))
-$(DIRS_CLEAN):
- @echo " CLEAN $(basename $@)"
- $(Q)$(MAKE) -C $(basename $@) clean
-
-# Parallel Flake8
-DIRS_FLAKE8 = $(addsuffix .flake8,$(DIRS))
-$(DIRS_FLAKE8):
- @echo " FLAKE8 $(basename $@)"
- -$(Q)$(MAKE) -C $(basename $@) flake8
-
-dist: venv
- @ echo "Creating PyPi artifacts"
+dist:
+ @ echo "Creating python source distribution"
python setup.py sdist
upload: dist
- @ echo "Uploading PyPi artifacts"
+ @ echo "Uploading sdist to test.pypi.org"
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
- twine upload dist/*
-docker_base_img:
- docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}pyvoltha-base:${TAG} -f docker/Dockerfile.base .
-
-docker_image: docker_base_img dist
- docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}pyvoltha:${TAG} -f docker/Dockerfile.pyvoltha .
-
-test: venv
- @ echo "Executing all unit tests"
- @ tox -- --with-xunit
-
-COVERAGE_OPTS=--with-coverage --with-xunit --cover-branches --cover-html --cover-html-dir=tmp/cover \
- --cover-package=pyvoltha.adapters,pyvoltha.common
-
-utest-with-coverage: venv
- @ echo "Executing all unit tests and producing coverage results"
- @ tox -- $(COVERAGE_OPTS)
+test:
+ @ echo "Executing unit tests w/tox"
+ tox
clean:
find . -name '*.pyc' | xargs rm -f
- find . -name 'coverage.xml' | xargs rm -f
- find . -name 'nosetests.xml' | xargs rm -f
- rm -rf pyvoltha.egg-info
- rm -rf dist
- rm -rf .tox
- rm -rf test/unit/tmp
-
-distclean: clean
- rm -rf ${VENVDIR}
-
-purge-venv:
- rm -fr ${VENVDIR}
-
-rebuild-venv: purge-venv venv
-
-venv: ${VENVDIR}/.built
-
-${VENVDIR}/.built:
- @ $(VENV_BIN) ${VENV_OPTS} ${VENVDIR}
- @ $(VENV_BIN) ${VENV_OPTS} --relocatable ${VENVDIR}
- @ . ${VENVDIR}/bin/activate && \
- pip install --upgrade pip; \
- if ! pip install -r requirements.txt; \
- then \
- echo "On MAC OS X, if the installation failed with an error \n'<openssl/opensslv.h>': file not found,"; \
- echo "see the BUILD.md file for a workaround"; \
- else \
- uname -s > ${VENVDIR}/.built; \
- fi
- @ $(VENV_BIN) ${VENV_OPTS} --relocatable ${VENVDIR}
-
-
-flake8: $(DIRS_FLAKE8)
-
-# end file
+ rm -rf \
+ .tox \
+ .coverage \
+ coverage.xml \
+ dist \
+ nose-results.xml \
+ pyvoltha.egg-info \
+ test/unit/tmp
diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base
deleted file mode 100644
index fe8879c..0000000
--- a/docker/Dockerfile.base
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu:xenial
-
-MAINTAINER Voltha Community <info@opennetworking.org>
-
-# Update to have latest images
-RUN apt-get update && \
- apt-get install -y python openssl iproute2 libpcap-dev wget build-essential git binutils python-dev libffi-dev libssl-dev
-
-# Install current version of pip rather than outdated pip from apt
-RUN wget -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py
-RUN python /tmp/get-pip.py
-
-COPY requirements.txt /tmp/requirements.txt
-RUN pip install -r /tmp/requirements.txt
diff --git a/docker/Dockerfile.pyvoltha b/docker/Dockerfile.pyvoltha
deleted file mode 100644
index 4497934..0000000
--- a/docker/Dockerfile.pyvoltha
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-ARG TAG=latest
-ARG REGISTRY=
-ARG REPOSITORY=
-
-FROM ${REGISTRY}${REPOSITORY}pyvoltha-base:${TAG}
-
-MAINTAINER Voltha Community <info@opennetworking.org>
-
-COPY dist /pyvoltha/dist
-RUN pip install /pyvoltha/dist/*.tar.gz
-
diff --git a/requirements.txt b/requirements.txt
index 8b1a953..558f67b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -50,5 +50,5 @@
Twisted==18.7.0
txaioetcd==0.3.0
urllib3==1.22
-voltha-protos==0.1.0
+voltha-protos==0.1.2
afkak==3.0.0.dev20181106
diff --git a/setup.py b/setup.py
index 293fd2e..02cf55b 100644
--- a/setup.py
+++ b/setup.py
@@ -57,7 +57,7 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
],
- packages=find_packages(exclude=['protos', 'test']),
+ packages=find_packages(exclude=['test']),
install_requires=[required],
include_package_data=True,
dependency_links=["git+https://github.com/ciena/afkak.git#egg=afkak-3.0.0.dev20181106"]
diff --git a/test/unit/extensions/omci/test_image_agent.py b/test/unit/extensions/omci/test_image_agent.py
index 08f0f1e..0e500cb 100644
--- a/test/unit/extensions/omci/test_image_agent.py
+++ b/test/unit/extensions/omci/test_image_agent.py
@@ -26,8 +26,7 @@
OmciDownloadSection, OmciDownloadSectionLast, OmciDownloadSectionResponse, \
OmciActivateImage, OmciActivateImageResponse, \
OmciCommitImage, OmciCommitImageResponse
-from pyvoltha.protos.voltha_pb2 import ImageDownload
-from pyvoltha.protos.device_pb2 import Device
+from voltha_protos.device_pb2 import Device, ImageDownload
from test.unit.extensions.omci.mock.mock_adapter_agent import MockAdapterAgent, MockCore
from twisted.internet import reactor
diff --git a/tox.ini b/tox.ini
index b32b8b6..60d0614 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,4 +1,3 @@
-;
; Copyright 2017 the original author or authors.
;
; Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,74 +11,24 @@
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
-;
+
[tox]
-;envlist = py27, py36, py3-analysis, py3-test
envlist = py27
-minversion = 2.5.0
-
-[package]
-name = pyvoltha
-
-[cov]
-xml = --cov-report xml:{toxworkdir}/{envname}coverage.xml
-term = --cov-report term-missing
-html = --cov-report html:{toxworkdir}/{envname}cov
-branch = --cov-branch
-directory =--cov {envsitepackagesdir}/{[package]name}
-coverage = {[cov]xml} {[cov]term} {[cov]html} {[cov]branch} {[cov]directory}
-cov_fail_under=100
-
-[pylama]
-format = pylint
-skip = */.tox/*,*/.env/*
-linters = pep8,pylint
-analysis_dirs = {[package]name} test
-analysis = pylama {[pylama]analysis_dirs}
-
-[pylama:pep8]
-max_line_length=99
-ignore = E203, W503, R0903
-
-[pylama:test/*]
-ignore = C0111,R0201,R0903
-
-[pytest]
-passenv = {env:PYTEST_ARGS}
-flags =-vvl {env:PYTEST_ARGS:}
-cov-fail-under=100
-unit_results =--junitxml={toxworkdir}/{envname}_results.xml
-test = py.test {[pytest]flags} {[pytest]unit_results}
-with_metrics = {[pytest]test} {[cov]coverage}
-
-[nosetests]
-passenv =
[testenv]
-changedir = test/unit
-basepython =
- py27: python2.7
- ;py3: python3
-envdir =
- py27: {toxworkdir}/.py27
- ;py3: {toxworkdir}/.py3
-setenv =
- COVERAGE_FILE = {envdir}/.coverage
- PYTHONPATH = {toxinidir}:{toxinidir}/pyvoltha/protos/third_party
-
commands =
- py27: nosetests {posargs}
-; py3-test: {[pytest]with_metrics} test
-; py3-no-coverage: {[pytest]test} test
-; py3-unit: {[pytest]with_metrics} test/unit
-; py3-component: {[pytest]with_metrics} test/component
-; py3-adhoc: {posargs: bash -c 'echo must provide posargs with "tox args -- posargs"'}
-; py3-analysis: {[pylama]analysis}
-; py3-analysis: black --check {[pylama]analysis_dirs}
-; py3-black: black {[pylama]analysis_dirs}
-; py3-docs: sphinx-build -b html docs docs_out
+ nosetests -c tox.ini
deps =
nose
- -r{toxinidir}/requirements.txt
- -r{toxinidir}/test-requirements.txt
\ No newline at end of file
+ mock
+ coverage
+ -r requirements.txt
+
+[nosetests]
+with-xunit=1
+xunit-file=nose-results.xml
+with-coverage=1
+cover-xml=1
+cover-xml-file=coverage.xml
+cover-package=pyvoltha