Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/traces in log #1927

Merged
merged 15 commits into from
Mar 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions test/acceptance/behave/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,11 @@ The log is stored in `logs` folder (if this folder does not exist it is created)
| delete_context_provider_registration | (pending) | DELETE | /v2/registrations/`<registration_id>` | No | No |
| |
|**alarms folder** | (pending) | |
| |
|**cli_parameters folder** | (pending) | |




## Hints:
- If we need " char, use \' and it will be replaced (`mappping_quotes` method in `helpers_utils.py` library) (limitation in behave and lettuce).
- If value is "max length allowed", per example, it is a generated random value with max length allowed and characters allowed.
Expand Down Expand Up @@ -343,7 +345,11 @@ The log is stored in `logs` folder (if this folder does not exist it is created)
```
create an entity in raw and "normalized" modes
```

- If don´t want verify the value of something trace in log, use `ignored` as value.
```
| trace | value |
| time | ignored |
```

## Tags

Expand Down
23 changes: 23 additions & 0 deletions test/acceptance/behave/components/common_steps/general_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from iotqatools.helpers_utils import *
from iotqatools.cb_v2_utils import CB
from iotqatools.mongo_utils import Mongo
from iotqatools.remote_log_utils import Remote_Log
from iotqatools.fabric_utils import FabricSupport

from tools.properties_config import Properties # methods in properties class
from tools.NGSI_v2 import NGSI
Expand Down Expand Up @@ -140,6 +142,27 @@ def delete_database_in_mongo(context):
mongo.disconnect()
__logger__.info("...Database \"%s\" is deleted" % database_name)


@step(u'check in log, label "([^"]*)" and message "([^"]*)"')
def check_in_log_label_and_text(context, label, text):
"""
Verify in log file if a label with a message exists
:param step:
:param label: label to find
:param text: text to find (begin since the end)
"""
__logger__.debug("Looking for in log the \"%s\" label and the \"%s\" text...")
props_cb_env = properties_class.read_properties()[CONTEXT_BROKER_ENV]
remote_log = Remote_Log(file="%s/contextBroker.log" % props_cb_env["CB_LOG_FILE"], fabric=context.my_fab)
line = remote_log.find_line(label,text)
assert line != None, " ERROR - the \"%s\" label and the \"%s\" text do not exist in the log"
__logger__.info("log line: \n%s" %line)
ngsi = NGSI()
ngsi.verify_log(context, line)
__logger__.info("...confirmed traces in log")



# ------------------------------------- validations ----------------------------------------------

@step(u'verify that receive a.? "([^"]*)" http code')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-

# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U
#
# This file is part of Orion Context Broker.
#
# Orion Context Broker is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Orion Context Broker is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# iot_support at tid dot es
#
# author: 'Iván Arias León (ivan dot ariasleon at telefonica dot com)'

#
# Note: the "skip" tag is to skip the scenarios that still are not developed or failed
# -tg=-skip
#


Feature: verify fields in log traces with get attribute data request using NGSI v2.
As a context broker user
I would like to verify fields in log traces with get attribute data request using NGSI v2
So that I can manage and use them in my scripts

Actions Before the Feature:
Setup: update properties test file from "epg_contextBroker.txt" and sudo local "false"
Setup: update contextBroker config file
Setup: start ContextBroker
Check: verify contextBroker is installed successfully
Check: verify mongo is installed successfully

Actions After each Scenario:
Setup: delete database in mongo

Actions After the Feature:
Setup: stop ContextBroker

@traces_in_log
Scenario: verify log traces using NGSI v2 with get attribute data request
Given a definition of headers
| parameter | value |
| Fiware-Service | test_log_traces |
| Fiware-ServicePath | /test |
| Content-Type | application/json |
# These properties below are used in create request
And properties to entities
| parameter | value |
| entities_type | house |
| entities_id | room |
| attributes_number | 3 |
| attributes_name | temperature |
| attributes_value | 34 |
| attributes_type | celsius |
| metadatas_number | 2 |
| metadatas_name | very_hot |
| metadatas_type | alarm |
| metadatas_value | hot |
And create entity group with "3" entities in "normalized" mode
| entity | prefix |
| id | true |
And verify that receive several "Created" http code
When get an attribute "temperature_0" by ID "room_1"
Then verify that receive an "OK" http code
And verify that the attribute by ID is returned
And check in log, label "INFO" and message "msg=logMsg.h[1803]: Starting transaction from"
| trace | value |
| time | ignored |
| trans | ignored |
| srv | pending |
| subsrv | pending |
| from | pending |
| function | lmTransactionStart |
| comp | Orion |
And check in log, label "INFO" and message "msg=logMsg.h[1887]: Transaction ended"
| trace | value |
| time | ignored |
| trans | ignored |
| srv | test_log_traces |
| subsrv | /test |
| from | ignored |
| function | lmTransactionEnd |
| comp | Orion |
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-

# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U
#
# This file is part of Orion Context Broker.
#
# Orion Context Broker is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Orion Context Broker is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# iot_support at tid dot es
#
# author: 'Iván Arias León (ivan dot ariasleon at telefonica dot com)'

#
# Note: the "skip" tag is to skip the scenarios that still are not developed or failed
# -tg=-skip
#


Feature: verify fields in log traces with remove a single attribute request using NGSI v2.
As a context broker user
I would like to verify fields in log traces with remove a single attribute request using NGSI v2
So that I can manage and use them in my scripts

Actions Before the Feature:
Setup: update properties test file from "epg_contextBroker.txt" and sudo local "false"
Setup: update contextBroker config file
Setup: start ContextBroker
Check: verify contextBroker is installed successfully
Check: verify mongo is installed successfully

Actions After each Scenario:
Setup: delete database in mongo

Actions After the Feature:
Setup: stop ContextBroker

@traces_in_log
Scenario: verify log traces using NGSI v2 with remove a single attribute request
Given a definition of headers
| parameter | value |
| Fiware-Service | test_log_traces |
| Fiware-ServicePath | /test |
| Content-Type | application/json |
# These properties below are used in create request
And properties to entities
| parameter | value |
| entities_type | house |
| entities_id | room |
| attributes_number | 3 |
| attributes_name | temperature |
| attributes_value | 34 |
| attributes_type | celsius |
| metadatas_number | 2 |
| metadatas_name | very_hot |
| metadatas_type | alarm |
| metadatas_value | hot |
And create entity group with "3" entities in "normalized" mode
| entity | prefix |
| id | true |
And verify that receive several "Created" http code
When delete an attribute "temperature_0" in the entity with id "room_1"
Then verify that receive an "No Content" http code
And verify that the attribute is deleted into mongo in the defined entity
And check in log, label "INFO" and message "msg=logMsg.h[1803]: Starting transaction from"
| trace | value |
| time | ignored |
| trans | ignored |
| srv | pending |
| subsrv | pending |
| from | pending |
| function | lmTransactionStart |
| comp | Orion |
And check in log, label "INFO" and message "msg=logMsg.h[1887]: Transaction ended"
| trace | value |
| time | ignored |
| trans | ignored |
| srv | test_log_traces |
| subsrv | /test |
| from | ignored |
| function | lmTransactionEnd |
| comp | Orion |
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# -*- coding: utf-8 -*-

# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U
#
# This file is part of Orion Context Broker.
#
# Orion Context Broker is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Orion Context Broker is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# iot_support at tid dot es
#
# author: 'Iván Arias León (ivan dot ariasleon at telefonica dot com)'

#
# Note: the "skip" tag is to skip the scenarios that still are not developed or failed
# -tg=-skip
#


Feature: verify fields in log traces with update attribute data request using NGSI v2.
As a context broker user
I would like to verify fields in log traces with update attribute data request using NGSI v2
So that I can manage and use them in my scripts

Actions Before the Feature:
Setup: update properties test file from "epg_contextBroker.txt" and sudo local "false"
Setup: update contextBroker config file
Setup: start ContextBroker
Check: verify contextBroker is installed successfully
Check: verify mongo is installed successfully

Actions After each Scenario:
Setup: delete database in mongo

Actions After the Feature:
Setup: stop ContextBroker

@traces_in_log
Scenario: verify log traces using NGSI v2 with update attribute data request
Given a definition of headers
| parameter | value |
| Fiware-Service | test_log_traces |
| Fiware-ServicePath | /test |
| Content-Type | application/json |
# These properties below are used in create request
And properties to entities
| parameter | value |
| entities_type | house |
| entities_id | room |
| attributes_number | 3 |
| attributes_name | temperature |
| attributes_value | 34 |
| attributes_type | celsius |
| metadatas_number | 2 |
| metadatas_name | very_hot |
| metadatas_type | alarm |
| metadatas_value | hot |
And create entity group with "3" entities in "normalized" mode
| entity | prefix |
| id | true |
And verify that receive several "Created" http code
# These properties below are used in update request
And properties to entities
| parameter | value |
| attributes_value | 80 |
| attributes_type | Fahrenheit |
| metadatas_number | 3 |
| metadatas_name | very_hot |
| metadatas_type | alarm |
| metadatas_value | cold |
When update an attribute by ID "room_1" and attribute name "temperature_0" if it exists
Then verify that receive an "No Content" http code
And verify that an entity is updated in mongo
And check in log, label "INFO" and message "msg=logMsg.h[1803]: Starting transaction from"
| trace | value |
| time | ignored |
| trans | ignored |
| srv | pending |
| subsrv | pending |
| from | pending |
| function | lmTransactionStart |
| comp | Orion |
And check in log, label "INFO" and message "msg=logMsg.h[1887]: Transaction ended"
| trace | value |
| time | ignored |
| trans | ignored |
| srv | test_log_traces |
| subsrv | /test |
| from | ignored |
| function | lmTransactionEnd |
| comp | Orion |
Loading