From 0e15df09b482d8cbede689e3186ed2da31dcb6b4 Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Thu, 8 Jan 2015 14:25:40 +0100 Subject: [PATCH 01/10] INIT acceptance test project structure; ADD send_data features (DRAFT) --- ngsi_adapter/src/test/acceptance/README.rst | 28 ++++ .../src/test/acceptance/commons/__init__.py | 1 + .../src/test/acceptance/features/__init__.py | 1 + .../acceptance/features/component/__init__.py | 1 + .../features/component/send_data/__init__.py | 1 + .../component/send_data/send_data.feature | 133 ++++++++++++++++++ .../send_data/send_data_parsers.feature | 111 +++++++++++++++ .../send_data_representations.feature | 24 ++++ ...send_data_security.feature.NOT_IMPLEMENTED | 0 .../features/component/send_data/steps.py | 1 + .../test/acceptance/features/e2e/__init__.py | 1 + .../features/integration/__init__.py | 1 + .../src/test/acceptance/requirements.txt | 2 + .../check_disk_grouping_valid_template.txt | 1 + .../check_disk_nogrouping_valid_template.txt | 1 + .../check_load_valid_template.txt | 1 + .../check_mem.sh_valid_template.txt | 1 + .../check_procs_valid_template.txt | 1 + .../check_users_valid_template.txt | 1 + .../src/test/acceptance/settings/__init__.py | 1 + .../acceptance/settings/dev-properties.json | 23 +++ 21 files changed, 335 insertions(+) create mode 100644 ngsi_adapter/src/test/acceptance/README.rst create mode 100644 ngsi_adapter/src/test/acceptance/commons/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/component/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/send_data.feature create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_representations.feature create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_security.feature.NOT_IMPLEMENTED create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py create mode 100644 ngsi_adapter/src/test/acceptance/features/e2e/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/integration/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/requirements.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/settings/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/settings/dev-properties.json diff --git a/ngsi_adapter/src/test/acceptance/README.rst b/ngsi_adapter/src/test/acceptance/README.rst new file mode 100644 index 0000000..82719e4 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/README.rst @@ -0,0 +1,28 @@ +========================================================== +FIWARE-MONITORING | NGSI-Adapter | Acceptance test project +========================================================== + +This project contains the NGSI-Adapter acceptance tests (component, integration and E2E testing). +All test cases have been defined using Gherkin that it is a Business Readable, Domain Specific Language that lets you +describe software’s behaviour without detailing how that behaviour is implemented. +Gherkin has the purpose of serving documentation of test cases. + + +Test case implementation has been performed using `Python `_ and +`Lettuce `_. + +Project Structure +----------------- + :: + + ├───acceptance + │ ├───commons + │ ├───features + │ │ ├───component + │ │ │ └───send_data + │ │ ├───e2e + │ │ └───integration + │ ├───resources + │ │ └───probe_sample_data + │ └───settings + │ diff --git a/ngsi_adapter/src/test/acceptance/commons/__init__.py b/ngsi_adapter/src/test/acceptance/commons/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/__init__.py b/ngsi_adapter/src/test/acceptance/features/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/component/__init__.py b/ngsi_adapter/src/test/acceptance/features/component/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/__init__.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data.feature new file mode 100644 index 0000000..d84de47 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data.feature @@ -0,0 +1,133 @@ +# -*- coding: utf-8 -*- +Feature: Sending probe data + As a monitoring element (probe) user + I want to be able to transform monitoring data from probes to NGSI context attributes + so that I can constantly check the status and performance of the cloud infrastructure using NGSI Context Broker. + + + @happy_path + Scenario: Probe sends valid raw data using an existing and well-formed parser + Given the parser "check_disk" + And the monitored resource with id "qa:192.168.1.2" and type "host" + When I send valid raw data according to the selected parser + Then the response status code is "200" + + + Scenario: Probe sends valid raw data using a not existing parser + Given the parser "not_existing" + And the monitored resource with id "qa:1234567890" and type "host" + When I send valid raw data + Then the response status code is "404" + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid probe ID values. + Given the parser "check_disk" + And the monitored resource with id "" and type "host" + When I send valid raw data according to the selected parser + Then the response status code is "200" + + Examples: + | probe_id | + | 1 | + | a | + | A | + | 1-2 | + | a_b | + | 1#B | + | c:4 | + | 12345678 | + | 123.4567 | + | abc.1234 | + | A123B-c1 | + | 123_vB12 | + | Ab:123.4 | + | [STRING_WITH_LENGTH_60] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid probe TYPE values. + Given the parser "check_disk" + And the monitored resource with id "qa:1234567890" and type "" + When I send valid raw data according to the selected parser + Then the response status code is "200" + And the response contains raw data received + + Examples: + | probe_type | + | 1 | + | a | + | A | + | 1-2 | + | a_b | + | 1#B | + | c:4 | + | 12345678 | + | 123.4567 | + | abc.1234 | + | A123B-c1 | + | 123_vB12 | + | Ab:123.4 | + | [STRING_WITH_LENGTH_60] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid parser name values. + Given the parser "" + And the monitored resource with id "qa:1234567890" and type "host" + When I send valid raw data according to the selected parser + Then the response status code is "200" + And the response contains raw data received + + Examples: + | parser_name | + | 1 | + | a | + | A | + | 12345678 | + | qa.parser | + | qa-parser | + | qa_parser | + | qa#parser | + | [STRING_WITH_LENGTH_60] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid probe ID values. + Given the parser "check_disk" + And the monitored resource with id "" and type "host" + When I send valid raw data according to the selected parser + Then the response status code is "400" + + Examples: + | probe_id | + | abc 1234 | + | | + | [STRING_WITH_LENGTH_2000] | + | [MISSING_PARAM] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid probe TYPE values. + Given the parser "check_disk" + And the monitored resource with id "qa:1234567890" and type "" + When I send valid raw data according to the selected parser + Then the response status code is "400" + And the response contains raw data received + + Examples: + | probe_type | + | abc 1234 | + | | + | [STRING_WITH_LENGTH_2000] | + | [MISSING_PARAM] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid parser name values. + Given the parser "" + And the monitored resource with id "qa:1234567890" and type "host" + When I send valid raw data according to the selected parser + Then the response status code is "400" + And the response contains raw data received + + Examples: + | parser_name | + | abc 1234 | + | | + | [STRING_WITH_LENGTH_2000] | + | [MISSING_PARAM] | diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature new file mode 100644 index 0000000..508ce61 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- +Feature: Checking implemented parsers + As a monitoring element (probe) user + I want to be able to transform monitoring data from probes to NGSI context attributes using all defined parsers + so that I can constantly check the status and performance of the cloud infrastructure using NGSI Context Broker. + + + @happy_path + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser + Given the parser "" + And the monitored resource with id "" and type "" + When I send valid raw data according to the selected parser + Then the response status code is "200" + + Examples: + | parser | probe_id | probe_type | + | check_disk | qa:192.168.1.2 | host | + | check_load | qa:192.168.1.3 | host | + | check_mem.sh | qa:192.168.1.4 | host | + | check_procs | qa:192.168.1.5 | host | + | check_users | qa:192.168.1.6 | host | + + + Scenario: Probe sends raw data using a malformed parser + Given the parser "qa_malformed" + And the monitored resource with id "qa:1234567890" and type "host" + When I send valid raw data + Then the response status code is "200" + And NGSI-Adapter has logged properly asynchronous errors for malformed parser + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser + Given the parser "" + And the monitored resource with id "qa:192.168.1.2" and type "host" + And raw data loaded from resource file "" with values "" + When I send valid raw data according to the selected parser + Then the response status code is "200" + And NGSI-Adapter has sent the properly request to NGSI Context Broker + + Examples: + | parser | resource_raw_data_template | value_list | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=22 | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=16.5 | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=100.0 | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=0 | + | check_disk | check_disk_nogrouping_valid_template | FREE_SPACE_VALUE_1=14,FREE_SPACE_VALUE_2=12.5 | + | check_disk | check_disk_nogrouping_valid_template | FREE_SPACE_VALUE_1=0.5,FREE_SPACE_VALUE_2=48 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=12 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=48.5 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=100.0 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=0 | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=33 | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=61.6 | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=100 | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=0 | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=0 | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=15 | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=2354154 | + | check_users | check_users_valid_template | NUM_USERS_VALUE=0 | + | check_users | check_users_valid_template | NUM_USERS_VALUE=12 | + | check_users | check_users_valid_template | NUM_USERS_VALUE=12654881 | + + + Scenario Outline: Probe sends well-formed raw data using an existing parser with wrong parameter values + Given the parser "" + And the monitored resource with id "qa:192.168.1.2" and type "host" + And raw data loaded from resource file "" with values "" + When I send valid raw data according to the selected parser + Then the response status code is "200" + And NGSI-Adapter has logged properly asynchronous errors for invalid data + + Examples: + | parser | resource_raw_data_template | value_list | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=22ab | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE= | + | check_disk | check_disk_nogrouping_valid_template | FREE_SPACE_VALUE_1=14,FREE_SPACE_VALUE_2=zzz | + | check_disk | check_disk_nogrouping_valid_template | FREE_SPACE_VALUE_1=,FREE_SPACE_VALUE_2=48 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE= | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=3by | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE= | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=xf | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE= | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=15.2 | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=ft4 | + | check_users | check_users_valid_template | NUM_USERS_VALUE= | + | check_users | check_users_valid_template | NUM_USERS_VALUE=12.6 | + | check_users | check_users_valid_template | NUM_USERS_VALUE=21dd | + + + Scenario Outline: Probe sends malformed raw data using an existing parser + Given the parser "" + And the monitored resource with id "qa:192.168.1.2" and type "host" + And raw data loaded from resource file "" + When I send valid raw data according to the selected parser + Then the response status code is "200" + And NGSI-Adapter has logged properly asynchronous errors for invalid data + + Examples: + | parser | resource_raw_data_template | + | check_disk | check_disk_grouping_invalid_missing | + | check_disk | check_disk_grouping_invalid_malformed | + | check_disk | check_disk_nogrouping_invalid_missing | + | check_disk | check_disk_nogrouping_invalid_malformed | + | check_load | check_load_invalid_missing | + | check_load | check_load_invalid_malformed | + | check_mem.sh | check_mem.sh_invalid_missing | + | check_mem.sh | check_mem.sh_invalid_malformed | + | check_procs | check_procs_invalid_missing | + | check_procs | check_procs_invalid_malformed | + | check_users | check_users_invalid_missing | + | check_users | check_users_invalid_malformed | diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_representations.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_representations.feature new file mode 100644 index 0000000..86afb8e --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_representations.feature @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +Feature: Sending probe data using invalid representations + As a monitoring element (probe) user + I want to be able to get error messages when using invalid representations for the resource + so that I can use safely and in the right way this API + + + @happy_path + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser with invalid Content-Type + Given the parser "check_disk" + And the monitored resource with id "qa:1234567890" and type "host" + And the header Content-Type "" + When I send valid raw data according to the selected parser + Then the response status code is "415" + + Examples: + | content_type | + | application/json | + | application/xml | + | multipart/from-data | + | text/html | + | text1/plain | + | text/plain1 | + | | diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_security.feature.NOT_IMPLEMENTED b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_security.feature.NOT_IMPLEMENTED new file mode 100644 index 0000000..e69de29 diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/e2e/__init__.py b/ngsi_adapter/src/test/acceptance/features/e2e/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/e2e/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/integration/__init__.py b/ngsi_adapter/src/test/acceptance/features/integration/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/integration/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/requirements.txt b/ngsi_adapter/src/test/acceptance/requirements.txt new file mode 100644 index 0000000..87bf23e --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/requirements.txt @@ -0,0 +1,2 @@ +lettuce==0.2.19 +git+https://github.com/telefonicaid/lettuce-tools.git@v0.1#egg=lettuce_tools \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_valid_template.txt new file mode 100644 index 0000000..4a70f60 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_valid_template.txt @@ -0,0 +1 @@ +"DISK OK - free space: mygroup 25484 MB ({FREE_SPACE_VALUE}% inode=95%);| mygroup=4151MB;31071;31121;0;31171" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_valid_template.txt new file mode 100644 index 0000000..9ed2a3e --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_valid_template.txt @@ -0,0 +1 @@ +"DISK OK - free space: / 1393 MB ({FREE_SPACE_VALUE_1}% inode=66%); /data 4195 MB ({FREE_SPACE_VALUE_2}% inode=99%);| /=3388MB;5023;5023;0;5038 /data=586MB;5022;5022;0;5037" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_valid_template.txt new file mode 100644 index 0000000..6296d2a --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_valid_template.txt @@ -0,0 +1 @@ +"OK - load average: {CPU_LOAD_VALUE}, 1.23, 3.45|load1=4.000;1.000;7.000;2; load5=1.000;5.000;5.000;2; load15=40.000;15.000;16.000;9;" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_valid_template.txt new file mode 100644 index 0000000..1959ed4 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_valid_template.txt @@ -0,0 +1 @@ +"Memory: OK Total: 1877 MB - Used: 369 MB - {USED_MEM_VALUE}% used|TOTAL=1969020928;;;; USED=386584576;;;; CACHE=999440384;;;; BUFFER=201584640;;;;" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_valid_template.txt new file mode 100644 index 0000000..128a4c0 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_valid_template.txt @@ -0,0 +1 @@ +"PROCS OK: {NUM_PROCESSES_VALUE} processes" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_valid_template.txt new file mode 100644 index 0000000..8185f12 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_valid_template.txt @@ -0,0 +1 @@ +"USERS OK - 1 users currently logged in |users={NUM_USERS_VALUE};10;15;0" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/settings/__init__.py b/ngsi_adapter/src/test/acceptance/settings/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/settings/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/settings/dev-properties.json b/ngsi_adapter/src/test/acceptance/settings/dev-properties.json new file mode 100644 index 0000000..69b8103 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/settings/dev-properties.json @@ -0,0 +1,23 @@ +{ + "environment": { + "name": "experimentation" + }, + "monitoring_adapter_service": { + "protocol": "http", + "host": "130.206.81.245", + "port": "1337", + "resource": "", + "host_user": "root", + "host_password": "2 b @bl3 2 3nt3r" + }, + "monitoring_nagios": { + "host": "130.206.81.243", + "host_user": "root", + "host_password": "2 b @bl3 2 3nt3r" + }, + "monitoring_remote_host": { + "host": "130.206.81.246", + "host_user": "root", + "host_password": "2 b @bl3 2 3nt3r" + } +} \ No newline at end of file From 78f03c1ee6d1e4f0103f9c3c7035aa7ee795ebfa Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Thu, 8 Jan 2015 16:59:09 +0100 Subject: [PATCH 02/10] ADD invalid sample data --- .../features/component/send_data/send_data_parsers.feature | 6 ------ .../check_disk_grouping_invalid_malformed.txt | 1 + .../check_disk_nogrouping_invalid_malformed.txt | 1 + .../probe_sample_data/check_load_invalid_malformed.txt | 1 + .../probe_sample_data/check_mem.sh_invalid_malformed.txt | 1 + .../probe_sample_data/check_procs_invalid_malformed.txt | 1 + .../probe_sample_data/check_users_invalid_malformed.txt | 1 + 7 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_invalid_malformed.txt diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature index 508ce61..739c2c8 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature @@ -97,15 +97,9 @@ Feature: Checking implemented parsers Examples: | parser | resource_raw_data_template | - | check_disk | check_disk_grouping_invalid_missing | | check_disk | check_disk_grouping_invalid_malformed | - | check_disk | check_disk_nogrouping_invalid_missing | | check_disk | check_disk_nogrouping_invalid_malformed | - | check_load | check_load_invalid_missing | | check_load | check_load_invalid_malformed | - | check_mem.sh | check_mem.sh_invalid_missing | | check_mem.sh | check_mem.sh_invalid_malformed | - | check_procs | check_procs_invalid_missing | | check_procs | check_procs_invalid_malformed | - | check_users | check_users_invalid_missing | | check_users | check_users_invalid_malformed | diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_invalid_malformed.txt new file mode 100644 index 0000000..9c8c43a --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_invalid_malformed.txt @@ -0,0 +1 @@ +"DISK OK - free space: mygroup 25484 MB;| mygroup=4151MB;31071;31121;0;31171" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_invalid_malformed.txt new file mode 100644 index 0000000..99f4413 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_invalid_malformed.txt @@ -0,0 +1 @@ +"DISK OK - free space: / 1393 MB (65% inode=66%); /data 4195 MB;| /=3388MB;5023;5023;0;5038 /data=586MB;5022;5022;0;5037" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_invalid_malformed.txt new file mode 100644 index 0000000..ffeec32 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_invalid_malformed.txt @@ -0,0 +1 @@ +"OK - load1=4.000;1.000;7.000;2; load5=1.000;5.000;5.000;2; load15=40.000;15.000;16.000;9;" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_invalid_malformed.txt new file mode 100644 index 0000000..61263a8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_invalid_malformed.txt @@ -0,0 +1 @@ +"Memory: OK Total: 1877 MB - Used: 369 MB |TOTAL=1969020928;;;; USED=386584576;;;; CACHE=999440384;;;; BUFFER=201584640;;;;" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_invalid_malformed.txt new file mode 100644 index 0000000..dd9dcb4 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_invalid_malformed.txt @@ -0,0 +1 @@ +"PROCS OK" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_invalid_malformed.txt new file mode 100644 index 0000000..9826eb0 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_invalid_malformed.txt @@ -0,0 +1 @@ +"USERS OK - 1 users currently logged in |10;15;0" \ No newline at end of file From 815c57c925c0aebf38635b71727f915188b3969e Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Fri, 9 Jan 2015 15:40:49 +0100 Subject: [PATCH 03/10] REFACTOR features --- ...feature => send_data_api_resource.feature} | 37 ++++++++++++------- .../send_data/send_data_parsers.feature | 28 +++++++++++--- .../send_data_representations.feature | 24 ------------ ...send_data_security.feature.NOT_IMPLEMENTED | 0 .../features/component/send_data/steps.py | 25 +++++++++++++ .../src/test/acceptance/resources/__init__.py | 1 + .../resources/probe_sample_data/__init__.py | 1 + 7 files changed, 74 insertions(+), 42 deletions(-) rename ngsi_adapter/src/test/acceptance/features/component/send_data/{send_data.feature => send_data_api_resource.feature} (82%) delete mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_representations.feature delete mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_security.feature.NOT_IMPLEMENTED create mode 100644 ngsi_adapter/src/test/acceptance/resources/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/__init__.py diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature similarity index 82% rename from ngsi_adapter/src/test/acceptance/features/component/send_data/send_data.feature rename to ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature index d84de47..bfbe010 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data.feature +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature @@ -9,21 +9,21 @@ Feature: Sending probe data Scenario: Probe sends valid raw data using an existing and well-formed parser Given the parser "check_disk" And the monitored resource with id "qa:192.168.1.2" and type "host" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "200" Scenario: Probe sends valid raw data using a not existing parser Given the parser "not_existing" And the monitored resource with id "qa:1234567890" and type "host" - When I send valid raw data + When I send raw data Then the response status code is "404" Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid probe ID values. Given the parser "check_disk" And the monitored resource with id "" and type "host" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "200" Examples: @@ -47,9 +47,8 @@ Feature: Sending probe data Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid probe TYPE values. Given the parser "check_disk" And the monitored resource with id "qa:1234567890" and type "" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "200" - And the response contains raw data received Examples: | probe_type | @@ -72,9 +71,8 @@ Feature: Sending probe data Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid parser name values. Given the parser "" And the monitored resource with id "qa:1234567890" and type "host" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "200" - And the response contains raw data received Examples: | parser_name | @@ -92,7 +90,7 @@ Feature: Sending probe data Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid probe ID values. Given the parser "check_disk" And the monitored resource with id "" and type "host" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "400" Examples: @@ -106,9 +104,8 @@ Feature: Sending probe data Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid probe TYPE values. Given the parser "check_disk" And the monitored resource with id "qa:1234567890" and type "" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "400" - And the response contains raw data received Examples: | probe_type | @@ -121,13 +118,27 @@ Feature: Sending probe data Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid parser name values. Given the parser "" And the monitored resource with id "qa:1234567890" and type "host" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "400" - And the response contains raw data received Examples: - | parser_name | + | parser_name | | abc 1234 | | | | [STRING_WITH_LENGTH_2000] | | [MISSING_PARAM] | + + + Scenario Outline: Probe sends valid raw data using an unsupported HTTP method + Given the parser "check_disk" + And the monitored resource with id "qa:1234567890" and type "host" + And http operation is "" + When I send raw data according to the selected parser + Then the response status code is "400" + + Examples: + | http_verb | + | get | + | put | + | delete | + | update | diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature index 739c2c8..ca92de0 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature @@ -9,7 +9,7 @@ Feature: Checking implemented parsers Scenario Outline: Probe sends valid raw data using an existing and well-formed parser Given the parser "" And the monitored resource with id "" and type "" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "200" Examples: @@ -24,7 +24,7 @@ Feature: Checking implemented parsers Scenario: Probe sends raw data using a malformed parser Given the parser "qa_malformed" And the monitored resource with id "qa:1234567890" and type "host" - When I send valid raw data + When I send raw data Then the response status code is "200" And NGSI-Adapter has logged properly asynchronous errors for malformed parser @@ -33,7 +33,7 @@ Feature: Checking implemented parsers Given the parser "" And the monitored resource with id "qa:192.168.1.2" and type "host" And raw data loaded from resource file "" with values "" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "200" And NGSI-Adapter has sent the properly request to NGSI Context Broker @@ -65,7 +65,7 @@ Feature: Checking implemented parsers Given the parser "" And the monitored resource with id "qa:192.168.1.2" and type "host" And raw data loaded from resource file "" with values "" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "200" And NGSI-Adapter has logged properly asynchronous errors for invalid data @@ -91,7 +91,7 @@ Feature: Checking implemented parsers Given the parser "" And the monitored resource with id "qa:192.168.1.2" and type "host" And raw data loaded from resource file "" - When I send valid raw data according to the selected parser + When I send raw data according to the selected parser Then the response status code is "200" And NGSI-Adapter has logged properly asynchronous errors for invalid data @@ -103,3 +103,21 @@ Feature: Checking implemented parsers | check_mem.sh | check_mem.sh_invalid_malformed | | check_procs | check_procs_invalid_malformed | | check_users | check_users_invalid_malformed | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser with invalid Content-Type + Given the parser "check_disk" + And the monitored resource with id "qa:1234567890" and type "host" + And the header Content-Type "" + When I send valid raw data according to the selected parser + Then the response status code is "415" + + Examples: + | content_type | + | application/json | + | application/xml | + | multipart/from-data | + | text/html | + | text1/plain | + | text/plain1 | + | | diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_representations.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_representations.feature deleted file mode 100644 index 86afb8e..0000000 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_representations.feature +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -Feature: Sending probe data using invalid representations - As a monitoring element (probe) user - I want to be able to get error messages when using invalid representations for the resource - so that I can use safely and in the right way this API - - - @happy_path - Scenario Outline: Probe sends valid raw data using an existing and well-formed parser with invalid Content-Type - Given the parser "check_disk" - And the monitored resource with id "qa:1234567890" and type "host" - And the header Content-Type "" - When I send valid raw data according to the selected parser - Then the response status code is "415" - - Examples: - | content_type | - | application/json | - | application/xml | - | multipart/from-data | - | text/html | - | text1/plain | - | text/plain1 | - | | diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_security.feature.NOT_IMPLEMENTED b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_security.feature.NOT_IMPLEMENTED deleted file mode 100644 index e69de29..0000000 diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py index 53a9ce8..a000e2c 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py @@ -1 +1,26 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + __author__ = 'jfernandez' + + diff --git a/ngsi_adapter/src/test/acceptance/resources/__init__.py b/ngsi_adapter/src/test/acceptance/resources/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/__init__.py b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' From 3ab216d6b26434da64641a6d0367947d64bb054c Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Fri, 9 Jan 2015 15:43:12 +0100 Subject: [PATCH 04/10] ADD ngsi-adapter rest client --- .../src/test/acceptance/commons/constants.py | 51 ++++ .../test/acceptance/commons/logger_utils.py | 138 ++++++++++ .../ngsi_adapter_api_utils/__init__.py | 1 + .../ngsi_adapter_client.py | 129 +++++++++ .../acceptance/commons/rest_client_utils.py | 244 ++++++++++++++++++ .../src/test/acceptance/commons/utils.py | 32 +++ .../src/test/acceptance/requirements.txt | 6 +- 7 files changed, 600 insertions(+), 1 deletion(-) create mode 100644 ngsi_adapter/src/test/acceptance/commons/constants.py create mode 100644 ngsi_adapter/src/test/acceptance/commons/logger_utils.py create mode 100644 ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py create mode 100644 ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py create mode 100644 ngsi_adapter/src/test/acceptance/commons/utils.py diff --git a/ngsi_adapter/src/test/acceptance/commons/constants.py b/ngsi_adapter/src/test/acceptance/commons/constants.py new file mode 100644 index 0000000..ffa832a --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/constants.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + + +# HEADERS +HEADER_CONTENT_TYPE = u'content-type' +HEADER_ACCEPT = u'accept' +HEADER_REPRESENTATION_JSON = u'application/json' +HEADER_REPRESENTATION_XML = u'application/xml' +HEADER_REPRESENTATION_TEXTPLAIN = u'text/plain' +HEADER_AUTH_TOKEN = u'X-Auth-Token' +HEADER_TENANT_ID = u'Tenant-Id' +HEADER_TRANSACTION_ID = u'txid' + +#HTTP VERBS +HTTP_VERB_POST = 'post' +HTTP_VERB_GET = 'get' +HTTP_VERB_PUT = 'put' +HTTP_VERB_DELETE = 'delete' +HTTP_VERB_UPDATE = 'update' + +# TRANSACTION ID +TRANSACTION_ID_PATTERN = "qa/{uuid}" + +# NGSI CLIENT +NGSI_ADAPTER_URI_BASE = "{api_root_url}" +NGSI_ADAPTER_URI_PARSER = NGSI_ADAPTER_URI_BASE + "/{parser_name}" +NGSI_ADAPTER_PARAMETER_ID = "id" +NGSI_ADAPTER_PARAMETER_TYPE = "type" diff --git a/ngsi_adapter/src/test/acceptance/commons/logger_utils.py b/ngsi_adapter/src/test/acceptance/commons/logger_utils.py new file mode 100644 index 0000000..780002a --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/logger_utils.py @@ -0,0 +1,138 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + +import logging +import xml +import json +from constants import HEADER_CONTENT_TYPE, HEADER_REPRESENTATION_XML, HEADER_REPRESENTATION_JSON + +""" +Part of this code has been taken from: + https://pdihub.hi.inet/fiware/fiware-iotqaUtils/raw/develop/iotqautils/iotqaLogger.py +""" + +LOG_PATTERN = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" + + +def configure_level_debug(): + """ + Configures global log level to DEBUG + """ + logging.basicConfig(level=logging.DEBUG, format=LOG_PATTERN) + + +def configure_level_info(): + """ + Configures global log level to INFO + """ + logging.basicConfig(level=logging.INFO, format=LOG_PATTERN) + + +def configure_level_warning(): + """ + Configures global log level to WARNING + """ + logging.basicConfig(level=logging.WARNING, format=LOG_PATTERN) + + +def configure_level_error(): + """ + Configures global log level to ERROR + """ + logging.basicConfig(level=logging.ERROR, format=LOG_PATTERN) + + +def get_logger(name): + """ + Creates new logger with the given name + :param name: Name of the logger + :return: Logger + """ + logger = logging.getLogger(name) + return logger + + +def _get_pretty_body(headers, body): + """ + Returns a pretty printed body using the Content-Type header information + :param headers: Headers for the request/response (dict) + :param body: Body to pretty print (string) + :return: Body pretty printed (string) + """ + if HEADER_CONTENT_TYPE in headers: + if HEADER_REPRESENTATION_XML == headers[HEADER_CONTENT_TYPE]: + xml_parsed = xml.dom.minidom.parseString(body) + pretty_xml_as_string = xml_parsed.toprettyxml() + return pretty_xml_as_string + else: + if HEADER_REPRESENTATION_JSON in headers[HEADER_CONTENT_TYPE]: + parsed = json.loads(body) + return json.dumps(parsed, sort_keys=True, indent=4) + else: + return body + else: + return body + + +def log_print_request(logger, method, url, query_params=None, headers=None, body=None): + """ + Logs an HTTP request data. + :param logger: Logger to use + :param method: HTTP method + :param url: URL + :param query_params: Query parameters in the URL + :param headers: Headers (dict) + :param body: Body (raw body, string) + :return: None + """ + log_msg = '>>>>>>>>>>>>>>>>>>>>> Request >>>>>>>>>>>>>>>>>>> \n' + log_msg += '\t> Method: %s\n' % method + log_msg += '\t> Url: %s\n' % url + if query_params is not None: + log_msg += '\t> Query params: {}\n'.format(str(query_params)) + if headers is not None: + log_msg += '\t> Headers: {}\n'.format(str(headers)) + if body is not None: + log_msg += '\t> Payload sent:\n {}\n'.format(_get_pretty_body(headers, body)) + + logger.debug(log_msg) + + +def log_print_response(logger, response): + """ + Logs an HTTP response data + :param logger: logger to use + :param response: HTTP response ('Requests' lib) + :return: None + """ + log_msg = '<<<<<<<<<<<<<<<<<<<<<< Response <<<<<<<<<<<<<<<<<<\n' + log_msg += '\t< Response code: {}\n'.format(str(response.status_code)) + log_msg += '\t< Headers: {}\n'.format(str(dict(response.headers))) + try: + log_msg += '\t< Payload received:\n {}'.format(_get_pretty_body(dict(response.headers), response.content)) + except ValueError: + log_msg += '\t< Payload received:\n {}'.format(_get_pretty_body(dict(response.headers), response.content.text)) + + logger.debug(log_msg) diff --git a/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/__init__.py b/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py b/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py new file mode 100644 index 0000000..e5418d3 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py @@ -0,0 +1,129 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + + +from commons.rest_client_utils import RestClient, API_ROOT_URL_ARG_NAME +from commons.constants import HEADER_REPRESENTATION_TEXTPLAIN, HEADER_CONTENT_TYPE, HEADER_TRANSACTION_ID, \ + HTTP_VERB_POST +from commons.utils import generate_transaction_id +from commons.logger_utils import get_logger, configure_level_debug +from pkg_resources import resource_string + +NGSI_ADAPTER_URI_BASE = "{" + API_ROOT_URL_ARG_NAME + "}" +NGSI_ADAPTER_URI_PARSER = NGSI_ADAPTER_URI_BASE + "/{parser_name}" +NGSI_ADAPTER_PARAMETER_ID = "id" +NGSI_ADAPTER_PARAMETER_TYPE = "type" + +logger = get_logger("rest_client_utils") + + +class NgsiAdapterClient: + + headers = dict() + + def __init__(self, protocol, host, port, base_resource=None): + """ + Class constructor. Init default headers + :param protocol: API Protocol + :param host: API Host + :param port: API Port + :param base_resource: base uri resource (if exists) + :return: None + """ + self.init_headers() + self.rest_client = RestClient(protocol, host, port, base_resource) + + def init_headers(self, content_type=HEADER_REPRESENTATION_TEXTPLAIN, transaction_id=generate_transaction_id()): + """ + Init header to values (or default values) + :param content_type: Content-Type header value. By default text/plain + :param transaction_id: txId header value. By default, generated value by Utils.generate_transaction_id() + :return: None + """ + self.headers.update({HEADER_CONTENT_TYPE: content_type, HEADER_TRANSACTION_ID: transaction_id}) + + def set_headers(self, headers): + """ + Set header. + :param headers: Headers to be used by next request (dict) + :return: None + """ + self.headers = headers + + def send_raw_data(self, raw_data, parser_name, probe_id, probe_type): + """ + Execute a well-formed POST request. All parameters are mandatory + :param raw_data: Raw probe data to send (string, text/plain) + :param parser_name: Parser to be used (string) + :param probe_id: Probe ID (string) + :param probe_type: Probe Type (string) + :return: HTTP Request response ('Requests' lib) + """ + parameters = dict() + parameters.update({NGSI_ADAPTER_PARAMETER_ID: probe_id}) + parameters.update({NGSI_ADAPTER_PARAMETER_TYPE: probe_type}) + return self.rest_client.post(uri_patter=NGSI_ADAPTER_URI_PARSER, body=raw_data, headers=self.headers, + parameters=parameters, parser_name=parser_name) + + def send_raw_data_custom(self, raw_data, parser_name=None, probe_id=None, probe_type=None, + http_method=HTTP_VERB_POST): + """ + Execute a 'send_data' request (POST request by default). Should support all testing cases. + The generated request could be malformed (Testing purpose) + Parameters with None value will not be in the generated request (missing parameter). + :param raw_data: Raw probe data to send (string, text/plain) + :param parser_name: Parser to be used (string) + :param probe_id: Probe ID (string) + :param probe_type: Probe Type (string) + :param http_method: send raw data is a HTTP POST request but, for testing purposes could be interesting to use + another HTTP verb. By default is defined to 'post' + :return: HTTP Request response ('Requests' lib) + """ + + parameters = dict() + if probe_id is not None: + parameters.update({NGSI_ADAPTER_PARAMETER_ID: probe_id}) + + if probe_type is not None: + parameters.update({NGSI_ADAPTER_PARAMETER_TYPE: probe_type}) + + if parser_name is not None: + return self.rest_client.launch_request(uri_patter=NGSI_ADAPTER_URI_PARSER, body=raw_data, + method=http_method, headers=self.headers, parameters=parameters, + parser_name=parser_name) + else: + return self.rest_client.launch_request(uri_patter=NGSI_ADAPTER_URI_BASE, body=raw_data, + method=http_method, headers=self.headers, parameters=parameters) + +if __name__ == '__main__': + configure_level_debug() + logger.info("START TEST") + + ngsi_adapter_client = NgsiAdapterClient("http", "130.206.81.245", "1337") + file_content = resource_string('resources.probe_sample_data', 'check_disk_grouping_invalid_malformed.txt') + #f = open('resources/probe_sample_data/check_disk_grouping_valid_template.txt', 'r') + #file_content = f.read() + logger.info("File content: " + file_content) + ngsi_adapter_client.send_raw_data_custom(file_content, 'check_disk', 'qa-probe', 'host') diff --git a/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py b/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py new file mode 100644 index 0000000..9a6c554 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py @@ -0,0 +1,244 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + + +import requests +import xmltodict +import xmldict +from json import JSONEncoder +from constants import HEADER_REPRESENTATION_JSON, HEADER_REPRESENTATION_XML, HTTP_VERB_POST, HTTP_VERB_DELETE, \ + HTTP_VERB_GET, HTTP_VERB_PUT, HTTP_VERB_UPDATE +from logger_utils import get_logger, log_print_request, log_print_response + +API_ROOT_URL_ARG_NAME = 'api_root_url' +URL_ROOT_PATTERN = "{protocol}://{host}:{port}" + +logger = get_logger("rest_client_utils") + + +class RestClient(object): + + api_root_url = None + + def __init__(self, protocol, host, port, resource=None): + """ + This method init the RestClient with an URL ROOT Pattern using the specified params + :param protocol: Web protocol [HTTP | HTTPS] (string) + :param host: Hostname or IP (string) + :param port: Service port (string) + :param resource: Base URI resource, if exists (string) + :return: None + """ + + self.api_root_url = self._generate_url_root(protocol, host, port) + if resource is not None: + self.api_root_url += "/" + resource + + @staticmethod + def _generate_url_root(protocol, host, port): + """ + Generates API root URL without resources + :param protocol: Web protocol [HTTP | HTTPS] (string) + :param host: Hostname or IP (string) + :param port: Service port (string) + :return: ROOT url + """ + return URL_ROOT_PATTERN.format(protocol=protocol, host=host, port=port) + + def _call_api(self, uri_patter, method, body=None, headers=None, parameters=None, **kwargs): + """ + Launch HTTP request to the API with given arguments + :param uri_patter: string pattern of the full API url with keyword arguments (format string syntax) + :param method: HTTP method to execute (string) [get | post | put | delete | update] + :param body: Raw Body content (string) (Plain/XML/JSON to be sent) + :param headers: HTTP header request (dict) + :param parameters: Query parameters for the URL. i.e. {'key1': 'value1', 'key2': 'value2'} + :param **kwargs: URL parameters (without API_ROOT_URL_ARG_NAME) to fill the patters + :returns: REST API response ('Requests' response) + """ + + kwargs[API_ROOT_URL_ARG_NAME] = self.api_root_url + url = uri_patter.format(**kwargs) + + log_print_request(logger, method, url, parameters, headers) + + try: + response = requests.request(method=method, url=url, data=body, headers=headers, params=parameters, verify=False) + except Exception, e: + logger.error("Request {} to {} crashed: {}".format(method, url, str(e))) + raise e + + log_print_response(logger, response) + + return response + + def launch_request(self, uri_patter, body, method, headers=None, parameters=None, **kwargs): + """ + Launch HTTP request to the API with given arguments + :param uri_patter: string pattern of the full API url with keyword arguments (format string syntax) + :param body: Raw Body content (string) (Plain/XML/JSON to be sent) + :param method: HTTP ver to be used in the request [GET | POST | PUT | DELETE | UPDATE ] + :param headers: HTTP header (dict) + :param parameters: Query parameters for the URL. i.e. {'key1': 'value1', 'key2': 'value2'} + :param **kwargs: URL parameters (without url_root) to fill the patters + :returns: REST API response ('Requests' response) + """ + return self._call_api(uri_patter, method, body, headers, parameters, **kwargs) + + def get(self, uri_patter, headers=None, parameters=None, **kwargs): + """ + Launch HTTP GET request to the API with given arguments + :param uri_patter: string pattern of the full API url with keyword arguments (format string syntax) + :param headers: HTTP header (dict) + :param parameters: Query parameters. i.e. {'key1': 'value1', 'key2': 'value2'} + :param **kwargs: URL parameters (without url_root) to fill the patters + :returns: REST API response ('Requests' response) + """ + return self._call_api(uri_patter, HTTP_VERB_GET, headers=headers, parameters=parameters, **kwargs) + + def post(self, uri_patter, body, headers=None, parameters=None, **kwargs): + """ + Launch HTTP POST request to the API with given arguments + :param uri_patter: string pattern of the full API url with keyword arguments (format string syntax) + :param body: Raw Body content (string) (Plain/XML/JSON to be sent) + :param headers: HTTP header (dict) + :param parameters: Query parameters. i.e. {'key1': 'value1', 'key2': 'value2'} + :param **kwargs: URL parameters (without url_root) to fill the patters + :returns: REST API response ('Requests' response) + """ + return self._call_api(uri_patter, HTTP_VERB_POST, body, headers, parameters, **kwargs) + + def put(self, uri_patter, body, headers=None, parameters=None, **kwargs): + """ + Launch HTTP PUT request to the API with given arguments + :param uri_patter: string pattern of the full API url with keyword arguments (format string syntax) + :param body: Raw Body content (string) (Plain/XML/JSON to be sent) + :param headers: HTTP header (dict) + :param parameters: Query parameters. i.e. {'key1': 'value1', 'key2': 'value2'} + :param **kwargs: URL parameters (without url_root) to fill the patters + :returns: REST API response ('Requests' response) + """ + return self._call_api(uri_patter, HTTP_VERB_PUT, body, headers, parameters, **kwargs) + + def delete(self, uri_patter, headers=None, parameters=None, **kwargs): + """ + Launch HTTP DELETE request to the API with given arguments + :param uri_patter: string pattern of the full API url with keyword arguments (format string syntax) + :param headers: HTTP header (dict) + :param parameters: Query parameters. i.e. {'key1': 'value1', 'key2': 'value2'} + :param **kwargs: URL parameters (without url_root) to fill the patters + :returns: REST API response ('Requests' response) + """ + return self._call_api(uri_patter, HTTP_VERB_DELETE, headers=headers, parameters=parameters, **kwargs) + + def update(self, uri_patter, body, headers=None, parameters=None, **kwargs): + """ + Launch HTTP UPDATE request to the API with given arguments + :param uri_patter: string pattern of the full API url with keyword arguments (format string syntax) + :param body: Raw Body content (string) (Plain/XML/JSON to be sent) + :param headers: HTTP header (dict) + :param parameters: Query parameters. i.e. {'key1': 'value1', 'key2': 'value2'} + :param **kwargs: URL parameters (without url_root) to fill the patters + :returns: REST API response ('Requests' response) + """ + return self._call_api(uri_patter, HTTP_VERB_UPDATE, body, headers, parameters, **kwargs) + + +def _xml_to_dict(xml_to_convert): + """ + Converts RAW XML string to Python dict + :param xml_to_convert: XML to convert (string/text) + :return: Python dict with all XML data + """ + + return xmltodict.parse(xml_to_convert, attr_prefix='') + + +def _dict_to_xml(dict_to_convert): + """ + Converts Python dict to XML + :param dict_to_convert: Python dict to be converted (dict) + :return: XML (string) + """ + + return xmldict.dict_to_xml(dict_to_convert) + + +def response_body_to_dict(http_requests_response, content_type, xml_root_element_name=None, is_list=False): + """ + Method to convert a XML or JSON response in a Python dict + :param http_requests_response: 'Requests (lib)' response + :param content_type: Expected content-type header value (Accept header value in the request) + :param xml_root_element_name: For XML requests. XML root element in response. + :param is_list: For XML requests. If response is a list, a True value will delete list node name + :return: Python dict with response. + """ + + if HEADER_REPRESENTATION_JSON == content_type: + try: + return http_requests_response.json() + except Exception, e: + logger.error("Error parsing the response to JSON. Exception:" + str(e)) + raise e + else: + assert xml_root_element_name is not None,\ + "xml_root_element_name is a mandatory param when body is in XML" + + try: + response_body = _xml_to_dict(http_requests_response.content)[xml_root_element_name] + except Exception, e: + logger.error("Error parsing the response to XML. Exception: " + str(e)) + raise e + + if is_list and response_body is not None: + response_body = response_body.popitem()[1] + + return response_body + + +def model_to_request_body(body_model, content_type, body_model_root_element=None): + """ + Converts a Python dict (body model) to XML or JSON + :param body_model: Model to be parsed. This model should have a root element. + :param content_type: Target representation (Content-Type header value) + :param body_model_root_element: For XML requests. XML root element in the model (if exists). + :return: + """ + + if HEADER_REPRESENTATION_XML == content_type: + try: + return _dict_to_xml(body_model) + except Exception, e: + logger.error("Error parsing the body model to XML. Exception: " + str(e)) + raise e + else: + body_json = body_model[body_model_root_element] if body_model_root_element is not None else body_model + encoder = JSONEncoder() + + try: + return encoder.encode(body_json) + except Exception, e: + logger.error("Error parsing the body model to JSON. Exception:" + str(e)) + raise e diff --git a/ngsi_adapter/src/test/acceptance/commons/utils.py b/ngsi_adapter/src/test/acceptance/commons/utils.py new file mode 100644 index 0000000..9648cf1 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/utils.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + + +import uuid +from constants import TRANSACTION_ID_PATTERN + + +def generate_transaction_id(): + return TRANSACTION_ID_PATTERN.format(uuid=uuid.uuid4()) \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/requirements.txt b/ngsi_adapter/src/test/acceptance/requirements.txt index 87bf23e..d2db458 100644 --- a/ngsi_adapter/src/test/acceptance/requirements.txt +++ b/ngsi_adapter/src/test/acceptance/requirements.txt @@ -1,2 +1,6 @@ lettuce==0.2.19 -git+https://github.com/telefonicaid/lettuce-tools.git@v0.1#egg=lettuce_tools \ No newline at end of file +git+https://github.com/telefonicaid/lettuce-tools.git@v0.1#egg=lettuce_tools +setuptools +nose +xmldict +xmltodict From f142f94626907544cef1952a8ffe6773c2cdc863 Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Tue, 13 Jan 2015 13:54:43 +0100 Subject: [PATCH 05/10] ADD step implementation; ADD logging utilities; FIX NGSI-Adapter client --- .../src/test/acceptance/commons/constants.py | 23 ++++++- .../test/acceptance/commons/dataset_utils.py | 45 +++++++++++++ .../test/acceptance/commons/logger_utils.py | 66 ++++++++++++------- .../ngsi_adapter_client.py | 16 +---- .../acceptance/commons/rest_client_utils.py | 4 +- .../test/acceptance/commons/terrain_utils.py | 62 +++++++++++++++++ .../src/test/acceptance/commons/utils.py | 31 ++++++++- .../features/component/send_data/steps.py | 38 ++++++++++- .../features/component/send_data/terrain.py | 52 +++++++++++++++ ngsi_adapter/src/test/acceptance/logging.conf | 38 +++++++++++ .../acceptance/settings/dev-properties.json | 6 +- 11 files changed, 334 insertions(+), 47 deletions(-) create mode 100644 ngsi_adapter/src/test/acceptance/commons/dataset_utils.py create mode 100644 ngsi_adapter/src/test/acceptance/commons/terrain_utils.py create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/terrain.py create mode 100644 ngsi_adapter/src/test/acceptance/logging.conf diff --git a/ngsi_adapter/src/test/acceptance/commons/constants.py b/ngsi_adapter/src/test/acceptance/commons/constants.py index ffa832a..cc07d4b 100644 --- a/ngsi_adapter/src/test/acceptance/commons/constants.py +++ b/ngsi_adapter/src/test/acceptance/commons/constants.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # # This file is part of FI-WARE project. # @@ -49,3 +49,24 @@ NGSI_ADAPTER_URI_PARSER = NGSI_ADAPTER_URI_BASE + "/{parser_name}" NGSI_ADAPTER_PARAMETER_ID = "id" NGSI_ADAPTER_PARAMETER_TYPE = "type" + +# CONFIGURATION PROPERTIES +PROPERTIES_FILE = "properties.json" +PROPERTIES_CONFIG_ENV = "environment" +PROPERTIES_CONFIG_ENV_NAME = "name" +PROPERTIES_CONFIG_ENV_LOGS_PATH = "log_path" +MONITORING_CONFIG_ENV_DEFAULT_PARSER = "default_parser" +MONITORING_CONFIG_ENV_DEFAULT_PARSER_DATA = "default_parser_data" +MONITORING_CONFIG_ENV_DEFAULT_PARSER_PARAMS = "default_parser_parameters" +MONITORING_CONFIG_SERVICE = "monitoring_adapter_service" +MONITORING_CONFIG_SERVICE_PROTOCOL = "protocol" +MONITORING_CONFIG_SERVICE_HOST = "host" +MONITORING_CONFIG_SERVICE_PORT = "port" +MONITORING_CONFIG_SERVICE_RESOURCE = "resource" +MONITORING_CONFIG_SERVICE_HOSTUSER = "host_user" +MONITORING_CONFIG_SERVICE_HOSTPASSWORD = "host_password" + +# RESOURCES +RESOURCES_SAMPLEDATA_MODULE = "resources.probe_sample_data" +RESOURCES_PARAMETER_PATTERN = "${param_name}" + diff --git a/ngsi_adapter/src/test/acceptance/commons/dataset_utils.py b/ngsi_adapter/src/test/acceptance/commons/dataset_utils.py new file mode 100644 index 0000000..4a49727 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/dataset_utils.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + + +from lettuce_tools.dataset_utils.dataset_utils import DatasetUtils + +dataset_utils = DatasetUtils() + + +def prepare_param(param): + """ + Generate a fixed length data for elements tagged with the text [LENGTH] in lettuce + Removes al the data elements tagged with the text [MISSING_PARAM] in lettuce + :param param: Lettuce parameter + :return data without not desired params + """ + + if "[MISSING_PARAM]" in param: + new_param = None + else: + new_param = dataset_utils.generate_fixed_length_param(param) + + return new_param diff --git a/ngsi_adapter/src/test/acceptance/commons/logger_utils.py b/ngsi_adapter/src/test/acceptance/commons/logger_utils.py index 780002a..a6ae1ff 100644 --- a/ngsi_adapter/src/test/acceptance/commons/logger_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/logger_utils.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # # This file is part of FI-WARE project. # @@ -24,6 +24,7 @@ __author__ = 'jfernandez' import logging +import logging.config import xml import json from constants import HEADER_CONTENT_TYPE, HEADER_REPRESENTATION_XML, HEADER_REPRESENTATION_JSON @@ -33,35 +34,29 @@ https://pdihub.hi.inet/fiware/fiware-iotqaUtils/raw/develop/iotqautils/iotqaLogger.py """ -LOG_PATTERN = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" +LOG_CONSOLE_FORMATTER = " %(asctime)s - %(name)s - %(levelname)s - %(message)s" +LOG_FILE_FORMATTER = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" +# Console logging level. By default: ERROR +logging.config.fileConfig("logging.conf") +logging_level = logging.ERROR -def configure_level_debug(): - """ - Configures global log level to DEBUG - """ - logging.basicConfig(level=logging.DEBUG, format=LOG_PATTERN) - -def configure_level_info(): +def configure_logging(level): """ - Configures global log level to INFO + Configures global log level to given one + :param level: Level (INFO | DEBUG | WARN | ERROR) + :return: """ - logging.basicConfig(level=logging.INFO, format=LOG_PATTERN) - -def configure_level_warning(): - """ - Configures global log level to WARNING - """ - logging.basicConfig(level=logging.WARNING, format=LOG_PATTERN) - - -def configure_level_error(): - """ - Configures global log level to ERROR - """ - logging.basicConfig(level=logging.ERROR, format=LOG_PATTERN) + global logging_level + logging_level = logging.ERROR + if "info" == level.lower(): + logging_level = logging.INFO + elif "warn" == level.lower(): + logging_level = logging.WARNING + elif "debug" == level.lower(): + logging_level = logging.DEBUG def get_logger(name): @@ -70,7 +65,25 @@ def get_logger(name): :param name: Name of the logger :return: Logger """ - logger = logging.getLogger(name) + + #logging.config.fileConfig("logging.conf") + logger = logging.getLogger("testingLogger") + + # if not len(logger.handlers): + # # File handler + # file_hdlr = logging.FileHandler('logs/monitoring_tests.log') + # formatter = logging.Formatter(LOG_FILE_FORMATTER) + # file_hdlr.setFormatter(formatter) + # logger.addHandler(file_hdlr) + # logger.setLevel(logging.DEBUG) + # + # # Console hadler + # console_hdlr = logging.StreamHandler() + # formatter = logging.Formatter(LOG_CONSOLE_FORMATTER) + # console_hdlr.setFormatter(formatter) + # logger.addHandler(console_hdlr) + # logger.setLevel(logging_level) + return logger @@ -81,6 +94,7 @@ def _get_pretty_body(headers, body): :param body: Body to pretty print (string) :return: Body pretty printed (string) """ + if HEADER_CONTENT_TYPE in headers: if HEADER_REPRESENTATION_XML == headers[HEADER_CONTENT_TYPE]: xml_parsed = xml.dom.minidom.parseString(body) @@ -107,6 +121,7 @@ def log_print_request(logger, method, url, query_params=None, headers=None, body :param body: Body (raw body, string) :return: None """ + log_msg = '>>>>>>>>>>>>>>>>>>>>> Request >>>>>>>>>>>>>>>>>>> \n' log_msg += '\t> Method: %s\n' % method log_msg += '\t> Url: %s\n' % url @@ -127,6 +142,7 @@ def log_print_response(logger, response): :param response: HTTP response ('Requests' lib) :return: None """ + log_msg = '<<<<<<<<<<<<<<<<<<<<<< Response <<<<<<<<<<<<<<<<<<\n' log_msg += '\t< Response code: {}\n'.format(str(response.status_code)) log_msg += '\t< Headers: {}\n'.format(str(dict(response.headers))) diff --git a/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py b/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py index e5418d3..157bc1f 100644 --- a/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py +++ b/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # # This file is part of FI-WARE project. # @@ -28,8 +28,7 @@ from commons.constants import HEADER_REPRESENTATION_TEXTPLAIN, HEADER_CONTENT_TYPE, HEADER_TRANSACTION_ID, \ HTTP_VERB_POST from commons.utils import generate_transaction_id -from commons.logger_utils import get_logger, configure_level_debug -from pkg_resources import resource_string +from commons.logger_utils import get_logger NGSI_ADAPTER_URI_BASE = "{" + API_ROOT_URL_ARG_NAME + "}" NGSI_ADAPTER_URI_PARSER = NGSI_ADAPTER_URI_BASE + "/{parser_name}" @@ -116,14 +115,3 @@ def send_raw_data_custom(self, raw_data, parser_name=None, probe_id=None, probe_ else: return self.rest_client.launch_request(uri_patter=NGSI_ADAPTER_URI_BASE, body=raw_data, method=http_method, headers=self.headers, parameters=parameters) - -if __name__ == '__main__': - configure_level_debug() - logger.info("START TEST") - - ngsi_adapter_client = NgsiAdapterClient("http", "130.206.81.245", "1337") - file_content = resource_string('resources.probe_sample_data', 'check_disk_grouping_invalid_malformed.txt') - #f = open('resources/probe_sample_data/check_disk_grouping_valid_template.txt', 'r') - #file_content = f.read() - logger.info("File content: " + file_content) - ngsi_adapter_client.send_raw_data_custom(file_content, 'check_disk', 'qa-probe', 'host') diff --git a/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py b/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py index 9a6c554..9c6d25e 100644 --- a/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # # This file is part of FI-WARE project. # @@ -82,7 +82,7 @@ def _call_api(self, uri_patter, method, body=None, headers=None, parameters=None kwargs[API_ROOT_URL_ARG_NAME] = self.api_root_url url = uri_patter.format(**kwargs) - log_print_request(logger, method, url, parameters, headers) + log_print_request(logger, method, url, parameters, headers, body) try: response = requests.request(method=method, url=url, data=body, headers=headers, params=parameters, verify=False) diff --git a/ngsi_adapter/src/test/acceptance/commons/terrain_utils.py b/ngsi_adapter/src/test/acceptance/commons/terrain_utils.py new file mode 100644 index 0000000..3caa845 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/terrain_utils.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- + +# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + + +from lettuce import world +from logger_utils import get_logger +import os +import sys +import json +from constants import PROPERTIES_FILE, PROPERTIES_CONFIG_ENV, PROPERTIES_CONFIG_ENV_LOGS_PATH + +logger = get_logger("terrain_utils") + + +def _load_project_properties(): + """ + Parse the JSON configuration file located in the src folder and + store the resulting dictionary in the lettuce world global variable. + """ + + with open(PROPERTIES_FILE) as config_file: + try: + world.config = json.load(config_file) + except Exception, e: + logger.error('Error parsing config file: %s' % e) + sys.exit(1) + + +def set_up(): + """ + Setup execution and configure global test parameters and environment. + :return: None + """ + _load_project_properties() + + """ + Make sure the logs path exists and create it otherwise. + """ + if not os.path.exists(world.config[PROPERTIES_CONFIG_ENV][PROPERTIES_CONFIG_ENV_LOGS_PATH]): + os.makedirs(world.config[PROPERTIES_CONFIG_ENV][PROPERTIES_CONFIG_ENV_LOGS_PATH]) diff --git a/ngsi_adapter/src/test/acceptance/commons/utils.py b/ngsi_adapter/src/test/acceptance/commons/utils.py index 9648cf1..a08851e 100644 --- a/ngsi_adapter/src/test/acceptance/commons/utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/utils.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # # This file is part of FI-WARE project. # @@ -25,8 +25,33 @@ import uuid -from constants import TRANSACTION_ID_PATTERN +from pkg_resources import resource_string +from logger_utils import get_logger +from constants import TRANSACTION_ID_PATTERN, RESOURCES_SAMPLEDATA_MODULE, RESOURCES_PARAMETER_PATTERN + +logger = get_logger("utils") def generate_transaction_id(): - return TRANSACTION_ID_PATTERN.format(uuid=uuid.uuid4()) \ No newline at end of file + """ + Generate a transaction ID value following defined pattern. + :return: New transactionId + """ + return TRANSACTION_ID_PATTERN.format(uuid=uuid.uuid4()) + + +def get_probe_data_from_resource_file(filename, replacement_values=None): + """ + Get probe data from resource files. If replacement_values is not empty, + :param filename: Resource filename to be used for loading probe data + :param param_values: (key, value) pairs. (list of dict) + :return: File content with param value replacements + """ + filename = filename + ".txt" if ".txt" not in filename else filename + file_content = resource_string(RESOURCES_SAMPLEDATA_MODULE, filename) + + if replacement_values is not None: + for param in replacement_values: + file_content = file_content.replace(RESOURCES_PARAMETER_PATTERN.replace('param_name', param['key']), param['value']) + + return file_content diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py index a000e2c..3a43a8c 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # # This file is part of FI-WARE project. # @@ -24,3 +24,39 @@ __author__ = 'jfernandez' +from lettuce import world, step + +from commons.utils import get_probe_data_from_resource_file +from nose.tools import assert_equal +from commons.dataset_utils import prepare_param +from commons.constants import PROPERTIES_CONFIG_ENV, \ + MONITORING_CONFIG_ENV_DEFAULT_PARSER, MONITORING_CONFIG_ENV_DEFAULT_PARSER_PARAMS, \ + MONITORING_CONFIG_ENV_DEFAULT_PARSER_DATA + + +@step(u'the parser "(.*)"') +def the_parser(step, parser): + world.parser = prepare_param(parser) + + +@step(u'the monitored resource with id "(.*)" and type "(.*)"') +def the_monitored_resource_with_id_and_type(step, id, type): + world.probe_id = prepare_param(id) + world.probe_type = prepare_param(type) + + +@step(u'I send raw data according to the selected parser') +def i_sed_raw_data_according_to_the_selected_parser(step): + if world.raw_data_filename is None: + #default_parser = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER] + world.raw_data_filename = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER_DATA] + world.raw_data_params = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER_PARAMS] + + probe_data = get_probe_data_from_resource_file(world.raw_data_filename, world.raw_data_params) + world.response = world.ngsi_adapter_client.send_raw_data_custom(probe_data, world.parser, + world.probe_id, world.probe_type) + + +@step(u'the response status code is "(.*)"') +def the_response_status_code_is(step, status_code): + assert_equal(str(world.response.status_code), status_code) diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/terrain.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/terrain.py new file mode 100644 index 0000000..2bf18b3 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/terrain.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + + +from lettuce import before, world +from commons.terrain_utils import set_up +from commons.ngsi_adapter_api_utils.ngsi_adapter_client import NgsiAdapterClient +from commons.constants import MONITORING_CONFIG_SERVICE, MONITORING_CONFIG_SERVICE_HOST, \ + MONITORING_CONFIG_SERVICE_PORT, MONITORING_CONFIG_SERVICE_PROTOCOL + + +@before.all +def before_all(): + set_up() + + +@before.each_feature +def before_each_feature(feature): + world.ngsi_adapter_client = NgsiAdapterClient(world.config[MONITORING_CONFIG_SERVICE][MONITORING_CONFIG_SERVICE_PROTOCOL], + world.config[MONITORING_CONFIG_SERVICE][MONITORING_CONFIG_SERVICE_HOST], + world.config[MONITORING_CONFIG_SERVICE][MONITORING_CONFIG_SERVICE_PORT]) + + +@before.each_scenario +def before_each_scenario(scenario): + world.parser = None + world.probe_id = "qa" + world.probe_type = "host" + world.raw_data_filename = None + world.raw_data_params = None diff --git a/ngsi_adapter/src/test/acceptance/logging.conf b/ngsi_adapter/src/test/acceptance/logging.conf new file mode 100644 index 0000000..9102732 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/logging.conf @@ -0,0 +1,38 @@ +[loggers] +keys=root,testingLogger + +[handlers] +keys=consoleHandler,fileHandler + +[formatters] +keys=consoleFormatter,fileFormatter + +[logger_root] +level=DEBUG +handlers=consoleHandler + +[logger_testingLogger] +level=DEBUG +handlers=consoleHandler,fileHandler +qualname=testingLogger +propagate=0 + +[handler_consoleHandler] +class=StreamHandler +level=DEBUG +formatter=consoleFormatter +args=(sys.stdout,) + +[handler_fileHandler] +class=FileHandler +level=DEBUG +formatter=fileFormatter +args=('logs/monitoring_tests.log', 'w') + +[formatter_consoleFormatter] +format=- %(asctime)s - %(name)s - %(levelname)s - %(message)s +datefmt= + +[formatter_fileFormatter] +format=%(asctime)s - %(name)s - %(levelname)s - %(message)s +datefmt= diff --git a/ngsi_adapter/src/test/acceptance/settings/dev-properties.json b/ngsi_adapter/src/test/acceptance/settings/dev-properties.json index 69b8103..5e42baf 100644 --- a/ngsi_adapter/src/test/acceptance/settings/dev-properties.json +++ b/ngsi_adapter/src/test/acceptance/settings/dev-properties.json @@ -1,6 +1,10 @@ { "environment": { - "name": "experimentation" + "name": "experimentation", + "log_path": "./logs", + "default_parser": "check_disk", + "default_parser_data": "check_disk_grouping_valid_template", + "default_parser_parameters": [{"key":"FREE_SPACE_VALUE", "value":"40"}] }, "monitoring_adapter_service": { "protocol": "http", From 97e47bac9edcba19624a1d90fadd69f80de9d47c Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Thu, 8 Jan 2015 14:25:40 +0100 Subject: [PATCH 06/10] INIT acceptance test project structure; ADD send_data features; ADD resources --- ngsi_adapter/src/test/acceptance/README.rst | 28 +++ .../src/test/acceptance/commons/__init__.py | 1 + .../src/test/acceptance/features/__init__.py | 1 + .../acceptance/features/component/__init__.py | 1 + .../features/component/send_data/__init__.py | 1 + .../send_data/send_data_api_resource.feature | 176 ++++++++++++++++++ .../send_data/send_data_parsers.feature | 123 ++++++++++++ .../features/component/send_data/steps.py | 26 +++ .../test/acceptance/features/e2e/__init__.py | 1 + .../features/integration/__init__.py | 1 + .../src/test/acceptance/requirements.txt | 2 + .../src/test/acceptance/resources/__init__.py | 1 + .../resources/probe_sample_data/__init__.py | 1 + .../check_disk_grouping_invalid_malformed.txt | 1 + .../check_disk_grouping_valid_template.txt | 1 + ...heck_disk_nogrouping_invalid_malformed.txt | 1 + .../check_disk_nogrouping_valid_template.txt | 1 + .../check_load_invalid_malformed.txt | 1 + .../check_load_valid_template.txt | 1 + .../check_mem.sh_invalid_malformed.txt | 1 + .../check_mem.sh_valid_template.txt | 1 + .../check_procs_invalid_malformed.txt | 1 + .../check_procs_valid_template.txt | 1 + .../check_users_invalid_malformed.txt | 1 + .../check_users_valid_template.txt | 1 + .../acceptance/settings/dev-properties.json | 23 +++ 26 files changed, 398 insertions(+) create mode 100644 ngsi_adapter/src/test/acceptance/README.rst create mode 100644 ngsi_adapter/src/test/acceptance/commons/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/component/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature create mode 100644 ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py create mode 100644 ngsi_adapter/src/test/acceptance/features/e2e/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/features/integration/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/requirements.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/__init__.py create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_invalid_malformed.txt create mode 100644 ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_valid_template.txt create mode 100644 ngsi_adapter/src/test/acceptance/settings/dev-properties.json diff --git a/ngsi_adapter/src/test/acceptance/README.rst b/ngsi_adapter/src/test/acceptance/README.rst new file mode 100644 index 0000000..82719e4 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/README.rst @@ -0,0 +1,28 @@ +========================================================== +FIWARE-MONITORING | NGSI-Adapter | Acceptance test project +========================================================== + +This project contains the NGSI-Adapter acceptance tests (component, integration and E2E testing). +All test cases have been defined using Gherkin that it is a Business Readable, Domain Specific Language that lets you +describe software’s behaviour without detailing how that behaviour is implemented. +Gherkin has the purpose of serving documentation of test cases. + + +Test case implementation has been performed using `Python `_ and +`Lettuce `_. + +Project Structure +----------------- + :: + + ├───acceptance + │ ├───commons + │ ├───features + │ │ ├───component + │ │ │ └───send_data + │ │ ├───e2e + │ │ └───integration + │ ├───resources + │ │ └───probe_sample_data + │ └───settings + │ diff --git a/ngsi_adapter/src/test/acceptance/commons/__init__.py b/ngsi_adapter/src/test/acceptance/commons/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/commons/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/__init__.py b/ngsi_adapter/src/test/acceptance/features/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/component/__init__.py b/ngsi_adapter/src/test/acceptance/features/component/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/__init__.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature new file mode 100644 index 0000000..22d1806 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature @@ -0,0 +1,176 @@ +# -*- coding: utf-8 -*- +Feature: Sending probe data + As a monitoring element (probe) user + I want to be able to transform monitoring data from probes to NGSI context attributes + so that I can constantly check the status and performance of the cloud infrastructure using NGSI Context Broker. + + + @happy_path + Scenario: Probe sends valid raw data using an existing and well-formed parser + Given the parser "qa_parser" + And the monitored resource with id "qa:192.168.1.2" and type "host" + When I send raw data according to the selected parser + Then the response status code is "200" + + + Scenario: Probe sends valid raw data using a not existing parser + Given the parser "not_existing" + And the monitored resource with id "qa:1234567890" and type "host" + When I send raw data according to the selected parser + Then the response status code is "404" + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid probe ID values. + Given the parser "qa_parser" + And the monitored resource with id "" and type "host" + When I send raw data according to the selected parser + Then the response status code is "200" + + Examples: + | probe_id | + | 1 | + | a | + | A | + | 1-2 | + | a_b | + | 1#B | + | c:4 | + | 12345678 | + | 123.4567 | + | abc.1234 | + | A123B-c1 | + | 123_vB12 | + | Ab:123.4 | + | [STRING_WITH_LENGTH_60] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid probe TYPE values. + Given the parser "qa_parser" + And the monitored resource with id "qa:1234567890" and type "" + When I send raw data according to the selected parser + Then the response status code is "200" + + Examples: + | probe_type | + | 1 | + | a | + | A | + | 1-2 | + | a_b | + | 1#B | + | c:4 | + | 12345678 | + | 123.4567 | + | abc.1234 | + | A123B-c1 | + | 123_vB12 | + | Ab:123.4 | + | [STRING_WITH_LENGTH_60] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with valid parser name values. + Given the parser "" + And the monitored resource with id "qa:1234567890" and type "host" + When I send raw data according to the selected parser + Then the response status code is "200" + + Examples: + | parser_name | + | 1 | + | a | + | B | + | 12345678 | + | qa.parser | + | qa-parser | + | qa_parser | + | qa@parser | + + @skip @CLAUDIA-4468 @CLAUDIA-4469 + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid probe ID values. + Given the parser "qa_parser" + And the monitored resource with id "" and type "host" + When I send raw data according to the selected parser + Then the response status code is "400" + + Examples: + | probe_id | + | | + | [STRING_WITH_LENGTH_2000] | + | [MISSING_PARAM] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid probe TYPE values. + Given the parser "qa_parser" + And the monitored resource with id "qa:1234567890" and type "" + When I send raw data according to the selected parser + Then the response status code is "400" + + Examples: + | probe_type | + | | + | [STRING_WITH_LENGTH_2000] | + | [MISSING_PARAM] | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid parser name values. + Given the parser "" + And the monitored resource with id "qa:1234567890" and type "host" + When I send raw data according to the selected parser + Then the response status code is "400" + + Examples: + | parser_name | + | abc 1234 | + | | + | [STRING_WITH_LENGTH_2000] | + | [MISSING_PARAM] | + + + Scenario Outline: Probe sends valid raw data using an unsupported HTTP method + Given the parser "qa_parser" + And the monitored resource with id "qa:1234567890" and type "host" + And http operation is "" + When I send raw data according to the selected parser + Then the response status code is "400" + + Examples: + | http_verb | + | get | + | put | + | delete | + | update | + + + Scenario Outline: NGSI-Adapter reuse the transaction-id header value given in the request + Given the parser "qa_parser" + And the monitored resource with id "qa:1234567890" and type "host" + And the header Transaction-Id "" + When I send valid raw data according to the selected parser + Then the response status code is "200" + And the given Transaction-Id value is used in logs + + Examples: + | transaction_id | + | 1 | + | 1231asdfgasd | + | a/12345.qa | + | ABCDEFG#123 | + | 123-456 | + | ABC_1av | + + Scenario Outline: NGSI-Adapter generates new transaction-id value when header is missing or empty + Given the parser "qa_parser" + And the monitored resource with id "qa:1234567890" and type "host" + And the header Transaction-Id "" + When I send valid raw data according to the selected parser + Then the response status code is "200" + And new Transaction-Id value is used in logs + + Examples: + | transaction_id | + | 1 | + | 1231asdfgasd | + | a/12345.qa | + | ABCDEFG#123 | + | 123-456 | + | ABC_1av | diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature new file mode 100644 index 0000000..c75f191 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_parsers.feature @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- +Feature: Checking implemented parsers + As a monitoring element (probe) user + I want to be able to transform monitoring data from probes to NGSI context attributes using all defined parsers + so that I can constantly check the status and performance of the cloud infrastructure using NGSI Context Broker. + + + @happy_path + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser + Given the parser "" + And the monitored resource with id "" and type "" + When I send raw data according to the selected parser + Then the response status code is "200" + + Examples: + | parser | probe_id | probe_type | + | check_disk | qa:192.168.1.2 | host | + | check_load | qa:192.168.1.3 | host | + | check_mem.sh | qa:192.168.1.4 | host | + | check_procs | qa:192.168.1.5 | host | + | check_users | qa:192.168.1.6 | host | + + + Scenario: Probe sends raw data using a malformed parser + Given the parser "qa_malformed" + And the monitored resource with id "qa:1234567890" and type "host" + When I send raw data + Then the response status code is "200" + And NGSI-Adapter has logged properly asynchronous errors for malformed parser + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser + Given the parser "" + And the monitored resource with id "qa:192.168.1.2" and type "host" + And raw data loaded from resource file "" with values "" + When I send raw data according to the selected parser + Then the response status code is "200" + And NGSI-Adapter has sent the properly request to NGSI Context Broker + + Examples: + | parser | resource_raw_data_template | value_list | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=22 | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=16.5 | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=100.0 | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=0 | + | check_disk | check_disk_nogrouping_valid_template | FREE_SPACE_VALUE_1=14,FREE_SPACE_VALUE_2=12.5 | + | check_disk | check_disk_nogrouping_valid_template | FREE_SPACE_VALUE_1=0.5,FREE_SPACE_VALUE_2=48 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=12 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=48.5 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=100.0 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=0 | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=33 | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=61.6 | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=100 | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=0 | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=0 | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=15 | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=2354154 | + | check_users | check_users_valid_template | NUM_USERS_VALUE=0 | + | check_users | check_users_valid_template | NUM_USERS_VALUE=12 | + | check_users | check_users_valid_template | NUM_USERS_VALUE=12654881 | + + + Scenario Outline: Probe sends well-formed raw data using an existing parser with wrong parameter values + Given the parser "" + And the monitored resource with id "qa:192.168.1.2" and type "host" + And raw data loaded from resource file "" with values "" + When I send raw data according to the selected parser + Then the response status code is "200" + And NGSI-Adapter has logged properly asynchronous errors for invalid data + + Examples: + | parser | resource_raw_data_template | value_list | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE=22ab | + | check_disk | check_disk_grouping_valid_template | FREE_SPACE_VALUE= | + | check_disk | check_disk_nogrouping_valid_template | FREE_SPACE_VALUE_1=14,FREE_SPACE_VALUE_2=zzz | + | check_disk | check_disk_nogrouping_valid_template | FREE_SPACE_VALUE_1=,FREE_SPACE_VALUE_2=48 | + | check_load | check_load_valid_template | CPU_LOAD_VALUE= | + | check_load | check_load_valid_template | CPU_LOAD_VALUE=3by | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE= | + | check_mem.sh | check_mem.sh_valid_template | USED_MEM_VALUE=xf | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE= | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=15.2 | + | check_procs | check_procs_valid_template | NUM_PROCESSES_VALUE=ft4 | + | check_users | check_users_valid_template | NUM_USERS_VALUE= | + | check_users | check_users_valid_template | NUM_USERS_VALUE=12.6 | + | check_users | check_users_valid_template | NUM_USERS_VALUE=21dd | + + + Scenario Outline: Probe sends malformed raw data using an existing parser + Given the parser "" + And the monitored resource with id "qa:192.168.1.2" and type "host" + And raw data loaded from resource file "" + When I send raw data according to the selected parser + Then the response status code is "200" + And NGSI-Adapter has logged properly asynchronous errors for invalid data + + Examples: + | parser | resource_raw_data_template | + | check_disk | check_disk_grouping_invalid_malformed | + | check_disk | check_disk_nogrouping_invalid_malformed | + | check_load | check_load_invalid_malformed | + | check_mem.sh | check_mem.sh_invalid_malformed | + | check_procs | check_procs_invalid_malformed | + | check_users | check_users_invalid_malformed | + + + Scenario Outline: Probe sends valid raw data using an existing and well-formed parser with invalid Content-Type + Given the parser "qa_parser" + And the monitored resource with id "qa:1234567890" and type "host" + And the header Content-Type "" + When I send valid raw data according to the selected parser + Then the response status code is "415" + + Examples: + | content_type | + | application/json | + | application/xml | + | multipart/from-data | + | text/html | + | text1/plain | + | text/plain1 | + | | diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py new file mode 100644 index 0000000..a000e2c --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U +# +# This file is part of FI-WARE project. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache version 2.0 License please +# contact with opensource@tid.es + +__author__ = 'jfernandez' + + diff --git a/ngsi_adapter/src/test/acceptance/features/e2e/__init__.py b/ngsi_adapter/src/test/acceptance/features/e2e/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/e2e/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/features/integration/__init__.py b/ngsi_adapter/src/test/acceptance/features/integration/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/features/integration/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/requirements.txt b/ngsi_adapter/src/test/acceptance/requirements.txt new file mode 100644 index 0000000..87bf23e --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/requirements.txt @@ -0,0 +1,2 @@ +lettuce==0.2.19 +git+https://github.com/telefonicaid/lettuce-tools.git@v0.1#egg=lettuce_tools \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/__init__.py b/ngsi_adapter/src/test/acceptance/resources/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/__init__.py b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/__init__.py new file mode 100644 index 0000000..53a9ce8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/__init__.py @@ -0,0 +1 @@ +__author__ = 'jfernandez' diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_invalid_malformed.txt new file mode 100644 index 0000000..9c8c43a --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_invalid_malformed.txt @@ -0,0 +1 @@ +"DISK OK - free space: mygroup 25484 MB;| mygroup=4151MB;31071;31121;0;31171" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_valid_template.txt new file mode 100644 index 0000000..9fed6c4 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_grouping_valid_template.txt @@ -0,0 +1 @@ +"DISK OK - free space: mygroup 25484 MB (${FREE_SPACE_VALUE}% inode=95%);| mygroup=4151MB;31071;31121;0;31171" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_invalid_malformed.txt new file mode 100644 index 0000000..99f4413 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_invalid_malformed.txt @@ -0,0 +1 @@ +"DISK OK - free space: / 1393 MB (65% inode=66%); /data 4195 MB;| /=3388MB;5023;5023;0;5038 /data=586MB;5022;5022;0;5037" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_valid_template.txt new file mode 100644 index 0000000..7c6161b --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_disk_nogrouping_valid_template.txt @@ -0,0 +1 @@ +"DISK OK - free space: / 1393 MB (${FREE_SPACE_VALUE_1}% inode=66%); /data 4195 MB ({FREE_SPACE_VALUE_2}% inode=99%);| /=3388MB;5023;5023;0;5038 /data=586MB;5022;5022;0;5037" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_invalid_malformed.txt new file mode 100644 index 0000000..ffeec32 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_invalid_malformed.txt @@ -0,0 +1 @@ +"OK - load1=4.000;1.000;7.000;2; load5=1.000;5.000;5.000;2; load15=40.000;15.000;16.000;9;" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_valid_template.txt new file mode 100644 index 0000000..9545e1d --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_load_valid_template.txt @@ -0,0 +1 @@ +"OK - load average: ${CPU_LOAD_VALUE}, 1.23, 3.45|load1=4.000;1.000;7.000;2; load5=1.000;5.000;5.000;2; load15=40.000;15.000;16.000;9;" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_invalid_malformed.txt new file mode 100644 index 0000000..61263a8 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_invalid_malformed.txt @@ -0,0 +1 @@ +"Memory: OK Total: 1877 MB - Used: 369 MB |TOTAL=1969020928;;;; USED=386584576;;;; CACHE=999440384;;;; BUFFER=201584640;;;;" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_valid_template.txt new file mode 100644 index 0000000..5161563 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_mem.sh_valid_template.txt @@ -0,0 +1 @@ +"Memory: OK Total: 1877 MB - Used: 369 MB - ${USED_MEM_VALUE}% used|TOTAL=1969020928;;;; USED=386584576;;;; CACHE=999440384;;;; BUFFER=201584640;;;;" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_invalid_malformed.txt new file mode 100644 index 0000000..dd9dcb4 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_invalid_malformed.txt @@ -0,0 +1 @@ +"PROCS OK" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_valid_template.txt new file mode 100644 index 0000000..675eb72 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_procs_valid_template.txt @@ -0,0 +1 @@ +"PROCS OK: ${NUM_PROCESSES_VALUE} processes" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_invalid_malformed.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_invalid_malformed.txt new file mode 100644 index 0000000..9826eb0 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_invalid_malformed.txt @@ -0,0 +1 @@ +"USERS OK - 1 users currently logged in |10;15;0" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_valid_template.txt new file mode 100644 index 0000000..2786091 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/check_users_valid_template.txt @@ -0,0 +1 @@ +"USERS OK - 1 users currently logged in |users=${NUM_USERS_VALUE};10;15;0" \ No newline at end of file diff --git a/ngsi_adapter/src/test/acceptance/settings/dev-properties.json b/ngsi_adapter/src/test/acceptance/settings/dev-properties.json new file mode 100644 index 0000000..69b8103 --- /dev/null +++ b/ngsi_adapter/src/test/acceptance/settings/dev-properties.json @@ -0,0 +1,23 @@ +{ + "environment": { + "name": "experimentation" + }, + "monitoring_adapter_service": { + "protocol": "http", + "host": "130.206.81.245", + "port": "1337", + "resource": "", + "host_user": "root", + "host_password": "2 b @bl3 2 3nt3r" + }, + "monitoring_nagios": { + "host": "130.206.81.243", + "host_user": "root", + "host_password": "2 b @bl3 2 3nt3r" + }, + "monitoring_remote_host": { + "host": "130.206.81.246", + "host_user": "root", + "host_password": "2 b @bl3 2 3nt3r" + } +} \ No newline at end of file From d58e7dc4ebccc2d7846c2ef88fb0c29a19fcfc6b Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Tue, 13 Jan 2015 19:01:23 +0100 Subject: [PATCH 07/10] ADD steps --- .../send_data/send_data_api_resource.feature | 15 ++++----- .../features/component/send_data/steps.py | 33 +++++++++++++++---- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature index 22d1806..ac7645c 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/send_data_api_resource.feature @@ -12,7 +12,7 @@ Feature: Sending probe data When I send raw data according to the selected parser Then the response status code is "200" - + @test Scenario: Probe sends valid raw data using a not existing parser Given the parser "not_existing" And the monitored resource with id "qa:1234567890" and type "host" @@ -85,6 +85,7 @@ Feature: Sending probe data | qa_parser | | qa@parser | + @skip @CLAUDIA-4468 @CLAUDIA-4469 Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid probe ID values. Given the parser "qa_parser" @@ -99,6 +100,7 @@ Feature: Sending probe data | [MISSING_PARAM] | + @skip @CLAUDIA-4468 @CLAUDIA-4469 Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid probe TYPE values. Given the parser "qa_parser" And the monitored resource with id "qa:1234567890" and type "" @@ -112,15 +114,14 @@ Feature: Sending probe data | [MISSING_PARAM] | - Scenario Outline: Probe sends valid raw data using an existing and well-formed parser, with invalid parser name values. + Scenario Outline: Probe sends valid raw data with invalid parser name value. Given the parser "" And the monitored resource with id "qa:1234567890" and type "host" When I send raw data according to the selected parser - Then the response status code is "400" + Then the response status code is "404" Examples: | parser_name | - | abc 1234 | | | | [STRING_WITH_LENGTH_2000] | | [MISSING_PARAM] | @@ -129,16 +130,14 @@ Feature: Sending probe data Scenario Outline: Probe sends valid raw data using an unsupported HTTP method Given the parser "qa_parser" And the monitored resource with id "qa:1234567890" and type "host" - And http operation is "" - When I send raw data according to the selected parser - Then the response status code is "400" + When I send raw data according to the selected parser with "" HTTP operation + Then the response status code is "405" Examples: | http_verb | | get | | put | | delete | - | update | Scenario Outline: NGSI-Adapter reuse the transaction-id header value given in the request diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py index 446fee2..3600447 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py @@ -34,30 +34,49 @@ MONITORING_CONFIG_ENV_DEFAULT_PARSER_DATA -@step(u'the parser "(.*)"') +def _set_default_dataset(): + """ + Ser default dataset vars for testing when data is not specified in the Scenarios + :return None + """ + #default_parser = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER] + world.raw_data_filename = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER_DATA] + world.raw_data_params = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER_PARAMS] + + +@step(u'the parser "(.*)"$') def the_parser(step, parser): world.parser = prepare_param(parser) -@step(u'the monitored resource with id "(.*)" and type "(.*)"') +@step(u'the monitored resource with id "(.*)" and type "(.*)"$') def the_monitored_resource_with_id_and_type(step, id, type): world.probe_id = prepare_param(id) world.probe_type = prepare_param(type) -@step(u'I send raw data according to the selected parser') +@step(u'I send raw data according to the selected parser$') def i_sed_raw_data_according_to_the_selected_parser(step): if world.raw_data_filename is None: - #default_parser = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER] - world.raw_data_filename = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER_DATA] - world.raw_data_params = world.config[PROPERTIES_CONFIG_ENV][MONITORING_CONFIG_ENV_DEFAULT_PARSER_PARAMS] + _set_default_dataset() probe_data = get_probe_data_from_resource_file(world.raw_data_filename, world.raw_data_params) world.response = world.ngsi_adapter_client.send_raw_data_custom(probe_data, world.parser, world.probe_id, world.probe_type) -@step(u'the response status code is "(.*)"') +@step(u'I send raw data according to the selected parser with "(.*)" HTTP operation$') +def i_sed_raw_data_according_to_the_selected_parser_with_http_verb(step, http_verb): + if world.raw_data_filename is None: + _set_default_dataset() + + probe_data = get_probe_data_from_resource_file(world.raw_data_filename, world.raw_data_params) + world.response = world.ngsi_adapter_client.send_raw_data_custom(probe_data, world.parser, + world.probe_id, world.probe_type, + http_method=http_verb) + + +@step(u'the response status code is "(.*)"$') def the_response_status_code_is(step, status_code): assert_equal(str(world.response.status_code), status_code) From 03dcd246c0601fadc3d463b3fa166d182dd591d6 Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Mon, 19 Jan 2015 13:18:51 +0100 Subject: [PATCH 08/10] REFACTOR var names, steps, properties and paths --- .../test/acceptance/commons/logger_utils.py | 2 +- .../ngsi_adapter_client.py | 18 +++++++++--------- .../acceptance/commons/remote_tail_utils.py | 9 --------- .../features/component/send_data/steps.py | 11 ++++++++--- ...emplate.txt => qa_probe_valid_template.txt} | 0 .../acceptance/settings/dev-properties.json | 4 ++-- .../acceptance/{ => settings}/logging.conf | 0 7 files changed, 20 insertions(+), 24 deletions(-) rename ngsi_adapter/src/test/acceptance/resources/probe_sample_data/{qa_probe_parser_valid_template.txt => qa_probe_valid_template.txt} (100%) rename ngsi_adapter/src/test/acceptance/{ => settings}/logging.conf (100%) diff --git a/ngsi_adapter/src/test/acceptance/commons/logger_utils.py b/ngsi_adapter/src/test/acceptance/commons/logger_utils.py index a6ae1ff..373a2b8 100644 --- a/ngsi_adapter/src/test/acceptance/commons/logger_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/logger_utils.py @@ -38,7 +38,7 @@ LOG_FILE_FORMATTER = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" # Console logging level. By default: ERROR -logging.config.fileConfig("logging.conf") +logging.config.fileConfig("./settings/logging.conf") logging_level = logging.ERROR diff --git a/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py b/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py index cef7f2a..945fd7e 100644 --- a/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py +++ b/ngsi_adapter/src/test/acceptance/commons/ngsi_adapter_api_utils/ngsi_adapter_client.py @@ -31,7 +31,7 @@ from commons.logger_utils import get_logger NGSI_ADAPTER_URI_BASE = "{" + API_ROOT_URL_ARG_NAME + "}" -NGSI_ADAPTER_URI_PARSER = NGSI_ADAPTER_URI_BASE + "/{parser_name}" +NGSI_ADAPTER_URI_PARSER = NGSI_ADAPTER_URI_BASE + "/{probe_name}" NGSI_ADAPTER_PARAMETER_ID = "id" NGSI_ADAPTER_PARAMETER_TYPE = "type" @@ -84,32 +84,32 @@ def set_headers(self, headers): self.headers = headers - def send_raw_data(self, raw_data, parser_name, entity_id, entity_type): + def send_raw_data(self, raw_data, probe_name, entity_id, entity_type): """ Execute a well-formed POST request. All parameters are mandatory :param raw_data: Raw probe data to send (string, text/plain) - :param parser_name: Parser to be used (string) + :param probe_name: Parser to be used (string) :param entity_id: Entity ID (string) :param entity_type: Entity Type (string) :return: HTTP Request response ('Requests' lib) """ - logger.info("Sending raw data to NGSI-Adapter [Parser: %s, EntityId: %, EntityType: %s", parser_name, + logger.info("Sending raw data to NGSI-Adapter [Probe: %s, EntityId: %, EntityType: %s", probe_name, entity_id, entity_type) parameters = dict() parameters.update({NGSI_ADAPTER_PARAMETER_ID: entity_id}) parameters.update({NGSI_ADAPTER_PARAMETER_TYPE: entity_type}) return self.rest_client.post(uri_pattern=NGSI_ADAPTER_URI_PARSER, body=raw_data, headers=self.headers, - parametersn=parameters, parser_name=parser_name) + parametersn=parameters, probe_name=probe_name) - def send_raw_data_custom(self, raw_data, parser_name=None, entity_id=None, entity_type=None, + def send_raw_data_custom(self, raw_data, probe_name=None, entity_id=None, entity_type=None, http_method=HTTP_VERB_POST): """ Execute a 'send_data' request (POST request by default). Should support all testing cases. The generated request could be malformed (Testing purpose) Parameters with None value will not be in the generated request (missing parameter). :param raw_data: Raw probe data to send (string, text/plain) - :param parser_name: Parser to be used (string) + :param probe_name: Parser to be used (string) :param entity_id: Entity ID (string) :param entity_type: Entity Type (string) :param http_method: send raw data is a HTTP POST request but, for testing purposes could be interesting to use @@ -125,10 +125,10 @@ def send_raw_data_custom(self, raw_data, parser_name=None, entity_id=None, entit if entity_type is not None: parameters.update({NGSI_ADAPTER_PARAMETER_TYPE: entity_type}) - if parser_name is not None: + if probe_name is not None: return self.rest_client.launch_request(uri_pattern=NGSI_ADAPTER_URI_PARSER, body=raw_data, method=http_method, headers=self.headers, parameters=parameters, - parser_name=parser_name) + probe_name=probe_name) else: return self.rest_client.launch_request(uri_pattern=NGSI_ADAPTER_URI_BASE, body=raw_data, method=http_method, headers=self.headers, parameters=parameters) diff --git a/ngsi_adapter/src/test/acceptance/commons/remote_tail_utils.py b/ngsi_adapter/src/test/acceptance/commons/remote_tail_utils.py index e79c87a..c23bd7e 100644 --- a/ngsi_adapter/src/test/acceptance/commons/remote_tail_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/remote_tail_utils.py @@ -141,12 +141,3 @@ def _read_tailer(tailer, local_capture_file_descriptor): logger.debug("Remote Tailer: Closing connections and file descriptors") tailer.disconnect() local_capture_file_descriptor.close() - - -if __name__ == '__main__': - remote_tail = RemoteTail("130.206.81.245", "root", "/var/log/ngsi_adapter/ngsi_adapter.log", - "../logs/remote", "../fiware_cloud_dsa") - remote_tail.init_tailer_connection() - remote_tail.start_tailer() - time.sleep(TIMER_GRACE_PERIOD) - remote_tail.stop_tailer() diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py index ef2e12c..08c6e61 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py @@ -56,6 +56,11 @@ def the_parser(step, probe_name, parser_name): world.parser = prepare_param(parser_name) +@step(u'the probe name "(.*)"') +def the_probe_name(step, probe_name): + world.probe = prepare_param(probe_name) + + @step(u'the monitored resource with id "(.*)" and type "(.*)"$') def the_monitored_resource_with_id_and_type(step, id, type): world.entity_id = prepare_param(id) @@ -68,7 +73,7 @@ def i_sed_raw_data_according_to_the_selected_parser(step): _set_default_dataset() probe_data = get_probe_data_from_resource_file(world.raw_data_filename, world.raw_data_params) - world.response = world.ngsi_adapter_client.send_raw_data_custom(probe_data, world.parser, + world.response = world.ngsi_adapter_client.send_raw_data_custom(probe_data, world.probe, world.entity_id, world.entity_type) @@ -78,7 +83,7 @@ def i_sed_raw_data_according_to_the_selected_parser_with_http_verb(step, http_ve _set_default_dataset() probe_data = get_probe_data_from_resource_file(world.raw_data_filename, world.raw_data_params) - world.response = world.ngsi_adapter_client.send_raw_data_custom(probe_data, world.parser, + world.response = world.ngsi_adapter_client.send_raw_data_custom(probe_data, world.probe, world.entity_id, world.entity_type, http_method=http_verb) @@ -110,7 +115,7 @@ def the_given_transaction_id_value_is_used_in_logs(step): transaction_id=world.transaction_id)} log_utils.search_in_log(remote_log_local_path, service_log_file_name, log_value_transaction_id) else: - log_value_message = {"MESSAGE": "msg={parser}".format(parser=world.parser)} + log_value_message = {"MESSAGE": "msg={probe}".format(probe=world.probe)} log_line = log_utils.search_in_log(remote_log_local_path, service_log_file_name, log_value_message) transaction_id = log_line[log_utils.LOG_TAG["TRANSACTION_ID"].replace("=", "")] diff --git a/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/qa_probe_parser_valid_template.txt b/ngsi_adapter/src/test/acceptance/resources/probe_sample_data/qa_probe_valid_template.txt similarity index 100% rename from ngsi_adapter/src/test/acceptance/resources/probe_sample_data/qa_probe_parser_valid_template.txt rename to ngsi_adapter/src/test/acceptance/resources/probe_sample_data/qa_probe_valid_template.txt diff --git a/ngsi_adapter/src/test/acceptance/settings/dev-properties.json b/ngsi_adapter/src/test/acceptance/settings/dev-properties.json index 852046d..49badc8 100644 --- a/ngsi_adapter/src/test/acceptance/settings/dev-properties.json +++ b/ngsi_adapter/src/test/acceptance/settings/dev-properties.json @@ -3,8 +3,8 @@ "name": "experimentation", "log_path": "./logs", "local_path_remote_logs": "./logs/remote/", - "default_parser": "qa_probe_parser", - "default_parser_data": "qa_probe_parser_valid_template", + "default_parser": "qa_probe", + "default_parser_data": "qa_probe_valid_template", "default_parser_parameters": [{"key":"NUM_USERS_VALUE", "value":"5"}] }, "monitoring_adapter_service": { diff --git a/ngsi_adapter/src/test/acceptance/logging.conf b/ngsi_adapter/src/test/acceptance/settings/logging.conf similarity index 100% rename from ngsi_adapter/src/test/acceptance/logging.conf rename to ngsi_adapter/src/test/acceptance/settings/logging.conf From 40febf40369520e7943487436a68840db18f3408 Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Mon, 19 Jan 2015 13:58:14 +0100 Subject: [PATCH 09/10] Documentation (draft) --- ngsi_adapter/src/test/acceptance/README.rst | 72 ++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/ngsi_adapter/src/test/acceptance/README.rst b/ngsi_adapter/src/test/acceptance/README.rst index 82719e4..1f7cbed 100644 --- a/ngsi_adapter/src/test/acceptance/README.rst +++ b/ngsi_adapter/src/test/acceptance/README.rst @@ -11,8 +11,8 @@ Gherkin has the purpose of serving documentation of test cases. Test case implementation has been performed using `Python `_ and `Lettuce `_. -Project Structure ------------------ +Acceptance Project Structure +---------------------------- :: ├───acceptance @@ -26,3 +26,71 @@ Project Structure │ │ └───probe_sample_data │ └───settings │ + + +FIWARE Monitoring Automation Framework +--------------------------------------- + +Features: + +- Lettuce-Tools support +- Settings using json files and Lettuce-Tools utility +- Test report using Lettuce-Tools XUnit output +- NGSI-Adapter Client +- Logging +- Remote NGSI-Adapter log capturing +- Test data management using templates (resources) + + +Acceptance test execution +------------------------- + +Execute the following command in the test project root directory: + +:: + + $> cd ngsi_adapter/src/test/acceptance + $> lettuce_tools -ft send_data_api_resource -ts comp -sd features/ --tags=-skip -en dev + +With this command, you will execute: + +- components Test Cases in the 'Development' environment configured in settings/dev-properties.json +- the send_data_api_resource feature +- Skipping all Scenarios with tagged with "skip" + + +**Prerequisites** + +- Python 2.7 or newer (2.x) (https://www.python.org/downloads/) +- pip (https://pypi.python.org/pypi/pip) +- virtualenv (https://pypi.python.org/pypi/virtualenv) +- Monitoring [NGSI-Adapter] (`Download NGSI-Adapter `_) + +**Test case execution using virtualenv** + +1. Create a virtual environment somewhere *(virtualenv ~/venv)* +#. Activate the virtual environment *(source ~/venv/bin/activate)* +#. Go to *ngsi_adapter/src/test/acceptance* folder in the project +#. Install the requirements for the acceptance tests in the virtual environment *(pip install -r requirements.txt --allow-all-external)* + +**Test case execution using Vagrant (optional)** + +Instead of using virtualenv, you can use the provided Vagrantfile to deploy a local VM using `Vagrant `_, +that will provide all environment configurations for launching test cases. + +1. Download and install Vagrant (https://www.vagrantup.com/downloads.html) +#. Go to *ngsi_adapter/src/test/acceptance* folder in the project +#. Execute *vagrant up* to launch a VM based on Vagrantfile provided. +#. After Vagrant provision, your VM is properly configured to launch acceptance tests. You have to access to the VM using +*vagrant ssh* and change to */vagrant* directory that will have mounted your workspace *(test/acceptance)*. + +If you need more information about how to use Vagrant, you can see +`Vagrant Getting Started `_ + +**Settings** + +Before executing the acceptance tests, you will need configure the properties file. To execute acceptance test on the +experimentation environment, you will have to configured the file *settings/dev-properties*. + +You will need a valid private key (*private_key_location*) to connect to NGSI-Adapter Host to capture remote logs. +In this way, you will be able to execute Scenarios that require the logs capturing for test validations. From 59ef096a4dba1e18e29abb6f66e58f650f48d6a0 Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Mon, 2 Feb 2015 16:53:54 +0100 Subject: [PATCH 10/10] Code style and minor issues --- ngsi_adapter/src/test/acceptance/README.rst | 4 ++-- ngsi_adapter/src/test/acceptance/Vagrantfile | 3 ++- ngsi_adapter/src/test/acceptance/commons/constants.py | 2 +- ngsi_adapter/src/test/acceptance/commons/dataset_utils.py | 2 +- ngsi_adapter/src/test/acceptance/commons/logger_utils.py | 2 +- .../src/test/acceptance/commons/remote_tail_utils.py | 5 +++-- .../src/test/acceptance/commons/rest_client_utils.py | 2 +- ngsi_adapter/src/test/acceptance/commons/terrain_utils.py | 2 +- ngsi_adapter/src/test/acceptance/commons/utils.py | 2 +- .../test/acceptance/features/component/send_data/steps.py | 2 +- .../test/acceptance/features/component/send_data/terrain.py | 2 +- 11 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ngsi_adapter/src/test/acceptance/README.rst b/ngsi_adapter/src/test/acceptance/README.rst index 1f7cbed..f505d3b 100644 --- a/ngsi_adapter/src/test/acceptance/README.rst +++ b/ngsi_adapter/src/test/acceptance/README.rst @@ -68,8 +68,8 @@ With this command, you will execute: **Test case execution using virtualenv** -1. Create a virtual environment somewhere *(virtualenv ~/venv)* -#. Activate the virtual environment *(source ~/venv/bin/activate)* +1. Create a virtual environment somewhere *(virtualenv $WORKON_HOME/venv)* +#. Activate the virtual environment *(source $WORKON_HOME/venv/bin/activate)* #. Go to *ngsi_adapter/src/test/acceptance* folder in the project #. Install the requirements for the acceptance tests in the virtual environment *(pip install -r requirements.txt --allow-all-external)* diff --git a/ngsi_adapter/src/test/acceptance/Vagrantfile b/ngsi_adapter/src/test/acceptance/Vagrantfile index 4f23a3a..aef9292 100644 --- a/ngsi_adapter/src/test/acceptance/Vagrantfile +++ b/ngsi_adapter/src/test/acceptance/Vagrantfile @@ -3,7 +3,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Every Vagrant virtual environment requires a box to build off of. + # Box: https://atlas.hashicorp.com/hashicorp/boxes/precise32 config.vm.box = "hashicorp/precise32" # Provision diff --git a/ngsi_adapter/src/test/acceptance/commons/constants.py b/ngsi_adapter/src/test/acceptance/commons/constants.py index 5b67812..fb51e25 100644 --- a/ngsi_adapter/src/test/acceptance/commons/constants.py +++ b/ngsi_adapter/src/test/acceptance/commons/constants.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ngsi_adapter/src/test/acceptance/commons/dataset_utils.py b/ngsi_adapter/src/test/acceptance/commons/dataset_utils.py index 4a49727..3be4bc0 100644 --- a/ngsi_adapter/src/test/acceptance/commons/dataset_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/dataset_utils.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ngsi_adapter/src/test/acceptance/commons/logger_utils.py b/ngsi_adapter/src/test/acceptance/commons/logger_utils.py index 373a2b8..46aa403 100644 --- a/ngsi_adapter/src/test/acceptance/commons/logger_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/logger_utils.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ngsi_adapter/src/test/acceptance/commons/remote_tail_utils.py b/ngsi_adapter/src/test/acceptance/commons/remote_tail_utils.py index c23bd7e..bfa2de7 100644 --- a/ngsi_adapter/src/test/acceptance/commons/remote_tail_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/remote_tail_utils.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -44,7 +44,8 @@ class RemoteTail: - def __init__(self, remote_host_ip, remote_host_user, remote_log_path, remote_log_file_name, local_log_target, private_key): + def __init__(self, remote_host_ip, remote_host_user, remote_log_path, remote_log_file_name, local_log_target, + private_key): """ Inits RemoteTail class :param remote_host_ip: Remote Host IP diff --git a/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py b/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py index 7909f9d..bdef1d4 100644 --- a/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/rest_client_utils.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ngsi_adapter/src/test/acceptance/commons/terrain_utils.py b/ngsi_adapter/src/test/acceptance/commons/terrain_utils.py index 7475911..4fc5f17 100644 --- a/ngsi_adapter/src/test/acceptance/commons/terrain_utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/terrain_utils.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ngsi_adapter/src/test/acceptance/commons/utils.py b/ngsi_adapter/src/test/acceptance/commons/utils.py index eb512f7..f8c0506 100644 --- a/ngsi_adapter/src/test/acceptance/commons/utils.py +++ b/ngsi_adapter/src/test/acceptance/commons/utils.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py index 08c6e61..76fae07 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/steps.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ngsi_adapter/src/test/acceptance/features/component/send_data/terrain.py b/ngsi_adapter/src/test/acceptance/features/component/send_data/terrain.py index 267df11..556548c 100644 --- a/ngsi_adapter/src/test/acceptance/features/component/send_data/terrain.py +++ b/ngsi_adapter/src/test/acceptance/features/component/send_data/terrain.py @@ -2,7 +2,7 @@ # Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U # -# This file is part of FI-WARE project. +# This file is part of FIWARE project. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.