Skip to content

Commit

Permalink
Merge pull request #141 from EVOLVED-5G/pipelinesv1
Browse files Browse the repository at this point in the history
Pipelinesv1
  • Loading branch information
EVOLVED5G authored Jun 14, 2023
2 parents 0ffa86e + 11cb5b8 commit c338763
Show file tree
Hide file tree
Showing 12 changed files with 257 additions and 144 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ History
* The SDK classes LocationSubscriber,ConnectionMonitor,QosAwareness don't accept the parameter 'nef_bearer_access_token' any more.
* The CLI method register_and_onboard_to_capif now accepts a second parameter --environment that takes values "production" or "development".
If this parameter is set to production then validation tests are running in the background, just after the registration and onboarding of the network app finishes.
* The CLI command run-verification-tests now required three inputs (capif registration file, certificates folder and verification file) to launch NEF and TSN verification pipelines.

-------------------
1.0.5 (2023-05-24)
Expand Down
22 changes: 22 additions & 0 deletions docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: source/conf.py

# We recommend specifying your dependencies to enable reproducible builds:
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
14 changes: 8 additions & 6 deletions docs/source/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ Now, you can execute ``evolved5g generate --config-file <path-to-your-config.yam

.. figure:: images/generate.gif

If you access GitHub once you have seen that output in your terminal, you will see that the repository has been successfully created:
Then the repository is created in your local computer as well as remotely in GitHub.

.. image:: images/repo_creation.png
.. figure:: images/netapp_creation.gif

It will create a specific branch (evolved5g) which will be used by the CI/CD for verification purposes. A dummy example will be created in both branches (master and evolved5g) which allow to directly run a pipeline using such branch. You will see a Dockerfile and inside the src folder a dummy html file as an example. Below can see the file structure created.
If you go to https://github.com/EVOLVED-5G you will see that the repository has been successfully created:

.. image:: images/repo_structure.png
.. image:: images/repo_creation.png

It will create a specific branch (evolved5g) which will be used by the CI/CD for verification and validation purposes. An example is provided in master branch. You will see the src folder with a docker compose and a script (run.sh) to launch the Network App.
It is important to remind that in order to have a fully functional example, it is mandatory to have NEF and CAPIF already up and running in your machine/container. Below can see the file structure created.

.. image:: images/dummy_html_example.png
.. image:: images/repo_structure.png

When the repository is created you will be at branch evolved5g, so the push must be done there, in case you want to work with master (branch) you have to execute git checkout master and then do the push ``git push -u origin master``, to know in which branch you are, just execute git branch.
.. figure:: images/netapp_repo.gif
Binary file modified docs/source/images/generate.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/netapp_creation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/netapp_repo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/images/repo_creation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/images/repo_structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 16 additions & 8 deletions docs/source/pipelines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,41 @@ Examples of usage

.. code-block:: console
evolved5g run-verification-tests --mode build --repo REPOSITORY_NAME
evolved5g run-verification-tests --mode build --repo REPOSITORY_NAME --user USERNAME --passwd USER_PASSWORD
.. code-block:: console
evolved5g run-verification-tests --mode deploy --repo REPOSITORY_NAME
evolved5g run-verification-tests --mode deploy --repo REPOSITORY_NAME --user USERNAME --passwd USER_PASSWORD
.. code-block:: console
evolved5g run-verification-tests --mode destroy --repo REPOSITORY_NAME
evolved5g run-verification-tests --mode destroy --repo REPOSITORY_NAME --user USERNAME --passwd USER_PASSWORD
.. code-block:: console
evolved5g run-verification-tests --mode code_analysis --repo REPOSITORY_NAME
evolved5g run-verification-tests --mode code_analysis --repo REPOSITORY_NAME --user USERNAME --passwd USER_PASSWORD
.. code-block:: console
evolved5g run-verification-tests --mode security_scan --repo REPOSITORY_NAME
evolved5g run-verification-tests --mode security_scan --repo REPOSITORY_NAME --user USERNAME --passwd USER_PASSWORD
.. code-block:: console
evolved5g run-verification-tests --mode capif_nef --repo REPOSITORY_NAME
evolved5g run-verification-tests --mode capif_nef --repo REPOSITORY_NAME --user USERNAME --passwd USER_PASSWORD --capifpath PATH_TO_CAPIF_REGISTRATION_JSON --certpath CERTIFICATES_FOLDER_STORE --verfpath FILE_TO_VERIFY
.. code-block:: console
evolved5g check-job --id YOUR_ID
evolved5g run-verification-tests --mode capif_nef --repo REPOSITORY_NAME --user USERNAME --passwd USER_PASSWORD --capifpath PATH_TO_CAPIF_REGISTRATION_JSON --certpath CERTIFICATES_FOLDER_STORE --verfpath FILE_TO_VERIFY
The pipelines build, deploy, destroy, code_analysis or security_scan will return an **ID** which can be used with the command :py:func:`check-job` to see how the NetApp is performing.
.. code-block:: console
evolved5g validation --repo FogusNetApp --user USERNAME --passwd USER_PASSWORD --environment ENVIRONMENT_TO_DEPLOY
.. code-block:: console
evolved5g check-job --id YOUR_ID --user USERNAME --passwd USER_PASSWORD
The verification pipelines (build, deploy, destroy, code_analysis, security_scan, capif_nef and capif_tsn) will return an **ID** which can be used with the command :py:func:`check-job` to see how the NetApp is performing.

Very important
^^^^^^^^^^^^^^
Expand Down
46 changes: 31 additions & 15 deletions evolved5g/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def cli(ctx):

@cli.command()
@click.option(
"--config-file", type=str, help="Provide User config location for custom package"
"--config-file", required=True, type=str, help="Provide User config location for custom package"
)
@click.pass_context
def generate(ctx, config_file):
Expand All @@ -27,29 +27,47 @@ def generate(ctx, config_file):
@click.option(
"--mode",
type=click.Choice(
["build", "deploy", "destroy", "capif_nef", "capif_tsn", "code_analysis", "security_scan", "validation"],
["build", "deploy", "destroy", "capif_nef", "capif_tsn", "code_analysis", "security_scan"],
case_sensitive=False,
),
)
@click.option("--repo", type=str, help="Enter repo name")
@click.option("--user", type=str, help="Enter your username for pipelines")
@click.option("--passwd", type=str, help="Enter repo password for pipelines")
@click.option("--repo", required=True, type=str, help="Enter repo name")
@click.option("--user", required=True, type=str, help="Enter your username for pipelines")
@click.option("--passwd", required=True, type=str, help="Enter repo password for pipelines")
@click.option("--capifpath", required=False, default=None, show_default=True, type=str, help="(Only for NEF and CAPIF) Path where to find the CAPIF registration configuration file (json)")
@click.option("--certpath", required=False, default=None, show_default=True, type=str, help="(Only for NEF and CAPIF) Folder path where to store the certification files")
@click.option("--verfpath", required=False, default=None, show_default=True, type=str, help="(Only for NEF and CAPIF) Path for the python file to verify")
@click.option("--version", required=False, default=4.0, show_default=True, type=str, help="Network App version")

@click.pass_context
def run_verification_tests(ctx, mode, repo, user, passwd):
def run_verification_tests(ctx, mode, repo, user, passwd, capifpath, certpath, verfpath, version):
"""Launch different verification tests"""
ctx.obj["helper"].run_verification_tests(mode, repo, user, passwd)

ctx.obj["helper"].run_verification_tests(mode, repo, user, passwd, capifpath, certpath, verfpath, version)

@cli.command()
@click.option("--id", type=int, help="Enter pipeline id")
@click.option("--user", type=str, help="Enter your username for pipelines")
@click.option("--passwd", type=str, help="Enter repo password for pipelines")
@click.option("--id", required=True, type=int, help="Enter pipeline id")
@click.option("--user", required=True, type=str, help="Enter your username for pipelines")
@click.option("--passwd", required=True, type=str, help="Enter repo password for pipelines")

@click.pass_context
def check_job(ctx, id, user, passwd):
"""Check the status of a pipeline"""
ctx.obj["helper"].check_job(id, user, passwd)

@cli.command()
@click.option("--repo", required=True, type=str, help="Enter repo name")
@click.option("--user", required=True, type=str, help="Enter your username for pipelines")
@click.option("--passwd", required=True, type=str, help="Enter repo password for pipelines")
@click.option("--environment", required=False, show_default=True, default="openshift", type=str, help="Enter the environment to deploy the NetApp (openshift, kubernetes-athens, kubernetes-uma)")
@click.option("--deploy", required=False, type=str, help="Network App deployment name")
@click.option("--email", required=False, default=False, type=str, help="Developer email to receive the report")
@click.option("--version", required=False, default=4.0, show_default=True, type=str, help="Network App version")

@click.pass_context
def validation(ctx, repo, user, passwd, environment, deploy, email, version):
"""Launch the validation tests"""
ctx.obj["helper"].validation(repo, user, passwd, environment, deploy, email, version)

@cli.command()
@click.option(
Expand All @@ -73,12 +91,10 @@ def check_job(ctx, id, user, passwd):
--csr_email_address: The email that will be used in the generated X.509 certificate
""",
)
@click.option('--environment',type=click.Choice(['production', 'development'], case_sensitive=False))
@click.pass_context
def register_and_onboard_to_capif(ctx, config_file_full_path: str, environment:str):
def register_and_onboard_to_capif(ctx, config_file_full_path: str):
ctx.obj["helper"].register_and_onboard_to_capif(config_file_full_path)
if (environment =="production"):
ctx.obj["helper"].validate_all_endpoints_returned_by_service_discoverer(config_file_full_path)
# ctx.obj["helper"].test_capif_and_nef_published_to_capif_endpoints(config_file_full_path)


@cli.command()
Expand Down
Loading

0 comments on commit c338763

Please sign in to comment.