How to Run Locally
Capif services are developed under services folder.
Run All CAPIF Services locally with Docker images
To run using docker and docker compose, version 2.10 or higher, you must ensure you have those tools installed in your machine. Also to simplify the process, we have 3 scripts allowing docker images to deploy, check and cleanup.
All these scripts are available under services directory.
To run CAPIF APIs locally using docker and docker-compose you can use run.sh script:
./run.sh -h
Usage: ./run.sh [environment] [options]
environment Optional. Environment name to use (e.g. dev, prod).
If not specified, 'dev' will be used by default.
Options:
-c : Setup different hostname for capif
-a : Setup different hostname for vault
-R : Setup different hostname for register service
-s : Run Mock server. Default true
-m : Run monitoring service
-l : Set Log Level (default DEBUG). Select one of: [CRITICAL, FATAL, ERROR, WARNING, WARN, INFO, DEBUG, NOTSET]
-r : Remove cached information on build
-v : Set OCF version of images
-f : Services directory. (Default $SERVICES_DIR)
-g : Gitlab base URL. (Default $REGISTRY_BASE_URL)
-b : Build docker images. Default TRUE
-h : show this help
This script builds and runs all services using docker images, including mongodb and nginx locally and in the background, and imports ca.crt to nginx. By default monitoring is not activated and Nginx is deployed use capifcore as a hostname.
Some examples of use:
# Default values, No monitoring and capifcore as CAPIF_HOSTNAME
./run.sh
# opencapif.etsi.org as CAPIF_HOSTNAME
./run.sh -c opencapif.etsi.org
# opencapif.etsi.org as CAPIF_HOSTNAME and monitoring activated
./run.sh -c opencapif.etsi.org -m
IMPORTANT NOTE: In some versions change of hostname in local deployment (setting some value different than capifcore) creates wrong certificates on vault component. This prevents successful requests using the certificates. if this is your case, here is a little workaround to solve this issue meanwhile SDG is solving it:
- Modify the hostname in the file capif/services/vault/vault_prepare_certs.sh on lines 43, 68, and 95.
- Update the url parameter of the CCF from capifcore to the desired hostname in the file capif/services/register/config.yaml.
If you want to check if all CAPIF services are running properly in a local machine after executing run.sh, you can use:
./check_services_are_running.sh
This shell script will return 0 if all services are running properly.
When we need to stop all CAPIF services, we can use next bash script:
./clean_capif_docker_services.sh -a
NOTE: You can use different flags if you only want to stop some of them, please check the help using:
./clean_capif_docker_services.sh -h
Usage: ./clean_capif_docker_services.sh [environment] [options]
environment Optional. Environment name to use (e.g. dev, prod).
If not specified, 'dev' will be used by default.
Options:
-c : Clean capif services
-v : Clean vault service
-r : Clean register service
-m : Clean monitoring service
-s : Clean Robot Mock service
-a : Clean all services
-z : Clean images generated by docker-compose. Boolean. Default false
-h : show this help
This shell script will remove and clean all CAPIF services started previously with run.sh
On the other hand you can check logs using show_logs.sh script, please check options:
./show_logs.sh -h
Usage: ./show_logs.sh [environment] [options]
environment Optional. Environment name to use (e.g. dev, prod).
If not specified, 'dev' will be used by default."
Options:
-c : Show capif services
-v : Show vault service
-r : Show register service
-s : Show Robot Mock Server service
-m : Show monitoring service
-a : Show all services
-f : Follow log output
-h : Show this help
Run All CAPIF Services locally with Docker images and deploy monitoring stack
It is now possible to deploy a monitoring stack for CAPIF with Grafana, Prometheus, FluentBit, Loki, Cadvisor, Tempo and Opentelemetry.
To deploy CAPIF together with the monitoring stack, it is only necessary to execute the following.
./run.sh -m true
After they have been built, the different panels can be consulted in Grafana at the url
http://localhost:3000
By default, the monitoring option is set to false. Once up, all data sources and dashboards are automatically provisioned.
Run each service using Docker
Also you can run OpenCAPIF service by service using docker:
cd <Service>
docker build -t capif_security .
docker run -p 8080:8080 capif_security
Run each service using Python
Run using python
cd <Service>
pip3 install -r requirements.txt
python3 -m <service>
Other Local Scripts
Here there is a little explanation of each script present under services directory.
All scripts have helm, you can run ./
| Script | Description |
|---|---|
| clean_mock_server.sh | This script is used to undeploy local mock server. |
| create_users.sh | Create users at local deployment. |
| remove_users.sh | Delete users at local deployment. |
| run_capif_tests.sh | Run Capif tests by using robot image. |
| run_interonnection_environments.sh | Deploy locally two instances of OpenCAPIF. You must specify the envs to be used. |
| run_mock_server.sh | Deploy locally the mock server instance. |
| run.sh | Deploy locally an OpenCAPIF Instance. |
| show_logs.sh | Shows the logs of local deployed OpenCAPIF Services. |
| variables.sh | This script just set default values to be used by local environment. Can be overrided by envs files. |
Start Your Testing with OpenCAPIF
Related with OpenCAPIF Testing, the following sections help you to understand testing implemented and how to run it by yourself:
- Test Plan Directory: Here you can find the complete test plan definition that are accomplish by all versions released of OpenCAPIF.
- Testing with Robot Framework: At this section you can find all information about how to run the test suite implemented using Robot Framework.
- Testing with Postman: Easy way to understand the complete basic OpenCAPIF flow, acting as invoker and provider.