From de4e9a662ac704b20c66d008560bdf6aec57e19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Bonnet?= Date: Mon, 27 Aug 2018 11:58:38 +0100 Subject: [PATCH 01/13] Fix route of the test execution endpoint --- tng-router/config/vnv_routes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tng-router/config/vnv_routes.yml b/tng-router/config/vnv_routes.yml index 9a64fb2..65f66d7 100644 --- a/tng-router/config/vnv_routes.yml +++ b/tng-router/config/vnv_routes.yml @@ -47,7 +47,7 @@ paths: site: http://tng-gtk-common:5000/functions verbs: [ get, options ] /api/v3/tests/plans(/?|/*): - site: http://tng-gtk-vnv:5000/ + site: http://tng-gtk-vnv:5000/plans verbs: [ get, post, options ] /api/v3/tests(/?|/*): site: http://tng-gtk-vnv:5000/ From 12d5183f6a5aca251ffd06b3f68e5b110bd26eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Bonnet?= Date: Tue, 28 Aug 2018 23:18:32 +0200 Subject: [PATCH 02/13] Fix tests/plans routes --- tng-router/config/vnv_routes.yml | 2 +- tng-router/spec/unit/upstream_finder_spec.rb | 82 +++++++++++++------- 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/tng-router/config/vnv_routes.yml b/tng-router/config/vnv_routes.yml index 65f66d7..c3851a9 100644 --- a/tng-router/config/vnv_routes.yml +++ b/tng-router/config/vnv_routes.yml @@ -47,7 +47,7 @@ paths: site: http://tng-gtk-common:5000/functions verbs: [ get, options ] /api/v3/tests/plans(/?|/*): - site: http://tng-gtk-vnv:5000/plans + site: http://tng-gtk-vnv:5000/tests/plans verbs: [ get, post, options ] /api/v3/tests(/?|/*): site: http://tng-gtk-vnv:5000/ diff --git a/tng-router/spec/unit/upstream_finder_spec.rb b/tng-router/spec/unit/upstream_finder_spec.rb index 1276621..28dbdf6 100644 --- a/tng-router/spec/unit/upstream_finder_spec.rb +++ b/tng-router/spec/unit/upstream_finder_spec.rb @@ -35,40 +35,66 @@ RSpec.describe UpstreamFinder do let(:app) { ->(env) { [200, env, "app"] } } let(:base_path) {''} - let(:paths) {{ - :"/api/v3/packages(/?|/*)"=>{:site=>"http://tng-gtk-common:5000/packages", :verbs=>["get", "post"]}, - :"/api/v3/services(/?|/*)"=>{:site=>"http://tng-gtk-common:5000/services"}, - :"/api/v3/functions(/?|/*)"=>{:site=>"http://tng-gtk-common:5000/functions"}, - :"/api/v3/records(/?|/*)"=>{:site=>"http://tng-gtk-common:5000/records"}, - :"/slices(/?|/*)"=>{:site=>"http://tng-slice-mngr:5998", :verbs=>["get", "post", "delete"]}, - :"/policies(/?|/*)"=>{:site=>"http://tng-policy-mngr:8081"}, - :"/slas(/?|/*)"=>{:site=>"http://tng-sla-mgmt:8080"}}} - let(:middleware) { described_class.new(app, base_path: base_path, paths: paths) } + context 'Service Platform' do + let(:paths) {{ + :"/api/v3/packages(/?|/*)"=>{:site=>"http://tng-gtk-common:5000/packages", :verbs=>["get", "post"]}, + :"/api/v3/services(/?|/*)"=>{:site=>"http://tng-gtk-common:5000/services"}, + :"/api/v3/functions(/?|/*)"=>{:site=>"http://tng-gtk-common:5000/functions"}, + :"/api/v3/records(/?|/*)"=>{:site=>"http://tng-gtk-common:5000/records"}, + :"/slices(/?|/*)"=>{:site=>"http://tng-slice-mngr:5998", :verbs=>["get", "post", "delete"]}, + :"/policies(/?|/*)"=>{:site=>"http://tng-policy-mngr:8081"}, + :"/slas(/?|/*)"=>{:site=>"http://tng-sla-mgmt:8080"}}} + let(:middleware) { described_class.new(app, base_path: base_path, paths: paths) } - it "processes GET requests" do - env = env_for('http://example.com/api/v3/packages/status/123', request_method: 'GET', - '5gtango.sink_path'=>'http://tng-gtk-common:5000/packages', '5gtango.logger'=> Logger.new(STDERR)) - code, env = middleware.call(env) - expect(code).to eq(200) - expect(env['5gtango.sink_path']).to eq('http://tng-gtk-common:5000/packages/status/123') + it "processes GET requests" do + env = env_for('http://example.com/api/v3/packages/status/123', request_method: 'GET', + '5gtango.sink_path'=>'http://tng-gtk-common:5000/packages', '5gtango.logger'=> Logger.new(STDERR)) + code, env = middleware.call(env) + expect(code).to eq(200) + expect(env['5gtango.sink_path']).to eq('http://tng-gtk-common:5000/packages/status/123') + end + + describe '.build_path' do + it 'is ok for /packages' do + env = env_for('http://example.com/api/v3/packages', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-common:5000/packages' + end + it 'is ok for /packages/' do + env = env_for('http://example.com/api/v3/packages/', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-common:5000/packages' + end + it 'is ok for /packages?page_number=0&page_size=100' do + env = env_for('http://example.com/api/v3/packages?page_number=0&page_size=100', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-common:5000/packages?page_number=0&page_size=100' + end + it 'is ok for /packages/status/:uuid' do + env = env_for('http://example.com/api/v3/packages/status/123', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-common:5000/packages/status/123' + end + end end - describe '.build_path' do - it 'is ok for /packages' do - env = env_for('http://example.com/api/v3/packages', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) - expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-common:5000/packages' + context 'V&V Platform' do + let(:paths) {{ + :"/api/v3/tests/plans(/?|/*)"=>{:site=>"http://tng-gtk-vnv:5000/tests/plans", :verbs=>["get", "post", "options"]}, + :"/api/v3/tests(/?|/*)"=>{:site=>"http://tng-gtk-vnv:5000/tests", :verbs=>["get", "options"]} + }} + let(:middleware) { described_class.new(app, base_path: base_path, paths: paths) } + it 'is ok for POSTing /tests/plans' do + env = env_for('http://example.com/api/v3/tests/plans', request_method: 'POST', '5gtango.logger'=> Logger.new(STDERR)) + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/tests/plans' end - it 'is ok for /packages/' do - env = env_for('http://example.com/api/v3/packages/', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) - expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-common:5000/packages' + it 'is ok for GETing /tests/plans' do + env = env_for('http://example.com/api/v3/tests/plans', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/tests/plans' end - it 'is ok for /packages?page_number=0&page_size=100' do - env = env_for('http://example.com/api/v3/packages?page_number=0&page_size=100', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) - expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-common:5000/packages?page_number=0&page_size=100' + it 'is ok for GETing /tests/plans' do + env = env_for('http://example.com/api/v3/tests/descriptors', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/tests/descriptors' end - it 'is ok for /packages/status/:uuid' do - env = env_for('http://example.com/api/v3/packages/status/123', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) - expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-common:5000/packages/status/123' + it 'is ok for GETing /tests/plans' do + env = env_for('http://example.com/api/v3/tests/results', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/tests/results' end end def env_for url, opts={} From a38caab058ee7f3f6b7ffb67141b46c38d12e94b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Bonnet?= Date: Wed, 29 Aug 2018 11:00:02 +0200 Subject: [PATCH 03/13] Fix test/plans POST route --- tng-router/config/vnv_routes.yml | 2 +- tng-router/spec/unit/upstream_finder_spec.rb | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tng-router/config/vnv_routes.yml b/tng-router/config/vnv_routes.yml index c3851a9..65f66d7 100644 --- a/tng-router/config/vnv_routes.yml +++ b/tng-router/config/vnv_routes.yml @@ -47,7 +47,7 @@ paths: site: http://tng-gtk-common:5000/functions verbs: [ get, options ] /api/v3/tests/plans(/?|/*): - site: http://tng-gtk-vnv:5000/tests/plans + site: http://tng-gtk-vnv:5000/plans verbs: [ get, post, options ] /api/v3/tests(/?|/*): site: http://tng-gtk-vnv:5000/ diff --git a/tng-router/spec/unit/upstream_finder_spec.rb b/tng-router/spec/unit/upstream_finder_spec.rb index 28dbdf6..4f05a3c 100644 --- a/tng-router/spec/unit/upstream_finder_spec.rb +++ b/tng-router/spec/unit/upstream_finder_spec.rb @@ -76,25 +76,25 @@ context 'V&V Platform' do let(:paths) {{ - :"/api/v3/tests/plans(/?|/*)"=>{:site=>"http://tng-gtk-vnv:5000/tests/plans", :verbs=>["get", "post", "options"]}, - :"/api/v3/tests(/?|/*)"=>{:site=>"http://tng-gtk-vnv:5000/tests", :verbs=>["get", "options"]} + :"/api/v3/tests/plans(/?|/*)"=>{:site=>"http://tng-gtk-vnv:5000/plans", :verbs=>["get", "post", "options"]}, + :"/api/v3/tests(/?|/*)"=>{:site=>"http://tng-gtk-vnv:5000", :verbs=>["get", "options"]} }} let(:middleware) { described_class.new(app, base_path: base_path, paths: paths) } it 'is ok for POSTing /tests/plans' do env = env_for('http://example.com/api/v3/tests/plans', request_method: 'POST', '5gtango.logger'=> Logger.new(STDERR)) - expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/tests/plans' + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/plans' end it 'is ok for GETing /tests/plans' do env = env_for('http://example.com/api/v3/tests/plans', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) - expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/tests/plans' + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/plans' end - it 'is ok for GETing /tests/plans' do + it 'is ok for GETing /tests/descriptors' do env = env_for('http://example.com/api/v3/tests/descriptors', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) - expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/tests/descriptors' + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/descriptors' end - it 'is ok for GETing /tests/plans' do + it 'is ok for GETing /tests/results' do env = env_for('http://example.com/api/v3/tests/results', request_method: 'GET', '5gtango.logger'=> Logger.new(STDERR)) - expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/tests/results' + expect(middleware.build_path(Rack::Request.new(env))).to eq 'http://tng-gtk-vnv:5000/results' end end def env_for url, opts={} From ae06a460a687b4b49fc294327bf1c5e5d82098d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Bonnet?= Date: Wed, 25 Jul 2018 15:31:23 +0300 Subject: [PATCH 04/13] Update README.md --- tng-sec-gtw/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tng-sec-gtw/README.md b/tng-sec-gtw/README.md index 634fc45..d5c3ef8 100644 --- a/tng-sec-gtw/README.md +++ b/tng-sec-gtw/README.md @@ -15,7 +15,7 @@ The tng-sec-gtw will enable a security layer for SONATA (powered by 5GTANGO) Ver +----------------+ +---------------+ https | | http | | - +---------^+ tng-api-gtw +----------------> tng-router | + +---------^+ tng-sec-gtw +----------------> tng-router | | | | | | +----------------+ | +---------------+ | @@ -33,16 +33,16 @@ To use this module you can do it by this way: $ docker network create tango $ docker run -d -p 80:80 --net=tango --name tng-portal sonatanfv/tng-portal:4.0 $ docker run -d -p 5000:5000 --net=tango --name tng-router sonatanfv/tng-router:4.0 -$ docker run -d -p 80:80 -p 443:443 -v /etc/ssl/private/sonata/:/etc/nginx/cert/ --net=tango --name tng-api-gtw \ +$ docker run -d -p 80:80 -p 443:443 -v /etc/ssl/private/sonata/:/etc/nginx/cert/ --net=tango --name tng-sec-gtw \ -e ROUTES_FILE=sp_routes.yml \ - sonatanfv/tng-api-gtw:4.0 + sonatanfv/tng-sec-gtw:4.0 ``` With these commands, you: 1. Create a `docker` network named `tango`; 1. Run the [Portal](https://github.com/sonata-nfv/tng-portal) container within the `tango` network; -1. Run the [Router](https://github.com/sonata-nfv/tng-sec-gtw/tng-router) container within the `tango` network; -1. Run the [API Gateway](https://github.com/sonata-nfv/tng-sec-gtw/tng-api-gtw) container within the `tango` network. +1. Run the [Router](https://github.com/sonata-nfv/tng-sec-gtw/tree/master/tng-router) container within the `tango` network; +1. Run the [Security Gateway](https://github.com/sonata-nfv/tng-api-gtw/tree/master/tng-sec-gtw) container within the `tango` network. OPTIONS: * `--name`: Container name (Optional) From edb371b082ab0e92d9e41256dbc0b47c2a10ea51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Bonnet?= Date: Wed, 25 Jul 2018 15:31:58 +0300 Subject: [PATCH 05/13] Update README.md --- tng-sec-gtw/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tng-sec-gtw/README.md b/tng-sec-gtw/README.md index d5c3ef8..bf96100 100644 --- a/tng-sec-gtw/README.md +++ b/tng-sec-gtw/README.md @@ -41,7 +41,7 @@ With these commands, you: 1. Create a `docker` network named `tango`; 1. Run the [Portal](https://github.com/sonata-nfv/tng-portal) container within the `tango` network; -1. Run the [Router](https://github.com/sonata-nfv/tng-sec-gtw/tree/master/tng-router) container within the `tango` network; +1. Run the [Router](https://github.com/sonata-nfv/tng-api-gtw/tree/master/tng-router) container within the `tango` network; 1. Run the [Security Gateway](https://github.com/sonata-nfv/tng-api-gtw/tree/master/tng-sec-gtw) container within the `tango` network. OPTIONS: From 18c35e1ec3ad8e3e414e66b6b708f8f25bdcbdcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Bonnet?= Date: Wed, 25 Jul 2018 15:39:50 +0300 Subject: [PATCH 06/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5aeaf9b..06e20fe 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ For further details on those components, please check their README files ## Versioning -For the versions available, see the [link toreleases on this repository](/releases). +For the versions available, see the [link to releases on this repository](/releases). ## Licensing From 3e335493164b6bb8a6be9213b0efa35ba13b32da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Bonnet?= Date: Fri, 27 Jul 2018 09:36:07 +0100 Subject: [PATCH 07/13] Update README.md --- tng-router/README.md | 153 +++++++++++++++++++++++++------------------ 1 file changed, 88 insertions(+), 65 deletions(-) diff --git a/tng-router/README.md b/tng-router/README.md index 3be1614..fd384a8 100644 --- a/tng-router/README.md +++ b/tng-router/README.md @@ -3,105 +3,135 @@

-# 5GTANGO API Router -This is the 5GTANGO API Router for the Verification&Validation and Service Platforms (built on top of [SONATA](https://github.com/sonata-nfv)) repository. +# API Router +This is the 5GTANGO Gatekeeper API Router for the Verification&Validation and Service Platforms (built on top of [SONATA](https://github.com/sonata-nfv)) component. -## Installing / Getting started - -The 5GTANGO API Router is a routing micro-service that is part of the [tng-api-gtw](https://github.com/sonata-nfv/tng-api-gtw). +Please see [details on the overall 5GTANGO architecture here](https://5gtango.eu/project-outcomes/deliverables/2-uncategorised/31-d2-2-architecture-design.html). The Gatekeeper is the component highlighted in the following picture. -A quick introduction of the minimal setup you need to get a hello world up & -running. +

-```shell -commands here -``` +## Installing / Getting started -Here you should say what actually happens when you execute the code above. +This component is implemented in [ruby](https://www.ruby-lang.org/en/), version **2.4.3**, and is part of the [tng-api-gtw](https://github.com/sonata-nfv/tng-api-gtw). -## Developing +### Installing from code -### Built With -List main libraries, frameworks used including versions (React, Angular etc...) +To have it up and running from code, please do the following: -### Prerequisites -What is needed to set up the dev environment. For instance, global dependencies or any other tools. include download links. +```shell +$ git clone https://github.com/sonata-nfv/tng-gtk-vnv.git # Clone this repository +$ cd tng-gtk-vnv # Go to the newly created folder +$ bundle install # Install dependencies +$ PORT=5000 bundle exec rackup # dev server at http://localhost:5000 +``` +Everything being fine, you'll have a server running on that session, on port `5000`. You can use it by using `curl`, like in: -### Setting up Dev +```shell +$ curl :5000/ +``` -Here's a brief intro about what a developer must do in order to start developing -the project further: +### Installing from the Docker container +In case you prefer a `docker` based development, you can run the following commands (`bash` shell): ```shell -git clone https://github.com/your/your-project.git -cd your-project/ -packagemanager install +$ docker network create tango +$ docker run -d -p 27017:27017 --net=tango --name mongo mongo +$ docker run -d -p 4011:4011 --net=tango --name tng-cat sonatanfv/tng-cat:dev +$ docker run -d -p 4012:4012 --net=tango --name tng-rep sonatanfv/tng-rep:dev +$ docker run -d -p 5000:5000 --net=tango --name tng-gtk-vnv \ + -e CATALOGUE_URL=http://tng-cat:4011/catalogues/api/v2 \ + -e REPOSITORY_URL=http://tng-cat:4012 \ + sonatanfv/tng-gtk-vnv:dev ``` +With these commands, you: -And state what happens step-by-step. If there is any virtual environment, local server or database feeder needed, explain here. +1. Create a `docker` network named `tango`; +1. Run the [MongoDB](https://www.mongodb.com/) container within the `tango` network; +1. Run the [Catalogue](https://github.com/sonata-nfv/tng-cat) container within the `tango` network; +1. Run the [Repository](https://github.com/sonata-nfv/tng-rep) container within the `tango` network; +1. Run the [V&V-specific Gatekeeper](https://github.com/sonata-nfv/tng-gtk-vnv) container within the `tango` network, with the `CATALOGUE_URL` and `REPOSITORY_URL` environment variables set to the previously created containers. -### Building +## Developing +This section covers all the needs a developer has in order to be able to contribute to this project. -If your project needs some additional steps for the developer to build the -project after some code changes, state them here. for example: +### Built With +We are using the following libraries (also referenced in the [`Gemfile`](https://github.com/sonata-nfv/tng-gtk-vnv/Gemfile) file) for development: -```shell -./configure -make -make install -``` +* `puma` (`3.11.0`), an application server; +* `rack` (`2.0.4`), a web-server interfacing library, on top of which `sinatra` has been built; +* `rake`(`12.3.0`), a dependencies management tool for ruby, similar to *make*; +* `sinatra` (`2.0.2`), a web framework for implementing efficient ruby APIs; +* `sinatra-contrib` (`2.0.2`), several add-ons to `sinatra`; +* `sinatra-cross_origin` (`0.4.0`), a *middleware* to `sinatra` that helps in managing the [`Cross Origin Resource Sharing (CORS)`](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) problem; -Here again you should state what actually happens when the code above gets -executed. +The following *gems* (libraries) are used just for tests: +* `ci_reporter_rspec` (`1.0.0`), a library for helping in generating continuous integration (CI) test reports; +* `rack-test` (`0.8.2`), a helper testing framework for `rack`-based applications; +* `rspec` (`3.7.0`), a testing framework for ruby; +* `rubocop` (`0.52.0`), a library for white box tests; +* `rubocop-checkstyle_formatter` (`0.4.0`), a helper library for `rubocop`; +* `webmock` (`3.1.1`), which alows *mocking* (i.e., faking) HTTP calls; -### Deploying / Publishing -give instructions on how to build and release a new version -In case there's some step you have to take that publishes this project to a -server, this is the right time to state it. +These libraries are installed/updated in the developer's machine when running the command (see above): ```shell -packagemanager deploy your-project -s server.com -u username -p password +$ bundle install ``` -And again you'd need to tell what the previous code actually does. +### Prerequisites +We usually use [`rbenv`](https://github.com/rbenv/rbenv) as the ruby version manager, but others like [`rvm`](https://rvm.io/) may work as well. -## Versioning +### Setting up Dev +Developing this micro-service is straight-forward with a low amount of necessary steps. -We can maybe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [link to tags on this repository](/tags). +Routes within the micro-service are defined in the [`config.ru`](https://github.com/sonata-nfv/tng-gtk-vnv/blob/master/config.ru) file, in the root directory. It has two sections: +* The `require` section, where all used libraries must be required (**Note:** `controllers` had to be required explicitly, while `services` do not, due to a bug we have found to happened in some of the environments); +* The `map` section, where this micro-service's routes are mapped to the controller responsible for it. -## Configuration +This new or updated route can then be mapped either into an existing controller or imply writing a new controller. This new or updated controller can use either existing or newly written services to fullfil it's role. -This component's configuration is done strictly through `ENV` variables. +For further details on the micro-service's architecture please check the [documentation](https://github.com/sonata-nfv/tng-gtk-vnv/wiki/micro-service-architecture). -The following `ENV` variables must be defined: +### Submiting changes +Changes to the repository can be requested using [this repository's issues](https://github.com/sonata-nfv/tng-gtk-vnv/issues) and [pull requests](https://github.com/sonata-nfv/tng-gtk-vnv/pulls) mechanisms. -1. `PORT`, which sets the HTTP port to (default) `5000`; -1. `ROUTES_FILE`, which sets the name of the file defining active routes as `sp_routes.yml` (the default name, for the Service Platform; for the V&V Platform, the deployment defines this `ENV` variable as `vnv_routes.yml`). +## Versioning -## Tests +The most up-to-date version is v4. For the versions available, see the [link to tags on this repository](https://github.com/sonata-nfv/tng-gtk-vnv/releases). + +## Configuration +The configuration of the micro-service is done through just two environment variables, defined in the [Dockerfile](https://github.com/sonata-nfv/tng-gtk-vnv/blob/master/Dockerfile): -**Unit** tests can be ran by executing the following set of commands: +* `CATALOGUE_URL`, which should define the Catalogue's URL, where test descriptors are fetched from; +* `REPOSITORY_URL`, which should define the Repository's URL, where test plans and test results are fetched from; -```shell -$ cd tng-router -$ bundle exec rspec spec/ -``` +## Tests +Unit tests are defined for both `controllers` and `services`, in the `/spec` folder. Since we use `rspec` as the test library, we configure tests in the [`spec_helper.rb`](https://github.com/sonata-nfv/tng-gtk-vnv/blob/master/spec/spec_helper.rb) file, also in the `/spec` folder. -**Smoke** (end-to-end) tests can be executed by running +To run these tests you need to execute the follwoing command: ```shell -$ cd tests/integration -$ ./functionaltests.sh +$ CATALOGUE_URL=... REPOSITORY_URL=... bundle exec rspec spec ``` +Wider scope (integration and functional) tests involving this micro-service are defined in [`tng-tests`](https://github.com/sonata-nfv/tng-tests). ## Style guide +Our style guide is really simple: + +1. We try to follow a [Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882) philosophy in as much as possible, i.e., classes and methods should do one thing only, have the least number of parameters possible, etc.; +1. we use two spaces for identation. + + + + + -Explain your code style and show how to check it. ## Api Reference The current version supports an `api_root` like `http://pre-int-sp-ath.5gtango.eu:32002`. +We have specified this micro-service's API in a [swagger](https://github.com/sonata-nfv/tng-gtk-vnv/blob/master/doc/swagger.json)-formated file. Please check it there. ### Authentication and authorization TBD @@ -248,20 +278,13 @@ Expected returned data is: Check [this gist](https://gist.github.com/jbonnet/1887b09327ac9b0ebfcb000e283d79f3) for an example of the answer. -## Style guide - -Explain your code style and show how to check it. -## Api Reference -If the api is external, link to api documentation. If not describe your api including authentication methods as well as explaining all the endpoints with their required parameters. -## Database -Explaining what database (and version) has been used. Provide download links. -Documents your database design and schemas, relations etc... ## Licensing -State what the license is and how to find the text version of the license. +This 5GTANGO component is published under Apache 2.0 license. Please see the [LICENSE](https://github.com/sonata-nfv/tng-gtk-vnv/blob/master/LICENSE) file for more details. + From 7a882b8a2491402c4b8f946f43353189a1c051ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Bonnet?= Date: Fri, 27 Jul 2018 09:43:17 +0100 Subject: [PATCH 08/13] Updated LICENSE to the 5GTANGO --- LICENSE | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 175 insertions(+), 21 deletions(-) diff --git a/LICENSE b/LICENSE index 0a8df5c..e97bf01 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,175 @@ -MIT License - -Copyright (c) 2018 sonata-nfv - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + From c07397602c9e178fc15260d0a997b75a350ea8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Bonnet?= Date: Fri, 27 Jul 2018 09:44:00 +0100 Subject: [PATCH 09/13] Update README.md --- tng-router/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tng-router/README.md b/tng-router/README.md index fd384a8..f2b0970 100644 --- a/tng-router/README.md +++ b/tng-router/README.md @@ -286,5 +286,5 @@ Check [this gist](https://gist.github.com/jbonnet/1887b09327ac9b0ebfcb000e283d79 ## Licensing -This 5GTANGO component is published under Apache 2.0 license. Please see the [LICENSE](https://github.com/sonata-nfv/tng-gtk-vnv/blob/master/LICENSE) file for more details. +This 5GTANGO component is published under Apache 2.0 license. Please see the [LICENSE](https://github.com/sonata-nfv/tng-api-gtw/blob/master/LICENSE) file for more details. From e39d00352d65a1877f0961ae727fb6f54896736b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Bonnet?= Date: Fri, 27 Jul 2018 09:49:51 +0100 Subject: [PATCH 10/13] Update README.md --- tng-router/README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tng-router/README.md b/tng-router/README.md index f2b0970..ef5e90e 100644 --- a/tng-router/README.md +++ b/tng-router/README.md @@ -6,21 +6,17 @@ # API Router This is the 5GTANGO Gatekeeper API Router for the Verification&Validation and Service Platforms (built on top of [SONATA](https://github.com/sonata-nfv)) component. -Please see [details on the overall 5GTANGO architecture here](https://5gtango.eu/project-outcomes/deliverables/2-uncategorised/31-d2-2-architecture-design.html). The Gatekeeper is the component highlighted in the following picture. - -

- ## Installing / Getting started -This component is implemented in [ruby](https://www.ruby-lang.org/en/), version **2.4.3**, and is part of the [tng-api-gtw](https://github.com/sonata-nfv/tng-api-gtw). +This component is a [rack](https://rack.github.io/) application implemented in [ruby](https://www.ruby-lang.org/en/), version **2.4.3**, and is part of the [tng-api-gtw](https://github.com/sonata-nfv/tng-api-gtw). ### Installing from code To have it up and running from code, please do the following: ```shell -$ git clone https://github.com/sonata-nfv/tng-gtk-vnv.git # Clone this repository -$ cd tng-gtk-vnv # Go to the newly created folder +$ git clone https://github.com/sonata-nfv/tng-api-gtw.git # Clone the parent repository +$ cd tng-api-gtw # Go to the newly created folder $ bundle install # Install dependencies $ PORT=5000 bundle exec rackup # dev server at http://localhost:5000 ``` From 392721d372a01abfbbba44ba5ca5f4aa62a84d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Bonnet?= Date: Fri, 27 Jul 2018 14:12:33 +0100 Subject: [PATCH 11/13] Add /policies/placement route --- tng-router/config/sp_routes.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tng-router/config/sp_routes.yml b/tng-router/config/sp_routes.yml index 07d0c01..abc9069 100644 --- a/tng-router/config/sp_routes.yml +++ b/tng-router/config/sp_routes.yml @@ -64,6 +64,9 @@ paths: /api/v3/slice-instances(/?|/*): site: http://tng-slice-mngr:5998/api/nsilcm/v1/nsi verbs: [ get, post, delete, options ] + /api/v3/policies/placement(/?|/*): + site: http://tng-gtk-sp:5000/policies/placement + verbs: [ get, post, options] /api/v3/policies(/?|/*): site: http://tng-policy-mngr:8081/api/v1 verbs: [ get, post, delete, options, put, patch ] From e9082e0c8f9dffe02ff6d6ce45fc098c8a29f4a8 Mon Sep 17 00:00:00 2001 From: luishens01 Date: Tue, 31 Jul 2018 09:31:59 +0200 Subject: [PATCH 12/13] modify jenkinsfile --- Jenkinsfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e16cea7..454fd12 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,12 +10,12 @@ pipeline { } stage('tng-api-gtw') { steps { - sh 'docker build -t registry.sonata-nfv.eu:5000/tng-api-gtw -f tng-router/Dockerfile tng-router/' + sh 'docker build -t registry.sonata-nfv.eu:5000/tng-api-gtw:v4.0 -f tng-router/Dockerfile tng-router/' } } stage('tng-sec-gtw') { steps { - sh 'docker build -t registry.sonata-nfv.eu:5000/tng-sec-gtw -f tng-sec-gtw/Dockerfile tng-sec-gtw/' + sh 'docker build -t registry.sonata-nfv.eu:5000/tng-sec-gtw:v4.0 -f tng-sec-gtw/Dockerfile tng-sec-gtw/' } } } @@ -39,12 +39,12 @@ pipeline { } stage('tng-api-gtw') { steps { - sh 'docker push registry.sonata-nfv.eu:5000/tng-api-gtw' + sh 'docker push registry.sonata-nfv.eu:5000/tng-api-gtw:v4.0' } } stage('tng-sec-gtw') { steps { - sh 'docker push registry.sonata-nfv.eu:5000/tng-sec-gtw' + sh 'docker push registry.sonata-nfv.eu:5000/tng-sec-gtw:v4.0' } } } @@ -61,8 +61,8 @@ pipeline { sh 'rm -rf tng-devops || true' sh 'git clone https://github.com/sonata-nfv/tng-devops.git' dir(path: 'tng-devops') { - sh 'ansible-playbook roles/sp.yml -i environments -e "target=pre-int-sp-ath.5gtango.eu component=gatekeeper"' - sh 'ansible-playbook roles/vnv.yml -i environments -e "target=pre-int-vnv-bcn.5gtango.eu component=gatekeeper"' + sh 'ansible-playbook roles/sp.yml -i environments -e "target=sta-sp-v4.0 component=gatekeeper"' + sh 'ansible-playbook roles/vnv.yml -i environments -e "target=sta-sp-v4.0 component=gatekeeper"' } } } @@ -85,14 +85,14 @@ pipeline { } stage('tng-api-gtw') { steps { - sh 'docker tag registry.sonata-nfv.eu:5000/tng-api-gtw:latest registry.sonata-nfv.eu:5000/tng-api-gtw:int' - sh 'docker push registry.sonata-nfv.eu:5000/tng-api-gtw:int' + sh 'docker tag registry.sonata-nfv.eu:5000/tng-api-gtw:v4.0 registry.sonata-nfv.eu:5000/tng-api-gtw:v4.0' + sh 'docker push registry.sonata-nfv.eu:5000/tng-api-gtw:v4.0' } } stage('tng-sec-gtw') { steps { - sh 'docker tag registry.sonata-nfv.eu:5000/tng-sec-gtw:latest registry.sonata-nfv.eu:5000/tng-sec-gtw:int' - sh 'docker push registry.sonata-nfv.eu:5000/tng-sec-gtw:int' + sh 'docker tag registry.sonata-nfv.eu:5000/tng-sec-gtw:v4.0 registry.sonata-nfv.eu:5000/tng-sec-gtw:v4.0' + sh 'docker push registry.sonata-nfv.eu:5000/tng-sec-gtw:v4.0' } } } From 5b415983ad777091d0d67ab0c5c726bd787f675b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Bonnet?= Date: Wed, 29 Aug 2018 22:43:33 +0200 Subject: [PATCH 13/13] Delete extra '/' in route --- tng-router/config/vnv_routes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tng-router/config/vnv_routes.yml b/tng-router/config/vnv_routes.yml index 65f66d7..49ca61b 100644 --- a/tng-router/config/vnv_routes.yml +++ b/tng-router/config/vnv_routes.yml @@ -50,5 +50,5 @@ paths: site: http://tng-gtk-vnv:5000/plans verbs: [ get, post, options ] /api/v3/tests(/?|/*): - site: http://tng-gtk-vnv:5000/ + site: http://tng-gtk-vnv:5000 verbs: [ get, options ]