Commit 77a89158 authored by lopezaguilar's avatar lopezaguilar Committed by Benoit Orihuela
Browse files

Remove resources/ApiUtils.resource, simplify notification_server_host, and...

parent d56d35a4
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Run All Test Suites with Listener" type="RobotFramework" factoryName="RobotFramework">
    <option name="target" value="$ProjectFileDir$" />
    <option name="args">
      <list>
        <option value="--listener" />
        <option value="libraries/ErrorListener.py" />
        <option value="--outputdir" />
        <option value="./results" />
      </list>
    </option>
    <option name="env">
      <map />
    </option>
    <option name="workingDir" value="$ProjectFileDir$" />
    <option name="makeSuite" value="true" />
    <method v="2" />
  </configuration>
</component>
 No newline at end of file
+17 −0
Original line number Original line Diff line number Diff line
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Run Current Test Suite" type="RobotFramework" factoryName="RobotFramework">
    <option name="target" value="$FilePath$" />
    <option name="args">
      <list>
        <option value="--outputdir" />
        <option value="./results" />
      </list>
    </option>
    <option name="env">
      <map />
    </option>
    <option name="workingDir" value="$ProjectFileDir$" />
    <option name="makeSuite" value="true" />
    <method v="2" />
  </configuration>
</component>
 No newline at end of file
+19 −0
Original line number Original line Diff line number Diff line
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Run Current Test Suite with Listener" type="RobotFramework" factoryName="RobotFramework">
    <option name="target" value="$FilePath$" />
    <option name="args">
      <list>
        <option value="--listener" />
        <option value="libraries/ErrorListener.py" />
        <option value="--outputdir" />
        <option value="./results" />
      </list>
    </option>
    <option name="env">
      <map />
    </option>
    <option name="workingDir" value="$ProjectFileDir$" />
    <option name="makeSuite" value="true" />
    <method v="2" />
  </configuration>
</component>
 No newline at end of file
+44 −20
Original line number Original line Diff line number Diff line
@@ -61,19 +61,28 @@ taking into account the content of `requirements.txt` file. Further details on e


In the `resources/variables.py` file, configure the following parameters:
In the `resources/variables.py` file, configure the following parameters:


- `url` : It is the url of the context broker which is to be tested (including the `ngsi-ld/v1` path, 
- `url` : It is the url of the context broker which is to be tested (including the `/ngsi-ld/v1` path, 
e.g., http://localhost:8080/ngsi-ld/v1).
e.g., http://localhost:8080/ngsi-ld/v1).
-`temporal_api_url` : This is the url of the GET temporal operation API, in case that a Context Broker splits 
this portion of the API (e.g., http://localhost:8080/ngsi-ld/v1).
- `ngsild_test_suite_context` : This is the url of the default context used in the ETSI NGSI-LD requests 
(e.g., 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld').
- `notification_server_host` and `notification_server_port` : This is the address and port used to create the local 
- `notification_server_host` and `notification_server_port` : This is the address and port used to create the local 
server to listen to notifications (the address must be accessible by the context broker). 
server to listen to notifications (the address must be accessible by the context broker). 
Default value: `0.0.0.0` and `8085`.
Default value: `0.0.0.0` and `8085`.
- `send_notification_server_host` and `send_notification_server_port` : This is the address and port used when 
creating the subscription on the context broker (generally it is the same information as `notification_server_host` 
and `notification_server_port`). Default value: `0.0.0.0` and `8085`.
- `context_source_host` and `context_source_port` : The address and port used for the context source. 
- `context_source_host` and `context_source_port` : The address and port used for the context source. 
Default value: `0.0.0.0` and `8086`.
Default value: `0.0.0.0` and `8086`.


When you execute locally the tests, you can leave the default values as they are. NGSI-LD Test Suite provides
When you execute locally the tests, you can leave the default values as they are. NGSI-LD Test Suite provides
some mockup services to provide the required functionality.
a mockup services to provide the notification functionality and therefore the notification_server_host can be
assigned to '0.0.0.0'. In case that you deploy the Context Broker on a docker engine, you need to specify the
url of the Docker Host. In this case you have two options to specify the IP address of your host machine:

- (Windows, MacOS) As of Docker v18.03+ you can use the `host.docker.internal` hostname to connect to your 
Docker host.
- (Linux) Need to extract the IP of the `docker0` interface. Execute the following command:
``` ifconfig docker0 | grep inet | awk '{print $2}' ``` and that IP is the one that you need to use for 
notification purposes.




## Execute the NGSI-LD Test Suite
## Execute the NGSI-LD Test Suite
@@ -110,18 +119,6 @@ test launch command followed by the file name.


```$ robot . > results.log```
```$ robot . > results.log```


If you want to generate a documentation for the support keywords:

```$ python3 -m robot.libdoc resources/ApiUtils.resource api_docs/ApiUtils.html```

If you want to generate a documentation for the Test Cases:

```$ python3 -m robot.testdoc TP/NGSI-LD api_docs/TestCases.html```

And if you want to tidy the Test Cases:

```$ python3 -m robot.tidy --recursive TP/NGSI-LD```

> **Note:** if you want to deactivate the Python Virtual Environment just execute the command in 
> **Note:** if you want to deactivate the Python Virtual Environment just execute the command in 
> MacOS and Ubuntu systems:
> MacOS and Ubuntu systems:
> 
> 
@@ -194,7 +191,7 @@ The `find_unused_test_data.py` script in the `scripts` directory can be used to
that are not used by any Test Case:
that are not used by any Test Case:


```
```
python3 scripts/find_unused_test_data.py
$ python3 scripts/find_unused_test_data.py
```
```


### Find and run Test Cases using a given test data file
### Find and run Test Cases using a given test data file
@@ -203,11 +200,38 @@ The `find_tc_using_test_data.py` script in the `scripts` directory can be used t
given test data file. It can optionally run all the matching Test Cases:
given test data file. It can optionally run all the matching Test Cases:


```
```
python3 scripts/find_tc_using_test_data.py
$ python3 scripts/find_tc_using_test_data.py
```
```


When launched, the script asks for a test date file name and if the matching Test Cases should be executed.
When launched, the script asks for a test date file name and if the matching Test Cases should be executed.


### Find the list of defined Variables and Keywords in all resources files

The `apiutils.py` script in the `scripts` directory can be used to find the Variables and Keywords that are defined
in all resources files defined in the folder `resources/ApiUtils`.

```
$ python3 scripts/apiutils.py
```

### Generate documentation content

If you want to generate a documentation for the support keywords, for example for Context Information Consumption 
resources:

```$ python3  -m robot.libdoc  resources/ApiUtils/ContextInformationConsumption.resource  api_docs/ContextInformationConsumption.html```

And, if you want to generate a documentation for the Test Cases:

```$ python3  -m robot.testdoc  TP/NGSI-LD  api_docs/TestCases.html```

### Coding Style of Test Suites

And if you want to tidy (code style) the Test Suites:

```$ python3  -m robot.tidy  --recursive TP/NGSI-LD```


## Frameworks and libraries used in the project
## Frameworks and libraries used in the project


* [Robot Framework](https://github.com/robotframework/robotframework)
* [Robot Framework](https://github.com/robotframework/robotframework)
+11 −5
Original line number Original line Diff line number Diff line
*** Settings ***
*** Settings ***
Documentation       Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed
Documentation       Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed


Resource            ${EXECDIR}/resources/ApiUtils.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource


@@ -21,7 +27,7 @@ ${content_type}= application/json




*** Test Cases ***
*** Test Cases ***
044_02_01_endpoint /entities/{entityId}
045_01_01 Endpoint /entities/{entityId}
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/entities/{entityId})
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/entities/{entityId})
    [Tags]    e-query    6_3_4
    [Tags]    e-query    6_3_4
    ${id}=    Generate Random Entity Id    ${building_id_prefix}
    ${id}=    Generate Random Entity Id    ${building_id_prefix}
@@ -36,7 +42,7 @@ ${content_type}= application/json
    Check Response Headers Link Not Empty    ${response.headers}
    Check Response Headers Link Not Empty    ${response.headers}
    [Teardown]    Delete Entity by Id Returning Response    ${id}
    [Teardown]    Delete Entity by Id Returning Response    ${id}


044_02_02_endpoint /subscriptions/{subscriptionId}
045_01_02 Endpoint /subscriptions/{subscriptionId}
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/subscriptions/{subscriptionId})
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/subscriptions/{subscriptionId})
    [Tags]    sub-retrieve    6_3_4
    [Tags]    sub-retrieve    6_3_4
    ${id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${id}=    Generate Random Entity Id    ${subscription_id_prefix}
@@ -48,7 +54,7 @@ ${content_type}= application/json
    Check Response Headers Link Not Empty    ${response.headers}
    Check Response Headers Link Not Empty    ${response.headers}
    [Teardown]    Delete Subscription    ${id}
    [Teardown]    Delete Subscription    ${id}


044_02_03_endpoint /csourceRegistrations/
045_01_03 Endpoint /csourceRegistrations/
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/csourceRegistrations/)
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/csourceRegistrations/)
    [Tags]    csr-query    6_3_4
    [Tags]    csr-query    6_3_4
    ${registration_id}=    Generate Random Entity Id    ${registration_id_prefix}
    ${registration_id}=    Generate Random Entity Id    ${registration_id_prefix}
@@ -66,7 +72,7 @@ ${content_type}= application/json
    Check Response Headers Link Not Empty    ${response.headers}
    Check Response Headers Link Not Empty    ${response.headers}
    [Teardown]    Delete Context Source Registration    ${registration_id}
    [Teardown]    Delete Context Source Registration    ${registration_id}


044_02_04_endpoint /temporal/entities
045_01_04 Endpoint /temporal/entities
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/temporal/entities)
    [Documentation]    Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/temporal/entities)
    [Tags]    te-query    6_3_4
    [Tags]    te-query    6_3_4
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${tea_id_prefix}
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${tea_id_prefix}
Loading