From ba20cfa319db7a2d8f8c0d4f681bfbf0cdd992fa Mon Sep 17 00:00:00 2001 From: Phillip Herron Date: Tue, 11 Dec 2018 15:44:32 -0600 Subject: [PATCH 1/8] Initial check-in of files for unit test framework for ONU device adapter --- voltha/adapters/adtran_onu/.coveragerc | 2 ++ voltha/adapters/adtran_onu/.gitignore | 3 ++ voltha/adapters/adtran_onu/Makefile | 36 +++++++++++++++++++ voltha/adapters/adtran_onu/test/__init__.py | 0 .../adapters/adtran_onu/test/test_example.py | 4 +++ .../adapters/adtran_onu/test_requirements.txt | 4 +++ 6 files changed, 49 insertions(+) create mode 100644 voltha/adapters/adtran_onu/.coveragerc create mode 100644 voltha/adapters/adtran_onu/.gitignore create mode 100644 voltha/adapters/adtran_onu/Makefile create mode 100644 voltha/adapters/adtran_onu/test/__init__.py create mode 100644 voltha/adapters/adtran_onu/test/test_example.py create mode 100644 voltha/adapters/adtran_onu/test_requirements.txt diff --git a/voltha/adapters/adtran_onu/.coveragerc b/voltha/adapters/adtran_onu/.coveragerc new file mode 100644 index 00000000..053d1977 --- /dev/null +++ b/voltha/adapters/adtran_onu/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit = venv/*, test/* diff --git a/voltha/adapters/adtran_onu/.gitignore b/voltha/adapters/adtran_onu/.gitignore new file mode 100644 index 00000000..2aa6d20b --- /dev/null +++ b/voltha/adapters/adtran_onu/.gitignore @@ -0,0 +1,3 @@ +htmlcov/ +venv/ +prof/ diff --git a/voltha/adapters/adtran_onu/Makefile b/voltha/adapters/adtran_onu/Makefile new file mode 100644 index 00000000..9dc2d07a --- /dev/null +++ b/voltha/adapters/adtran_onu/Makefile @@ -0,0 +1,36 @@ +THIS_MAKEFILE := $(abspath $(MAKEFILE_LIST) ) +WORKING_DIR := $(dir $(THIS_MAKEFILE) ) +ADAPTERS_DIR := $(dir $(patsubst %/,%,$(WORKING_DIR))) +VOLTHA_DIR := $(dir $(patsubst %/,%,$(ADAPTERS_DIR))) + +VENVDIR=$(WORKING_DIR)venv +TESTDIR=$(WORKING_DIR)test + +ADD_TO_PYTHONPATH := export PYTHONPATH=$(PYTHONPATH):$(VOLTHA_DIR)/protos/third_party; +IN_VENV=. '$(VENVDIR)/bin/activate'; + +PROFILING=--profile-svg +DOT := $(shell command -v dot 2> /dev/null) +ifndef DOT +$(warning "dot is not available please install graphviz") +PROFILING= +endif + +RUN_PYTEST=$(IN_VENV) $(ADD_TO_PYTHONPATH) python -m pytest -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html + +$(VENVDIR): + @virtualenv -p python2 $(VENVDIR) + @virtualenv -p python2 --relocatable $(VENVDIR) + +.PHONY: create-venv +create-venv: $(VENVDIR) + +.PHONY: test +test: create-venv + @$(IN_VENV) command -v py.test > /dev/null 2>&1 || `echo >&2 "'make requirements' first. Aborting."; exit 1;` + @rm -rf $(TESTDIR)/__pycache__ + @cd $(WORKING_DIR) && $(RUN_PYTEST) $(TESTDIR) + +.PHONY: requirements +requirements: create-venv + @$(IN_VENV) pip install --upgrade -r test_requirements.txt diff --git a/voltha/adapters/adtran_onu/test/__init__.py b/voltha/adapters/adtran_onu/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/voltha/adapters/adtran_onu/test/test_example.py b/voltha/adapters/adtran_onu/test/test_example.py new file mode 100644 index 00000000..171a6639 --- /dev/null +++ b/voltha/adapters/adtran_onu/test/test_example.py @@ -0,0 +1,4 @@ +from voltha.adapters.adtran_onu import adtran_onu + +def test_example(): + assert True diff --git a/voltha/adapters/adtran_onu/test_requirements.txt b/voltha/adapters/adtran_onu/test_requirements.txt new file mode 100644 index 00000000..83c80cf1 --- /dev/null +++ b/voltha/adapters/adtran_onu/test_requirements.txt @@ -0,0 +1,4 @@ +-r ../../../requirements.txt +pytest >= 3.0, < 4.0 +pytest-cov >= 2.1.0, < 3.0 +pytest-profiling >= 1.3.0 From 9ba3df75c7d2cb2c0331ca4220d54123375d170a Mon Sep 17 00:00:00 2001 From: Phillip Herron Date: Tue, 11 Dec 2018 16:03:36 -0600 Subject: [PATCH 2/8] Updated pytest-profiling version range --- voltha/adapters/adtran_onu/README.md | 3 --- voltha/adapters/adtran_onu/test_requirements.txt | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 voltha/adapters/adtran_onu/README.md diff --git a/voltha/adapters/adtran_onu/README.md b/voltha/adapters/adtran_onu/README.md deleted file mode 100644 index 5d35f576..00000000 --- a/voltha/adapters/adtran_onu/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# adtran_onu -# This is the test for review process -VOLTHA ONU Device Adapter for Adtran ONU/ONTs diff --git a/voltha/adapters/adtran_onu/test_requirements.txt b/voltha/adapters/adtran_onu/test_requirements.txt index 83c80cf1..4d8a4014 100644 --- a/voltha/adapters/adtran_onu/test_requirements.txt +++ b/voltha/adapters/adtran_onu/test_requirements.txt @@ -1,4 +1,4 @@ -r ../../../requirements.txt pytest >= 3.0, < 4.0 pytest-cov >= 2.1.0, < 3.0 -pytest-profiling >= 1.3.0 +pytest-profiling >= 1.1.1, < 2.0 From a281268974dab258d127ff386acee96b8787ef67 Mon Sep 17 00:00:00 2001 From: Phillip Herron Date: Tue, 11 Dec 2018 16:30:21 -0600 Subject: [PATCH 3/8] Less characters for Nathan :) --- voltha/adapters/adtran_onu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voltha/adapters/adtran_onu/Makefile b/voltha/adapters/adtran_onu/Makefile index 9dc2d07a..e1f27ee8 100644 --- a/voltha/adapters/adtran_onu/Makefile +++ b/voltha/adapters/adtran_onu/Makefile @@ -16,7 +16,7 @@ $(warning "dot is not available please install graphviz") PROFILING= endif -RUN_PYTEST=$(IN_VENV) $(ADD_TO_PYTHONPATH) python -m pytest -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html +RUN_PYTEST=$(IN_VENV) $(ADD_TO_PYTHONPATH) py.test -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html $(VENVDIR): @virtualenv -p python2 $(VENVDIR) From 8ab2521bedb2e921be8a7f84b90dcc3a9f30716d Mon Sep 17 00:00:00 2001 From: Nicole Story Date: Tue, 11 Dec 2018 13:10:59 -0600 Subject: [PATCH 4/8] Updates to Makefile --- voltha/adapters/adtran_olt/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/voltha/adapters/adtran_olt/Makefile b/voltha/adapters/adtran_olt/Makefile index efa5fc7e..7e88ba3a 100644 --- a/voltha/adapters/adtran_olt/Makefile +++ b/voltha/adapters/adtran_olt/Makefile @@ -6,8 +6,8 @@ VOLTHA_DIR := $(dir $(patsubst %/,%,$(ADAPTERS_DIR))) VENVDIR=$(WORKING_DIR)venv TESTDIR=$(WORKING_DIR)test -ADD_TO_PYTHONPATH := export PYTHONPATH=$(VOLTHA_DIR)/protos/third_party; -IN_VENV=. '$(VENVDIR)/bin/activate'; $(ADD_TO_PYTHONPATH) +ADD_TO_PYTHONPATH := export PYTHONPATH=$(PYTHONPATH):$(VOLTHA_DIR)protos/third_party; +IN_VENV=. '$(VENVDIR)/bin/activate'; PROFILING=--profile-svg DOT := $(shell command -v dot 2> /dev/null) @@ -16,7 +16,7 @@ $(warning "dot is not available please install graphviz") PROFILING= endif -RUN_PYTEST=$(IN_VENV) python -m pytest -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html +RUN_PYTEST=$(IN_VENV) $(ADD_TO_PYTHONPATH) python -m pytest -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html $(VENVDIR): @virtualenv -p python2 $(VENVDIR) From cd13542a9b0a3fd2712d028082c273ce20f16d13 Mon Sep 17 00:00:00 2001 From: Nicole Story Date: Tue, 11 Dec 2018 16:40:33 -0600 Subject: [PATCH 5/8] PYTHONPATH variable --- voltha/adapters/adtran_olt/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voltha/adapters/adtran_olt/Makefile b/voltha/adapters/adtran_olt/Makefile index 7e88ba3a..f892a141 100644 --- a/voltha/adapters/adtran_olt/Makefile +++ b/voltha/adapters/adtran_olt/Makefile @@ -6,7 +6,7 @@ VOLTHA_DIR := $(dir $(patsubst %/,%,$(ADAPTERS_DIR))) VENVDIR=$(WORKING_DIR)venv TESTDIR=$(WORKING_DIR)test -ADD_TO_PYTHONPATH := export PYTHONPATH=$(PYTHONPATH):$(VOLTHA_DIR)protos/third_party; +PYTHONPATH := $(PYTHONPATH):$(VOLTHA_DIR)protos/third_party; IN_VENV=. '$(VENVDIR)/bin/activate'; PROFILING=--profile-svg @@ -16,7 +16,7 @@ $(warning "dot is not available please install graphviz") PROFILING= endif -RUN_PYTEST=$(IN_VENV) $(ADD_TO_PYTHONPATH) python -m pytest -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html +RUN_PYTEST=$(IN_VENV) PYTHONPATH=$(PYTHONPATH) python -m pytest -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html $(VENVDIR): @virtualenv -p python2 $(VENVDIR) From dfcf421288f7fd29e058dc1d658dab29f3a2eb6a Mon Sep 17 00:00:00 2001 From: Nicole Story Date: Tue, 11 Dec 2018 16:55:21 -0600 Subject: [PATCH 6/8] Ignore profiling --- voltha/adapters/adtran_olt/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/voltha/adapters/adtran_olt/.gitignore b/voltha/adapters/adtran_olt/.gitignore index 99e78d8f..2aa6d20b 100644 --- a/voltha/adapters/adtran_olt/.gitignore +++ b/voltha/adapters/adtran_olt/.gitignore @@ -1,2 +1,3 @@ htmlcov/ venv/ +prof/ From d3f1dac7bd6a04d3b8d4fc447ba64c8119adf80f Mon Sep 17 00:00:00 2001 From: Nicole Story Date: Tue, 11 Dec 2018 16:57:53 -0600 Subject: [PATCH 7/8] Less characters for Nathan :D --- voltha/adapters/adtran_olt/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voltha/adapters/adtran_olt/Makefile b/voltha/adapters/adtran_olt/Makefile index f892a141..ff9a5988 100644 --- a/voltha/adapters/adtran_olt/Makefile +++ b/voltha/adapters/adtran_olt/Makefile @@ -16,7 +16,7 @@ $(warning "dot is not available please install graphviz") PROFILING= endif -RUN_PYTEST=$(IN_VENV) PYTHONPATH=$(PYTHONPATH) python -m pytest -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html +RUN_PYTEST=$(IN_VENV) PYTHONPATH=$(PYTHONPATH) py.test -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html $(VENVDIR): @virtualenv -p python2 $(VENVDIR) From 8fd37cb480670ddc52312943f0512a9cc5281817 Mon Sep 17 00:00:00 2001 From: Phillip Herron Date: Wed, 12 Dec 2018 10:36:38 -0600 Subject: [PATCH 8/8] Updates so that OLT and ONU Makefiles match --- voltha/adapters/adtran_onu/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voltha/adapters/adtran_onu/Makefile b/voltha/adapters/adtran_onu/Makefile index e1f27ee8..ff9a5988 100644 --- a/voltha/adapters/adtran_onu/Makefile +++ b/voltha/adapters/adtran_onu/Makefile @@ -6,7 +6,7 @@ VOLTHA_DIR := $(dir $(patsubst %/,%,$(ADAPTERS_DIR))) VENVDIR=$(WORKING_DIR)venv TESTDIR=$(WORKING_DIR)test -ADD_TO_PYTHONPATH := export PYTHONPATH=$(PYTHONPATH):$(VOLTHA_DIR)/protos/third_party; +PYTHONPATH := $(PYTHONPATH):$(VOLTHA_DIR)protos/third_party; IN_VENV=. '$(VENVDIR)/bin/activate'; PROFILING=--profile-svg @@ -16,7 +16,7 @@ $(warning "dot is not available please install graphviz") PROFILING= endif -RUN_PYTEST=$(IN_VENV) $(ADD_TO_PYTHONPATH) py.test -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html +RUN_PYTEST=$(IN_VENV) PYTHONPATH=$(PYTHONPATH) py.test -vvlx $(PROFILING) --cov=$(WORKING_DIR) --cov-report term-missing --cov-report html $(VENVDIR): @virtualenv -p python2 $(VENVDIR)