aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4
diff options
context:
space:
mode:
Diffstat (limited to 'moonv4')
-rw-r--r--moonv4/DEV.md50
-rw-r--r--moonv4/moon_db/README.md29
-rw-r--r--moonv4/moon_db/README.rst9
-rw-r--r--moonv4/moon_db/tests/README.md35
-rw-r--r--moonv4/moon_db/tests/unit_python/conftest.py4
-rw-r--r--moonv4/moon_manager/tests/unit_python/conftest.py4
-rw-r--r--moonv4/templates/python_unit_test/run_tests.sh6
7 files changed, 86 insertions, 51 deletions
diff --git a/moonv4/DEV.md b/moonv4/DEV.md
index 70bcc4fc..f9864639 100644
--- a/moonv4/DEV.md
+++ b/moonv4/DEV.md
@@ -1,6 +1,50 @@
-# Build Python Packages and Docker Images
-
-## Python Package
+# Developer Tutorial
+
+## Gerrit Setup
+### Git Install
+- `sudo apt-get install git`
+- `git config --global user.email "example@wikimedia.org"`
+- `git config --global user.name "example"`
+
+### ssh key
+- `cd ~/.ssh`
+- `ssh-keygen -t rsa -C your_email@youremail.com`
+- `~/.ssh/id_rsa`: identification (private) key`
+- `~/.ssh/id_rsa.pub`: public key
+- copy the public key to Gerrit web
+- add Gerrit web上 entry to `~/.ssh/known_hosts`
+- eval `ssh-agent`: start ssh-agent
+- `ssh-add ~/.ssh/id_rsa`: add private key to ssh
+- `ssh -p 29418 <USERNAME>@gerrit.opnfv.org`: test
+
+### Gerrit clone
+- `git clone https://WuKong@gerrit.opnfv.org:29418/moon`
+- the password is dynamically generated on the Gerrit web
+
+### Gerrit Setting
+- `sudo apt-get install python-pip`
+- `sudo pip install git-review`
+- `git remote add gerrit ssh://<yourname>@gerrit.opnfv.org:29418/moon.git`
+- add the ssh public key to the Gerrit web
+- `git review –s`: test the Gerrit review connection
+
+### Gerrit-Review
+- git add XXX
+- git commit --signoff --all
+- git review
+
+### Review Correction
+- `git clone https://git.openstack.org/openstack/oslo-specs`
+- `cd oslo-specs`
+- `git fetch https://git.openstack.org/openstack/oslo-specs refs/changes/43/492543/1 && git checkout FETCH_HEAD`
+- `git checkout -b 492543-1`
+- `vi specs/policy/external-pdp.rst`
+- `git add specs/policy/external-pdp.rst`
+- `git commit –amend`
+- `git review`
+
+
+## Build Python Package
### pre-requist
Get the code
```bash
diff --git a/moonv4/moon_db/README.md b/moonv4/moon_db/README.md
new file mode 100644
index 00000000..565b96fd
--- /dev/null
+++ b/moonv4/moon_db/README.md
@@ -0,0 +1,29 @@
+# moon_db
+
+This package contains the database module for the Moon project
+It is designed to provide a driver to access the Moon database.
+
+For any other information, refer to the parent project:
+
+ https://git.opnfv.org/moon
+
+## Build
+### Build Python Package
+- `cd ${MOON_HOME}/moonv4/moon_utilities/`
+- `python3 setup.py sdist bdist_wheel`
+
+### Upload moon_db to PIP
+- `python setup.py upload`
+or
+- `gpg --detach-sign -u "${GPG_ID}" -a dist/moon_db-X.Y.Z-py3-none-any.whl`
+- `gpg --detach-sign -u "${GPG_ID}" -a dist/moon_db-X.Y.Z.tar.gz`
+- `twine upload dist/moon_db-X.Y.Z-py3-none-any.whl dist/moon_db-X.Y.Z-py3-none-any.whl.asc`
+- `twine upload dist/moon_db-X.Y.Z.tar.gz dist/moon_db-X.Y.Z.tar.gz.asc`
+
+
+## Test
+### Python Unit Test
+launch Docker for Python unit tests
+- `cd ${MOON_HOME}/moonv4/moon_utilities`
+- `docker run --rm --volume $(pwd):/data wukongsun/moon_python_unit_test:latest`
+
diff --git a/moonv4/moon_db/README.rst b/moonv4/moon_db/README.rst
deleted file mode 100644
index afee9be5..00000000
--- a/moonv4/moon_db/README.rst
+++ /dev/null
@@ -1,9 +0,0 @@
-DB module for the Moon project
-==============================
-
-This package contains the database module for the Moon project
-It is designed to provide a driver to access the Moon database.
-
-For any other information, refer to the parent project:
-
- https://git.opnfv.org/moon
diff --git a/moonv4/moon_db/tests/README.md b/moonv4/moon_db/tests/README.md
deleted file mode 100644
index 73a9fcd2..00000000
--- a/moonv4/moon_db/tests/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-# Tests
-
-## Python Unit Test for moon_db
-
-- launch Docker for Python unit tests
-
-
- cd ${MOON_HOME}/moonv4/moon_db/
- docker run -ti --volume ${PWD}:/data asteroide/moon_tests
-
-
-## Build and upload python packages
-
-- build python packages
-
-
- python setup.py sdist bdist_wheel
-
-
-- upload moon_db to PIP
-
-
- python setup.py upload
-
-
-or
-
-
- gpg --detach-sign -u "${GPG_ID}" -a dist/moon_db-X.Y.Z-py3-none-any.whl
- gpg --detach-sign -u "${GPG_ID}" -a dist/moon_db-X.Y.Z.tar.gz
- twine upload dist/moon_db-X.Y.Z-py3-none-any.whl dist/moon_db-X.Y.Z-py3-none-any.whl.asc
- twine upload dist/moon_db-X.Y.Z.tar.gz dist/moon_db-X.Y.Z.tar.gz.asc
-
-
-
diff --git a/moonv4/moon_db/tests/unit_python/conftest.py b/moonv4/moon_db/tests/unit_python/conftest.py
index 6cce944e..b9f38d7c 100644
--- a/moonv4/moon_db/tests/unit_python/conftest.py
+++ b/moonv4/moon_db/tests/unit_python/conftest.py
@@ -192,9 +192,9 @@ def set_consul_and_db(monkeypatch):
"id": "1111111111111"
}]}
)
- from moon_db.db_manager import init_engine, run
+ from moon_db.db_manager import init_engine, main
engine = init_engine()
- run("upgrade", logging.getLogger("db_manager"), engine)
+ main("upgrade", logging.getLogger("db_manager"), engine)
yield m
os.unlink(CONF['database']['url'].replace("sqlite:///", ""))
diff --git a/moonv4/moon_manager/tests/unit_python/conftest.py b/moonv4/moon_manager/tests/unit_python/conftest.py
index 58f04af2..d6f518f7 100644
--- a/moonv4/moon_manager/tests/unit_python/conftest.py
+++ b/moonv4/moon_manager/tests/unit_python/conftest.py
@@ -176,10 +176,10 @@ def no_requests(monkeypatch):
}]}
)
print("Start populating the DB.")
- from moon_db.db_manager import init_engine, run
+ from moon_db.db_manager import init_engine, main
engine = init_engine()
print("engine={}".format(engine))
- run("upgrade", logging.getLogger("db_manager"), engine)
+ main("upgrade", logging.getLogger("db_manager"), engine)
print("End populating the DB.")
yield m
diff --git a/moonv4/templates/python_unit_test/run_tests.sh b/moonv4/templates/python_unit_test/run_tests.sh
index 68b75efa..6c586f87 100644
--- a/moonv4/templates/python_unit_test/run_tests.sh
+++ b/moonv4/templates/python_unit_test/run_tests.sh
@@ -1,7 +1,13 @@
#!/usr/bin/env bash
cd /data
+pip3 install -r tests/unit_python/requirements.txt --upgrade
pip3 install .
+if [ -f /data/tests/unit_python/run_tests.sh ];
+then
+ bash /data/tests/unit_python/run_tests.sh;
+fi
+
cd /data/tests/unit_python
pytest .