Skip to content

Commit

Permalink
Merge branch 'feature/service_instance' into 'develop'
Browse files Browse the repository at this point in the history
Feature/service instance

Closes #1, #2, #3, #4, #6, and #5

See merge request Orange-OpenSource/lfn/onap/python-onapsdk!72
  • Loading branch information
michal-jagiello-tmpl committed Jun 8, 2020
2 parents fc27645 + 5bf44a5 commit b73f782
Show file tree
Hide file tree
Showing 109 changed files with 9,955 additions and 368 deletions.
217 changes: 113 additions & 104 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,107 +1,116 @@
---
stages:
- linting
- unit_test
- build
- test
- deploy

image: docker:git
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay
# Variables for Container-Scanning.gitlab-ci.yml
CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE #/$CI_COMMIT_REF_SLUG
CI_APPLICATION_TAG: $CI_COMMIT_REF_SLUG #$CI_COMMIT_SHA
# Variable for pylint/pydocstyle/SAST/Code-Quality.gitlab-ci.yml
SRC_PATH: '/src'
DOC_PATH: '/docs'

.before_script_docker: &before_script_docker
before_script:
- docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"

build_master:
stage: build
<<: *before_script_docker
script:
- docker build -t "$CI_REGISTRY_IMAGE:latest" .
- docker push "$CI_REGISTRY_IMAGE:latest"
only:
- master
except:
variables:
- $JOBS_DISABLED

build_testing:
stage: build
<<: *before_script_docker
script:
- docker build -t "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}" .
- docker push "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}"
only:
- branches
except:
refs:
- master
variables:
- $JOBS_DISABLED

build_stable:
stage: build
<<: *before_script_docker
script:
- docker build -t "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}" .
- docker push "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}"
only:
- tags
except:
variables:
- $JOBS_DISABLED

integration_tests:
stage: test
stages:
- linting
- unit_test
- build
- test
- deploy

image: docker:git
services:
- name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdc:develop
alias: sdc.api.fe.simpledemo.onap.org
image: python:3.7
allow_failure: true
script:
- pip install .
- pip install pytest mock # mock is needed as pytest parse all files before selection
- mv setup.cfg setup.old # pytest tries to use setup.cfg but we don't want
- pytest --verbose --junitxml=pytest-integration.xml integration_tests
artifacts:
reports:
junit: pytest-*.xml
except:
variables:
- $JOBS_DISABLED

pages:
stage: deploy
image:
name: python:3.7
script:
- chmod +x scripts/build_all_branches_in.sh
- scripts/build_all_branches_in.sh
artifacts:
paths:
- public
except:
- docker:dind
variables:
DOCKER_DRIVER: overlay
# Variables for Container-Scanning.gitlab-ci.yml
CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE #/$CI_COMMIT_REF_SLUG
CI_APPLICATION_TAG: $CI_COMMIT_REF_SLUG #$CI_COMMIT_SHA
# Variable for pylint/pydocstyle/SAST/Code-Quality.gitlab-ci.yml
SRC_PATH: '/src'
DOC_PATH: '/docs'

.before_script_docker: &before_script_docker
before_script:
- docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"

build_master:
stage: build
<<: *before_script_docker
script:
- docker build -t "$CI_REGISTRY_IMAGE:latest" .
- docker push "$CI_REGISTRY_IMAGE:latest"
only:
- master
except:
variables:
- $JOBS_DISABLED

build_testing:
stage: build
<<: *before_script_docker
script:
- docker build -t "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}" .
- docker push "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}"
only:
- branches
except:
refs:
- master
variables:
- $JOBS_DISABLED

build_stable:
stage: build
<<: *before_script_docker
script:
- docker build -t "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}" .
- docker push "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}"
only:
- tags
except:
variables:
- $JOBS_DISABLED

integration_tests:
stage: test
variables:
- $JOBS_DISABLED

include:
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pylint.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pytest.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pydocstyle.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/doc8.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/Container-Scanning.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/Code-Quality.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/SAST.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pyup.gitlab-ci.yml'
- template: License-Scanning.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml

FF_NETWORK_PER_BUILD: 1 # Enable https://docs.gitlab.com/runner/executors/docker.html#network-per-build feature
services:
- name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdc:develop
alias: sdc.api.fe.simpledemo.onap.org
- name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdnc:latest
alias: sdnc.api.simpledemo.onap.org
- name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-so:latest
alias: so.api.simpledemo.onap.org
- name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-aai:latest
alias: aai.api.sparky.simpledemo.onap.org
image: python:3.7
allow_failure: true
script:
- pip install .
- pip install pytest mock # mock is needed as pytest parse all files before selection
- mv setup.cfg setup.old # pytest tries to use setup.cfg but we don't want
- pytest --verbose --junitxml=pytest-integration.xml integration_tests
artifacts:
reports:
junit: pytest-*.xml
except:
variables:
- $JOBS_DISABLED

pages:
stage: deploy
image:
name: python:3.7
script:
- chmod +x scripts/build_all_branches_in.sh
- scripts/build_all_branches_in.sh
artifacts:
paths:
- public
except:
variables:
- $JOBS_DISABLED

include:
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pylint.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pytest.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pydocstyle.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/doc8.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/Container-Scanning.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/Code-Quality.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/SAST.gitlab-ci.yml'
- remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pyup.gitlab-ci.yml'
- template: License-Scanning.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml


6 changes: 4 additions & 2 deletions integration_tests/test_01_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
from onapsdk.vendor import Vendor
import onapsdk.constants as const

from .urls import SDC_MOCK_URL


@pytest.mark.integration
def test_vendor_unknown():
"""Integration tests for Vendor."""
SDC.base_front_url = "http://sdc.api.fe.simpledemo.onap.org:30206"
SDC.base_front_url = SDC_MOCK_URL
SDC.base_back_url = Vendor.base_front_url
response = requests.post("{}/reset".format(SDC.base_front_url))
response.raise_for_status()
Expand All @@ -26,7 +28,7 @@ def test_vendor_unknown():
@pytest.mark.integration
def test_vendor_onboard_unknown():
"""Integration tests for Vendor."""
SDC.base_front_url = "http://sdc.api.fe.simpledemo.onap.org:30206"
SDC.base_front_url = SDC_MOCK_URL
SDC.base_back_url = Vendor.base_front_url
response = requests.post("{}/reset".format(SDC.base_front_url))
response.raise_for_status()
Expand Down
12 changes: 8 additions & 4 deletions integration_tests/test_02_vsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@

import requests

from onapsdk.sdc import SDC
from onapsdk.vendor import Vendor
from onapsdk.vsp import Vsp
import onapsdk.constants as const

from .urls import SDC_MOCK_URL


@pytest.mark.integration
def test_vsp_unknown():
"""Integration tests for Vsp."""
Vendor.base_front_url = "http://sdc.api.fe.simpledemo.onap.org:30206"
Vendor.base_back_url = Vendor.base_front_url
SDC.base_front_url = SDC_MOCK_URL
SDC.base_back_url = SDC_MOCK_URL
response = requests.post("{}/reset".format(Vendor.base_front_url))
response.raise_for_status()
vendor = Vendor(name="test")
Expand All @@ -40,8 +44,8 @@ def test_vsp_unknown():
@pytest.mark.integration
def test_vsp_onboard_unknown():
"""Integration tests for Vsp."""
Vendor.base_front_url = "http://sdc.api.fe.simpledemo.onap.org:30206"
Vendor.base_back_url = Vendor.base_front_url
SDC.base_front_url = SDC_MOCK_URL
SDC.base_back_url = SDC_MOCK_URL
response = requests.post("{}/reset".format(Vendor.base_front_url))
response.raise_for_status()
vendor = Vendor(name="test")
Expand Down
11 changes: 7 additions & 4 deletions integration_tests/test_03_vf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@

import requests

from onapsdk.sdc import SDC
from onapsdk.vendor import Vendor
from onapsdk.vsp import Vsp
from onapsdk.vf import Vf
import onapsdk.constants as const

from .urls import SDC_MOCK_URL


@pytest.mark.integration
def test_vf_unknown():
"""Integration tests for Vf."""
Vendor.base_front_url = "http://sdc.api.fe.simpledemo.onap.org:30206"
Vendor.base_back_url = Vendor.base_front_url
SDC.base_front_url = SDC_MOCK_URL
SDC.base_back_url = SDC_MOCK_URL
response = requests.post("{}/reset".format(Vendor.base_front_url))
response.raise_for_status()
vendor = Vendor(name="test")
Expand All @@ -42,8 +45,8 @@ def test_vf_unknown():
@pytest.mark.integration
def test_vf_onboard_unknown():
"""Integration tests for Vf."""
Vendor.base_front_url = "http://sdc.api.fe.simpledemo.onap.org:30206"
Vendor.base_back_url = Vendor.base_front_url
SDC.base_front_url = SDC_MOCK_URL
SDC.base_back_url = SDC_MOCK_URL
response = requests.post("{}/reset".format(Vendor.base_front_url))
response.raise_for_status()
vendor = Vendor(name="test")
Expand Down
16 changes: 6 additions & 10 deletions integration_tests/test_04_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
from onapsdk.service import Service
import onapsdk.constants as const

from .urls import SDC_MOCK_URL


@pytest.mark.integration
def test_service_unknown():
"""Integration tests for Service."""
SDC.base_front_url = "http://sdc.api.fe.simpledemo.onap.org:30206"
SDC.base_back_url = Vendor.base_front_url
SDC.base_front_url = SDC_MOCK_URL
SDC.base_back_url = SDC_MOCK_URL
response = requests.post("{}/reset".format(SDC.base_front_url))
response.raise_for_status()
vendor = Vendor(name="test")
Expand All @@ -39,23 +41,17 @@ def test_service_unknown():
svc.add_resource(vf)
svc.checkin()
assert svc.status == const.CHECKED_IN
svc.submit()
assert svc.status == const.SUBMITTED
svc.start_certification()
assert svc.status == const.UNDER_CERTIFICATION
svc.certify()
assert svc.status == const.CERTIFIED
svc.approve()
assert svc.status == const.APPROVED
svc.distribute()
assert svc.status == const.DISTRIBUTED
assert svc.distributed

@pytest.mark.integration
def test_service_onboard_unknown():
"""Integration tests for Service."""
SDC.base_front_url = "http://sdc.api.fe.simpledemo.onap.org:30206"
SDC.base_back_url = Vendor.base_front_url
SDC.base_front_url = SDC_MOCK_URL
SDC.base_back_url = SDC_MOCK_URL
response = requests.post("{}/reset".format(SDC.base_front_url))
response.raise_for_status()
vendor = Vendor(name="test")
Expand Down
Loading

0 comments on commit b73f782

Please sign in to comment.