From 70bc2ecce6bc3c32f50a1d28fa9c4c1b6a085af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Tue, 11 Jul 2023 17:39:47 +0200 Subject: [PATCH 01/10] First version with windows execution description together with virtual python environment --- .gitignore | 3 +- README.md | 90 +++++++++++++++++++++++++++++++++++++++--------- requirements.txt | 8 ++--- 3 files changed, 79 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 5393a5e1..b2e080cf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ resources/__pycache__ results *.pyc *.http -.vscode/ \ No newline at end of file +.vscode/ +.idea diff --git a/README.md b/README.md index 3458ff56..fe1ee956 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,101 @@ # Quick start guide -## Install Python & PIP +## Install Python, PIP & Virtualenv -* Install Python3 by running the following command: +* Install Python3 by running the following command in the terminal: ```$ sudo dnf install python3``` (Ubuntu) ```$ brew install python3``` (MacOS) +In case of Windows 11, open the Microsoft Store from the PowerShell: + +```$ start ms-windows-store:``` (Windows 11) + +and search python3.11 to install it. + * Confirm its installation with: ```$ python3 --version``` (Ubuntu) ```$ python3 --version``` (MacOS) +```$ python3 --version``` (Windows 11) + * At this point, you can launch Python3 interpreter: ```$ python3``` (Ubuntu) ```$ python3``` (MacOS) +```$ python3``` (Windows 11) + * Pip should be included by default. To confirm, run: -```$ command -v pip``` (Ubuntu) +```$ pip3 --version``` (Ubuntu) ```$ pip3 --version``` (MacOS) -* In case pip is not installed, [follow the official pip installation guide](https://pip.pypa.io/en/latest/installing/). +```$ pip3 --version``` (Windows 11) + +In case pip is not installed, [follow the official pip installation guide](https://pip.pypa.io/en/latest/installing/). + +* Install virtualenv + +```$ pip3 intall virtualenv``` (Ubuntu) + +```$ pip3 intall virtualenv``` (MacOS) + +```$ pip3 intall virtualenv``` (Windows 11) + +In case of Windows, it is needed to execute the following command: + +```$ Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted``` + +to be able to run scripts from the powershell. + +## Checkout the base project + +```$ git clone https://forge.etsi.org/rep/cim/ngsi-ld-test-suite.git``` + +* In case git is not installed, [follow the official git installation guide](https://git-scm.com/downloads). + +## Create the python virtual environment + +```$ virtualenv -ppython3.11 .venv``` (Ubuntu) + +```$ virtualenv -ppyton3.11 .venv``` (MacOS) + +```$ python -m virtualenv -ppython3.11 .venv``` (Windows 11) + +## Activate the python virtual environment + +```$ source ./.venv/bin/activate``` (Ubuntu) + +```$ source ./.venv/bin/activate``` (MacOS) + +```$ .\.venv\Script\activate``` (Windows 11) + +* After the execution you will see the prompt with the (.venv). To deactivate the python environment just execute the +following command: + +```$ deactivate``` (Ubuntu) + +```$ deactivate``` (MacOS) + +```$ deactivate``` (Windows 11) + +## Install the project requirements + +Browse the base project root folder and execute the following command: + +```$ pip install -r requirements.txt``` (Ubuntu) + +```$ pip install -r requirements.txt``` (MacOS) + +```$ pip install -r requirements.txt``` (Windows 11) + +Further details on each library can be found in [PyPi](https://pypi.org/) and [Robot Framework Standard Libraries](http://robotframework.org/robotframework/#standard-libraries) ## Install IDE (PyCharm) @@ -43,9 +112,6 @@ insert the following: `{"EXECDIR": "{path}/auth-test-suite"}` * Install [Robot Framework Intellisense](https://marketplace.visualstudio.com/items?itemName=TomiTurtiainen.rf-intellisense) -## Checkout the base project - -```$ git clone git@forge.etsi.org:cim/ngsi-ld-test-suite.git``` ## Configure the environment @@ -55,16 +121,6 @@ In the `resources/variables.py` file, configure the following: * `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`). * `context_source_host` and `context_source_port` : The address and port used for the context source. -## Install the project requirements - -Browse the base project root folder and execute the following command: - -```$ python3 -m pip install -r requirements.txt``` (Ubuntu) - -```$ python3 -m pip install -r requirements.txt``` (MacOS) - -Further details on each library can be found in [PyPi](https://pypi.org/) and [Robot Framework Standard Libraries](http://robotframework.org/robotframework/#standard-libraries) - ## Run configurations (PyCharm) Two sample configurations have been created: diff --git a/requirements.txt b/requirements.txt index f6f16821..ff776daa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # python3.10 project -robotframework==6.0.2 +robotframework==6.1 robotframework-jsonlibrary==0.5 -robotframework-requests==0.9.4 -deepdiff==6.3.0 +robotframework-requests==0.9.5 +deepdiff==6.3.1 robotframework-httpctrl==0.3.1 -robotframework-tidy==4.2.1 +robotframework-tidy==4.4.0 -- GitLab From e80afc854b13b83dc63d492da0684795c7bf338f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Mon, 17 Jul 2023 18:43:29 +0200 Subject: [PATCH 02/10] Configuration script for ubuntu --- scripts/configure.sh | 294 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 294 insertions(+) create mode 100644 scripts/configure.sh diff --git a/scripts/configure.sh b/scripts/configure.sh new file mode 100644 index 00000000..0d287e0d --- /dev/null +++ b/scripts/configure.sh @@ -0,0 +1,294 @@ +#!/bin/bash + +# Function to check if a command is available +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + + +# Install Chocolatey (Windows) +install_chocolatey() { + echo "Installing Chocolatey..." + powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" + + if command_exists choco; then + echo "Chocolatey was installed successfully." + else + echo "Failed to install Chocolatey." + exit 1 + fi +} + +# Install Homebrew (macOS) +install_homebrew() { + echo "Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + if command_exists brew; then + echo "Brew was installed successfully." + else + echo "Failed to install Brew." + exit 1 + fi +} + + +# Install virtualenv (All OS) +install_virtualenv() { + if command_exists virtualenv; then + echo " - Virtualenv is already installed." + else + echo " - Installing virtualenv..." + python3.11 -m ensurepip --upgrade + python3.11 -m pip install virtualenv + + if command_exists virtualenv; then + echo " - Virtualenv installed successfully." + else + echo " - Failed to install Virtualenv" + fi + fi +} + +# Function to prompt for yes/no confirmation +confirm() { + local prompt="${1:-Are you sure? [Y/n]} " + local default_value="${2:-Y}" + + read -p "$prompt" response + response=${response:-$default_value} + response=$(echo "$response" | tr '[:upper:]' '[:lower:]') + + if [[ $response == "y" || $response == "yes" ]]; then + return 1 + elif [[ $response == "n" || $response == "no" ]]; then + return 0 + else + echo "Invalid response. Please enter 'Y' or 'N'." + confirm "$prompt" "$default_value" + fi +} + +# Create the virtualenv .venv, activate, and install python requirements +configure_virtualenv() { + echo "Configuring Python Virtual Environment" + echo " - Cloning the ETSI repository in the current folder" + git clone https://forge.etsi.org/rep/cim/ngsi-ld-test-suite.git >/dev/null 2>/dev/null + cd ngsi-ld-test-suite >/dev/null 2>/dev/null + + # Temporal need to change the git branch + git checkout windows11 >/dev/null 2>/dev/null + + echo " - Creating Python Virtual Environment" + + if [ -d "./.venv" ]; then + echo " - .venv directory already exists" + + # Prompt for confirmation + confirm " Do you want to delete and generate it again? [Y/n]? " "Y" + + # Check the return value + if [ $? -eq 1 ]; then + echo " Deleting previous .venv folder..." + rm -rf -y .venv >/dev/null 2>/dev/null + virtualenv -ppython3.11 .venv >/dev/null 2>/dev/null + else + echo " You declined. Aborting..." + fi + else + virtualenv -ppython3.11 .venv >/dev/null 2>/dev/null + fi + + # Activate the .venv + echo " - Activating .venv" + source .venv/bin/activate >/dev/null 2>/dev/null + + # Install the requirements + echo " - Installing the python requirements from the project" + pip install -r requirements.txt >/dev/null 2>/dev/null +} + + +# Configuration script for macOS +execute_macos() { + echo "macOS operating system, installing requirements..." + + # Check if Homebrew is already installed + if ! command_exists brew; then + install_homebrew + else + echo "Homebrew is already installed." + fi + + # Check if git is already installed + if ! command_exists git; then + brew install git + + # Check that git was successfully installed + if command_exists git; then + echo "Git installed successfully" + else + echo "Failed to install Git." + exit 1 + fi + else + echo "Git is already installed." + fi + + # Check if Python 3.11 is already installed + if command_exists python3.11; then + echo "Python 3.11 is already installed." + else + # Install Python 3.11 for macOS + echo "Installing Python 3.11 for macOS..." + brew install python@3.11 + + # Check if Python 3.11 was installed successfully + if command_exists python3.11; then + echo "Python 3.11 was installed successfully on macOS." + else + echo "Failed to install Python 3.11 on macOS." + exit 1 + fi + fi + + # Create the virtualenv .venv, activate, and install python requirements + configure_virtualenv +} + +# Configuration script for Linux +execute_linux() { + echo "Linux operating system, installing requirements..." + + # Check if git is already installed + if ! command_exists git; then + echo " - Installing Git." + sudo apt-get install -y -qq git >/dev/null 2>/dev/null + + # Check that git was successfully installed + if command_exists git; then + echo " - Git installed successfully." + else + echo " - Failed to install Git." + exit 1 + fi + else + echo " - Git is already installed." + fi + + # Check if Python 3.11 is already installed + if command_exists python3.11; then + echo " - Python 3.11 is already installed." + else + # Install Python 3.11 for Ubuntu + echo " - Installing Python 3.11, Pip, and Virtualenv for Ubuntu..." + sudo add-apt-repository -y ppa:deadsnakes/ppa >/dev/null 2>/dev/null + sudo apt-get update -y -qq >/dev/null 2>/dev/null + sudo apt-get install -y -qq python3.11 python3-pip python3-virtualenv >/dev/null 2>/dev/null + + # Check if Python 3.11 was installed successfully + if command_exists python3.11; then + echo " - Python 3.11 was installed successfully." + else + echo " - Failed to install Python 3.11." + exit 1 + fi + + # Check if Pip was installed successfully + if command_exists pip3; then + echo " - Pip3 was installed successfully." + else + echo " - Failed to install Pip3." + exit 1 + fi + + # Check if Virtualenv was installed successfully + if command_exists virtualenv; then + echo " - Virtualenv was installed successfully." + else + echo " - Failed to install Virtualenv." + exit 1 + fi + + fi + + echo + + # Create the virtualenv .venv, activate, and install python requirements + configure_virtualenv +} + +# Configuration script for Windows +execute_window() { + echo "Windows operating system, installing requirements..." + + # Check if Chocolatey is already installed + if ! command_exists choco; then + install_chocolatey + else + echo "Chocolatey is already installed." + fi + + + # Check if git is already installed + if ! command_exists git; then + choco install git -y + + # Check that git was successfully installed + if command_exists git; then + echo "Git installed successfully" + else + echo "Failed to install Git." + exit 1 + fi + else + echo "Git is already installed." + fi + + + # Check if Python 3.11 is already installed + if command_exists python3.11; then + echo "Python 3.11 is already installed." + else + # Install Python 3.11 for Windows 11 + echo "Installing Python 3.11 for Windows 11..." + choco install python --pre --version=3.11 + + # Check if Python 3.11 was installed successfully + if command_exists python3.11; then + echo "Python 3.11 was installed successfully." + else + echo "Failed to install Python 3.11." + exit 1 + fi + fi + + # Install Virtualenv + install_virtualenv + + # Create the virtualenv .venv, activate, and install python requirements + configure_virtualenv +} + +# Determine the operating system +os=$(uname -s) + +# Execute the script based in the OS +if [[ $os == "Darwin" ]]; then + execute_macos + echo + echo "Ready to use..." +elif [[ $os == "Linux" ]]; then + execute_linux + echo + echo "Ready to use..." +elif [[ $os == "Windows_NT" ]]; then + execute_window + echo + echo "Ready to use..." +else + echo "Unsupported operating system: $os" + exit 1 +fi + +exit 1 -- GitLab From f65822e50caf114979e32a948644b7de5da00f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Tue, 18 Jul 2023 16:11:56 +0200 Subject: [PATCH 03/10] Automatic configuration in MacOS (Monterey) --- scripts/configure.sh | 49 ++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/scripts/configure.sh b/scripts/configure.sh index 0d287e0d..314f1880 100644 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -21,13 +21,13 @@ install_chocolatey() { # Install Homebrew (macOS) install_homebrew() { - echo "Installing Homebrew..." + echo " - Installing Homebrew..." /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" if command_exists brew; then - echo "Brew was installed successfully." + echo " - Brew was installed successfully." else - echo "Failed to install Brew." + echo " - Failed to install Brew." exit 1 fi } @@ -105,7 +105,7 @@ configure_virtualenv() { # Install the requirements echo " - Installing the python requirements from the project" - pip install -r requirements.txt >/dev/null 2>/dev/null + pip3 install -r requirements.txt >/dev/null 2>/dev/null } @@ -117,41 +117,60 @@ execute_macos() { if ! command_exists brew; then install_homebrew else - echo "Homebrew is already installed." + echo " - Homebrew is already installed." fi # Check if git is already installed if ! command_exists git; then - brew install git + echo " - Installing git..." + brew install git --quiet >/dev/null 2>/dev/null # Check that git was successfully installed if command_exists git; then - echo "Git installed successfully" + echo " - Git installed successfully" else - echo "Failed to install Git." + echo " - Failed to install Git." exit 1 fi else - echo "Git is already installed." + echo " - Git is already installed." fi # Check if Python 3.11 is already installed if command_exists python3.11; then - echo "Python 3.11 is already installed." + echo " - Python 3.11 is already installed." else - # Install Python 3.11 for macOS - echo "Installing Python 3.11 for macOS..." - brew install python@3.11 + # Install Python 3.11 for macOS, it includes also the installation of pip3 + echo " - Installing Python 3.11 (with pip) and Virtualenv for macOS..." + brew install python@3.11 virtualenv --quiet >/dev/null 2>/dev/null # Check if Python 3.11 was installed successfully if command_exists python3.11; then - echo "Python 3.11 was installed successfully on macOS." + echo " - Python 3.11 was installed successfully on macOS." + else + echo " - Failed to install Python 3.11 on macOS." + exit 1 + fi + + # Check if Pip was installed successfully + if command_exists pip3; then + echo " - Pip3 was installed successfully." + else + echo " - Failed to install Pip3." + exit 1 + fi + + # Check if Virtualenv was installed successfully + if command_exists virtualenv; then + echo " - Virtualenv was installed successfully." else - echo "Failed to install Python 3.11 on macOS." + echo " - Failed to install Virtualenv." exit 1 fi fi + echo + # Create the virtualenv .venv, activate, and install python requirements configure_virtualenv } -- GitLab From 117e1322aed2bbd52b651a3c925ee085415a3c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 20 Jul 2023 09:02:07 +0200 Subject: [PATCH 04/10] Updating README content, python version, configuration script, and default value of url --- LICENSE | 23 +++++ README.md | 193 +++++++++++++++++++++-------------------- requirements.txt | 2 +- resources/variables.py | 2 +- scripts/configure.sh | 134 ++++++++-------------------- 5 files changed, 159 insertions(+), 195 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..e4a76bdb --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +Copyright 2021 ETSI + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index fe1ee956..0285f492 100644 --- a/README.md +++ b/README.md @@ -1,127 +1,143 @@ # Quick start guide -## Install Python, PIP & Virtualenv +This tutorial is an introduction to the [FIWARE Cosmos Orion Flink Connector](http://fiware-cosmos-flink.rtfd.io), which +facilitates Big Data analysis of context data, through an integration with [Apache Flink](https://flink.apache.org/), +one of the most popular Big Data platforms. Apache Flink is a framework and distributed processing engine for stateful +computations both over unbounded and bounded data streams. Flink has been designed to run in all common cluster +environments, perform computations at in-memory speed and at any scale. -* Install Python3 by running the following command in the terminal: -```$ sudo dnf install python3``` (Ubuntu) +## Contents -```$ brew install python3``` (MacOS) +
-In case of Windows 11, open the Microsoft Store from the PowerShell: +Details -```$ start ms-windows-store:``` (Windows 11) +- [Install the Test Suite](install_the_test_suite) +- [Configure the test suite](Configure the test suite) +- [Execute the NGSI-LD Test Suite](Execute the NGSI-LD Test Suite) +- [Contribute to the Test Suite](Contribute to the Test Suite) + - [Install IDE (PyCharm)](Install IDE (PyCharm)) + - [Install IDE (VSCode)](Install IDE (VSCode)) + - [Run configurations (PyCharm)](Run configurations (PyCharm)) + - [Pre commit](Pre commit) +- [Frameworks and libraries used in the project](Frameworks and libraries used in the project) +- [Useful links](Useful links) +- [LICENSE](LICENSE) -and search python3.11 to install it. -* Confirm its installation with: +
-```$ python3 --version``` (Ubuntu) -```$ python3 --version``` (MacOS) +## Install the Test Suite -```$ python3 --version``` (Windows 11) +In order to install the NGSI-LD Test Suite, download the configuration script: -* At this point, you can launch Python3 interpreter: +- For MacOS and Ubuntu, download the following file: -```$ python3``` (Ubuntu) +```$ curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure-linux.sh > configure.sh``` -```$ python3``` (MacOS) +- For Windows, download the following file: -```$ python3``` (Windows 11) +```$ curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure-windows.sh > configure.sh``` -* Pip should be included by default. To confirm, run: +- Be sure that you have the proper execution permission of the file and execute it: -```$ pip3 --version``` (Ubuntu) +```$ configure.sh``` -```$ pip3 --version``` (MacOS) +This script will install the corresponding requirements to execute the Test Suite: -```$ pip3 --version``` (Windows 11) +- Python3.11 +- Git +- Virtualenv +- Pip -In case pip is not installed, [follow the official pip installation guide](https://pip.pypa.io/en/latest/installing/). +Clone the NGSI-LD Test Suite repository in the local folder and create the corresponding Python Virtual Environment +taking into account the content of `requirements.txt` file. Further details on each library can be found in +[PyPi](https://pypi.org/) and +[Robot Framework Standard Libraries](http://robotframework.org/robotframework/#standard-libraries). -* Install virtualenv -```$ pip3 intall virtualenv``` (Ubuntu) +## Configure the test suite -```$ pip3 intall virtualenv``` (MacOS) +In the `resources/variables.py` file, configure the following parameters: -```$ pip3 intall virtualenv``` (Windows 11) +- `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). +- `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). +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. +Default value: `0.0.0.0` and `8086`. -In case of Windows, it is needed to execute the following command: -```$ Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted``` +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 teh required functionality. -to be able to run scripts from the powershell. -## Checkout the base project +## Execute the NGSI-LD Test Suite -```$ git clone https://forge.etsi.org/rep/cim/ngsi-ld-test-suite.git``` +The first operation that you have to develop is the activation of the Python Virtual Environment through the +execution of the following command in MacOS or Ubuntu: -* In case git is not installed, [follow the official git installation guide](https://git-scm.com/downloads). +```$ source .venv/bin/activate``` -## Create the python virtual environment +In case of Windows, you need to execute the following command: -```$ virtualenv -ppython3.11 .venv``` (Ubuntu) +```$ .... ``` -```$ virtualenv -ppyton3.11 .venv``` (MacOS) +Now, we can launch the tests with the following command: -```$ python -m virtualenv -ppython3.11 .venv``` (Windows 11) - -## Activate the python virtual environment +```$ robot --outputdir ./results .``` -```$ source ./.venv/bin/activate``` (Ubuntu) +For more running instructions please consult [scripts/run_tests.sh](./scripts/run_tests.sh). -```$ source ./.venv/bin/activate``` (MacOS) +If we want to generate a documentation for the support keywords: -```$ .\.venv\Script\activate``` (Windows 11) +```$ python3 -m robot.libdoc resources/ApiUtils.resource api_docs/ApiUtils.html``` -* After the execution you will see the prompt with the (.venv). To deactivate the python environment just execute the -following command: +If we want to generate a documentation for the Test Cases: -```$ deactivate``` (Ubuntu) +```$ python3 -m robot.testdoc TP/NGSI-LD api_docs/TestCases.html``` -```$ deactivate``` (MacOS) +And if we want to tidy the Test Cases: -```$ deactivate``` (Windows 11) +```$ python3 -m robot.tidy --recursive TP/NGSI-LD``` -## Install the project requirements +Note: if we want to deactivate the Python Virtual Environment just execute the command `deactivate`. -Browse the base project root folder and execute the following command: -```$ pip install -r requirements.txt``` (Ubuntu) +## Contribute to the Test Suite -```$ pip install -r requirements.txt``` (MacOS) +In order to contribute to the NGSI-LD Test Suite, we recommend the installation of an IDE with the corresponding +Robot Framework. Our recommendations are: -```$ pip install -r requirements.txt``` (Windows 11) +- PyCharm +- VisualStudio Code -Further details on each library can be found in [PyPi](https://pypi.org/) and [Robot Framework Standard Libraries](http://robotframework.org/robotframework/#standard-libraries) -## Install IDE (PyCharm) +### Install IDE (PyCharm) -* Install [PyCharm](https://www.jetbrains.com/fr-fr/pycharm/download) +- Install [PyCharm](https://www.jetbrains.com/fr-fr/pycharm/download) -* Install [Robot Framework Language Server](https://plugins.jetbrains.com/plugin/16086-robot-framework-language-server) +- Install [Robot Framework Language Server](https://plugins.jetbrains.com/plugin/16086-robot-framework-language-server) -* Define as variable the path of the working directory: in Settings > Languages & Frameworks > Robot Framework (Project), +- Define as variable the path of the working directory. In Settings > Languages & Frameworks > Robot Framework (Project), insert the following: `{"EXECDIR": "{path}/auth-test-suite"}` -## Install IDE (VSCode) - -* Install [Visual Studio Code](https://code.visualstudio.com/docs/setup/linux) -* Install [Robot Framework Intellisense](https://marketplace.visualstudio.com/items?itemName=TomiTurtiainen.rf-intellisense) +### Install IDE (VSCode) +- Install [Visual Studio Code](https://code.visualstudio.com/docs/setup/linux) -## Configure the environment +- Install +[Robot Framework Intellisense](https://marketplace.visualstudio.com/items?itemName=TomiTurtiainen.rf-intellisense) -In the `resources/variables.py` file, configure the following: -* `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). -* `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). -* `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`). -* `context_source_host` and `context_source_port` : The address and port used for the context source. -## Run configurations (PyCharm) +### Run configurations (PyCharm) Two sample configurations have been created: @@ -130,12 +146,13 @@ Two sample configurations have been created: To launch a run configuration, choose one of the two configurations from the Run menu and click on it to run it. -## Pre commit -Before each commit, a formatting according to the rules of [Robotidy](https://github.com/MarketSquare/robotframework-tidy) - is done for files with the `.robot` or `.resource` extension. If nothing has been modified, the commit is done normally. - Otherwise, the commit displays an error message with all the modifications made by Robotidy to format the file. Modified - files can then be added to the commit. +### Pre commit + +Before each commit, a formatting according to the rules of +[Robotidy](https://github.com/MarketSquare/robotframework-tidy) is done for files with the `.robot` or `.resource` +extension. If nothing has been modified, the commit is done normally. Otherwise, the commit displays an error message +with all the modifications made by Robotidy to format the file. Modified files can then be added to the commit. To use it, install `pre-commit` with the following commands (using pip): @@ -149,33 +166,12 @@ Now, it will run automatically on every commit. To manually launch the tool, the following command can be used: -```$ ./venv/bin/python -m robotidy .``` +```$ python -m robotidy .``` Further details can be found on the [pre-commit](https://pre-commit.com) site. -## Execute the tests - -Configure the context broker URL in the resources/variables.py file - -Launch the tests with the following command: - -```$ robot --outputdir ./results .``` - -For more running instructions please consult [scripts/run_tests.sh](./scripts/run_tests.sh). - -## Generate a documentation for the support keywords - -```$ python3 -m robot.libdoc resources/ApiUtils.resource api_docs/ApiUtils.html``` - -## Generate a documentation for the Test Cases - -```$ python3 -m robot.testdoc TP/NGSI-LD api_docs/TestCases.html``` - -## Tidy the Test Cases -```$ 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) * [JSON Library](https://github.com/robotframework-thailand/robotframework-jsonlibrary) @@ -184,6 +180,15 @@ For more running instructions please consult [scripts/run_tests.sh](./scripts/ru * [HttpCtrl Library](https://github.com/annoviko/robotframework-httpctrl) * [Robotidy Library ](https://github.com/MarketSquare/robotframework-tidy) -# Useful links + +## Useful links * [Robot Framework User Guide](http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#output-file) + + +## LICENSE + +Copyright 2021 ETSI + +The content of this repository and the files contained are released under the [ETSI Software License](LICENSE) a +(BSD-3-Clause LICENSE). diff --git a/requirements.txt b/requirements.txt index ff776daa..f3dbab6b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -# python3.10 project +# python3.11 project robotframework==6.1 robotframework-jsonlibrary==0.5 robotframework-requests==0.9.5 diff --git a/resources/variables.py b/resources/variables.py index f0c933b8..017b8eb2 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -1,4 +1,4 @@ -url = 'localhost:8080/ngsi-ld/v1' +url = 'http://localhost:8080/ngsi-ld/v1' ngsild_test_suite_context = 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld' notification_server_host = '0.0.0.0' notification_server_port = 8085 diff --git a/scripts/configure.sh b/scripts/configure.sh index 314f1880..126521b7 100644 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -1,4 +1,20 @@ #!/bin/bash +# +# Command Line Interface to configure the ETSI NGSI-LD Test Suite (https://forge.etsi.org/rep/cim/ngsi-ld-test-suite) +# For this repository, the commands are merely a convenience script to install the needed services (Python3.11, +# Virtualenv, Pip, and Git. Additionally, the script clones the repository of the tests and create the proper Python +# Virtual Environment for the python project based on the requirements.txt file. +# +# The script will check the OS (MacOS or Ub Ubuntu Linux) and based on it execute the steps to configure the ETSI Test +# Suite. You can start up with the following command: +# +# ./configure.sh +# +# The final steps is the configuration of the ./ngsi-ld-test-suite/resources/variables.py +# (https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/blob/windows11/resources/variables.py) following the README.md +# content (https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/tree/windows11?ref_type=heads), activate the Virtual +# Environment and execute the Robot Tests. + # Function to check if a command is available command_exists() { @@ -6,19 +22,6 @@ command_exists() { } -# Install Chocolatey (Windows) -install_chocolatey() { - echo "Installing Chocolatey..." - powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" - - if command_exists choco; then - echo "Chocolatey was installed successfully." - else - echo "Failed to install Chocolatey." - exit 1 - fi -} - # Install Homebrew (macOS) install_homebrew() { echo " - Installing Homebrew..." @@ -33,29 +36,12 @@ install_homebrew() { } -# Install virtualenv (All OS) -install_virtualenv() { - if command_exists virtualenv; then - echo " - Virtualenv is already installed." - else - echo " - Installing virtualenv..." - python3.11 -m ensurepip --upgrade - python3.11 -m pip install virtualenv - - if command_exists virtualenv; then - echo " - Virtualenv installed successfully." - else - echo " - Failed to install Virtualenv" - fi - fi -} - # Function to prompt for yes/no confirmation confirm() { local prompt="${1:-Are you sure? [Y/n]} " local default_value="${2:-Y}" - read -p "$prompt" response + read -r -p "$prompt" response response=${response:-$default_value} response=$(echo "$response" | tr '[:upper:]' '[:lower:]') @@ -73,11 +59,15 @@ confirm() { configure_virtualenv() { echo "Configuring Python Virtual Environment" echo " - Cloning the ETSI repository in the current folder" - git clone https://forge.etsi.org/rep/cim/ngsi-ld-test-suite.git >/dev/null 2>/dev/null - cd ngsi-ld-test-suite >/dev/null 2>/dev/null + git clone https://forge.etsi.org/rep/cim/ngsi-ld-test-suite.git >/dev/null 2>/dev/null + + cd ngsi-ld-test-suite || { + echo "Failure, unable to change to the ngsi-ld-test-suite directory, maybe the git clone operation failed..."; + exit 1; + } # Temporal need to change the git branch - git checkout windows11 >/dev/null 2>/dev/null + git checkout windows11 >/dev/null 2>/dev/null echo " - Creating Python Virtual Environment" @@ -90,22 +80,22 @@ configure_virtualenv() { # Check the return value if [ $? -eq 1 ]; then echo " Deleting previous .venv folder..." - rm -rf -y .venv >/dev/null 2>/dev/null - virtualenv -ppython3.11 .venv >/dev/null 2>/dev/null + rm -rf -y .venv >/dev/null 2>/dev/null + virtualenv -ppython3.11 .venv >/dev/null 2>/dev/null else echo " You declined. Aborting..." fi else - virtualenv -ppython3.11 .venv >/dev/null 2>/dev/null + virtualenv -ppython3.11 .venv >/dev/null 2>/dev/null fi # Activate the .venv echo " - Activating .venv" - source .venv/bin/activate >/dev/null 2>/dev/null + source .venv/bin/activate >/dev/null 2>/dev/null # Install the requirements echo " - Installing the python requirements from the project" - pip3 install -r requirements.txt >/dev/null 2>/dev/null + pip3 install -r requirements.txt >/dev/null 2>/dev/null } @@ -123,7 +113,7 @@ execute_macos() { # Check if git is already installed if ! command_exists git; then echo " - Installing git..." - brew install git --quiet >/dev/null 2>/dev/null + brew install git --quiet >/dev/null 2>/dev/null # Check that git was successfully installed if command_exists git; then @@ -142,7 +132,7 @@ execute_macos() { else # Install Python 3.11 for macOS, it includes also the installation of pip3 echo " - Installing Python 3.11 (with pip) and Virtualenv for macOS..." - brew install python@3.11 virtualenv --quiet >/dev/null 2>/dev/null + brew install python@3.11 virtualenv --quiet >/dev/null 2>/dev/null # Check if Python 3.11 was installed successfully if command_exists python3.11; then @@ -182,7 +172,7 @@ execute_linux() { # Check if git is already installed if ! command_exists git; then echo " - Installing Git." - sudo apt-get install -y -qq git >/dev/null 2>/dev/null + sudo apt-get install -y -qq git >/dev/null 2>/dev/null # Check that git was successfully installed if command_exists git; then @@ -201,9 +191,9 @@ execute_linux() { else # Install Python 3.11 for Ubuntu echo " - Installing Python 3.11, Pip, and Virtualenv for Ubuntu..." - sudo add-apt-repository -y ppa:deadsnakes/ppa >/dev/null 2>/dev/null - sudo apt-get update -y -qq >/dev/null 2>/dev/null - sudo apt-get install -y -qq python3.11 python3-pip python3-virtualenv >/dev/null 2>/dev/null + sudo add-apt-repository -y ppa:deadsnakes/ppa >/dev/null 2>/dev/null + sudo apt-get update -y -qq >/dev/null 2>/dev/null + sudo apt-get install -y -qq python3.11 python3-pip python3-virtualenv >/dev/null 2>/dev/null # Check if Python 3.11 was installed successfully if command_exists python3.11; then @@ -237,57 +227,7 @@ execute_linux() { configure_virtualenv } -# Configuration script for Windows -execute_window() { - echo "Windows operating system, installing requirements..." - - # Check if Chocolatey is already installed - if ! command_exists choco; then - install_chocolatey - else - echo "Chocolatey is already installed." - fi - - # Check if git is already installed - if ! command_exists git; then - choco install git -y - - # Check that git was successfully installed - if command_exists git; then - echo "Git installed successfully" - else - echo "Failed to install Git." - exit 1 - fi - else - echo "Git is already installed." - fi - - - # Check if Python 3.11 is already installed - if command_exists python3.11; then - echo "Python 3.11 is already installed." - else - # Install Python 3.11 for Windows 11 - echo "Installing Python 3.11 for Windows 11..." - choco install python --pre --version=3.11 - - # Check if Python 3.11 was installed successfully - if command_exists python3.11; then - echo "Python 3.11 was installed successfully." - else - echo "Failed to install Python 3.11." - exit 1 - fi - fi - - # Install Virtualenv - install_virtualenv - - # Create the virtualenv .venv, activate, and install python requirements - configure_virtualenv -} # Determine the operating system os=$(uname -s) @@ -301,10 +241,6 @@ elif [[ $os == "Linux" ]]; then execute_linux echo echo "Ready to use..." -elif [[ $os == "Windows_NT" ]]; then - execute_window - echo - echo "Ready to use..." else echo "Unsupported operating system: $os" exit 1 -- GitLab From e0344c25ed86e1aea32cbbdf24a3dba8e850c614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 20 Jul 2023 09:14:50 +0200 Subject: [PATCH 05/10] Resolve contents links --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0285f492..d67ff936 100644 --- a/README.md +++ b/README.md @@ -13,17 +13,17 @@ environments, perform computations at in-memory speed and at any scale. Details -- [Install the Test Suite](install_the_test_suite) -- [Configure the test suite](Configure the test suite) -- [Execute the NGSI-LD Test Suite](Execute the NGSI-LD Test Suite) -- [Contribute to the Test Suite](Contribute to the Test Suite) - - [Install IDE (PyCharm)](Install IDE (PyCharm)) - - [Install IDE (VSCode)](Install IDE (VSCode)) - - [Run configurations (PyCharm)](Run configurations (PyCharm)) - - [Pre commit](Pre commit) -- [Frameworks and libraries used in the project](Frameworks and libraries used in the project) -- [Useful links](Useful links) -- [LICENSE](LICENSE) +- [Install the Test Suite](#install-the-test-suite) +- [Configure the test suite](#configure-the-test-suite) +- [Execute the NGSI-LD Test Suite](#execute-the-ngsi-ld-test-suite) +- [Contribute to the Test Suite](#contribute-to-the-test-suite) + - [Install IDE (PyCharm)](#install-ide-pycharm) + - [Install IDE (VSCode)](#install-ide-vscode) + - [Run configurations (PyCharm)](#run-configurations-pycharm) + - [Pre commit](#pre-commit) +- [Frameworks and libraries used in the project](#frameworks-and-libraries-used-in-the-project) +- [Useful links](#useful-links) +- [LICENSE](#license) @@ -181,7 +181,7 @@ Further details can be found on the [pre-commit](https://pre-commit.com) site. * [Robotidy Library ](https://github.com/MarketSquare/robotframework-tidy) -## Useful links +## Useful links * [Robot Framework User Guide](http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#output-file) -- GitLab From f99aff599332bfe43904b0bf16869600362971b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 20 Jul 2023 09:43:01 +0200 Subject: [PATCH 06/10] Update the description of the README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d67ff936..ded154f5 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,7 @@ -# Quick start guide - -This tutorial is an introduction to the [FIWARE Cosmos Orion Flink Connector](http://fiware-cosmos-flink.rtfd.io), which -facilitates Big Data analysis of context data, through an integration with [Apache Flink](https://flink.apache.org/), -one of the most popular Big Data platforms. Apache Flink is a framework and distributed processing engine for stateful -computations both over unbounded and bounded data streams. Flink has been designed to run in all common cluster -environments, perform computations at in-memory speed and at any scale. +# NGSI-LD Test Suite +This repository contain the ETSI NGSI-LD Test Suite to test the complaint of the Context Brokers with the +specification of the ETSI NGSI-LD. ## Contents -- GitLab From 43b38c2ac0f9daa054b1f90406fbac3ea037fd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Tue, 25 Jul 2023 16:18:07 +0200 Subject: [PATCH 07/10] Adding windows scripts files --- README.md | 56 ++++++++++++++++------------ scripts/configure.ps1 | 85 +++++++++++++++++++++++++++++++++++++++++++ scripts/run_tests.ps1 | 25 +++++++++++++ 3 files changed, 142 insertions(+), 24 deletions(-) create mode 100644 scripts/configure.ps1 create mode 100644 scripts/run_tests.ps1 diff --git a/README.md b/README.md index ded154f5..650682cd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NGSI-LD Test Suite +# ETSI NGSI-LD Test Suite This repository contain the ETSI NGSI-LD Test Suite to test the complaint of the Context Brokers with the specification of the ETSI NGSI-LD. @@ -14,33 +14,35 @@ specification of the ETSI NGSI-LD. - [Execute the NGSI-LD Test Suite](#execute-the-ngsi-ld-test-suite) - [Contribute to the Test Suite](#contribute-to-the-test-suite) - [Install IDE (PyCharm)](#install-ide-pycharm) - - [Install IDE (VSCode)](#install-ide-vscode) - [Run configurations (PyCharm)](#run-configurations-pycharm) - [Pre commit](#pre-commit) - [Frameworks and libraries used in the project](#frameworks-and-libraries-used-in-the-project) - [Useful links](#useful-links) - [LICENSE](#license) - ## Install the Test Suite -In order to install the NGSI-LD Test Suite, download the configuration script: +In order to install the ETSI NGSI-LD Test Suite, download the configuration script: - For MacOS and Ubuntu, download the following file: -```$ curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure-linux.sh > configure.sh``` +```$ curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure.sh > configure.sh``` -- For Windows, download the following file: +- For Windows, using Powershell download the following file (curl is an alias for Invoke-WebRequest in Powershell): -```$ curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure-windows.sh > configure.sh``` +```$ curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure.ps1 > configure.ps1``` -- Be sure that you have the proper execution permission of the file and execute it: +- For MacOS and Ubuntu, Be sure that you have the proper execution permission of the file and execute it: ```$ configure.sh``` +- In Windows 11, using Powershell, make sure you can run the script + +```> powershell -executionpolicy bypass configure.ps1``` + This script will install the corresponding requirements to execute the Test Suite: - Python3.11 @@ -69,7 +71,6 @@ 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. 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 some mockup services to provide teh required functionality. @@ -83,13 +84,17 @@ execution of the following command in MacOS or Ubuntu: In case of Windows, you need to execute the following command: -```$ .... ``` +```> .\.venv\scripts\activate.bat ``` + +Now, we can launch the tests with the following command in MacOS or Linux: -Now, we can launch the tests with the following command: +```$ robot --outputdir ./results .``` -```$ robot --outputdir ./results .``` +For Windows system, you can lauch the tests with the following command: -For more running instructions please consult [scripts/run_tests.sh](./scripts/run_tests.sh). +```> robot --outputdir .\results .\TP\NGSI-LD``` + +For more running instructions, please consult [scripts/run_tests.sh](./scripts/run_tests.sh) or [scripts/run_tests.ps1](./scripts/run_tests.ps1) If we want to generate a documentation for the support keywords: @@ -103,16 +108,27 @@ And if we want to tidy the Test Cases: ```$ python3 -m robot.tidy --recursive TP/NGSI-LD``` -Note: if we want to deactivate the Python Virtual Environment just execute the command `deactivate`. +Note: if we want to deactivate the Python Virtual Environment just execute the command `deactivate` in MacOS and Ubuntu +systems and `.venv\scripts\deactivate.bat` in Windows system. +> :information_source: **Note:** if we want to deactivate the Python Virtual Environment just execute the command in +> MacOS and Ubuntu systems: +> +> ```console +> $ deactivate +> ``` +> And in Window system: +> +> ```console +> > .venv\scripts\deactivate.bat +> ``` ## Contribute to the Test Suite -In order to contribute to the NGSI-LD Test Suite, we recommend the installation of an IDE with the corresponding +In order to contribute to the ETSI NGSI-LD Test Suite, we recommend the installation of an IDE with the corresponding Robot Framework. Our recommendations are: - PyCharm -- VisualStudio Code ### Install IDE (PyCharm) @@ -125,14 +141,6 @@ Robot Framework. Our recommendations are: insert the following: `{"EXECDIR": "{path}/auth-test-suite"}` -### Install IDE (VSCode) - -- Install [Visual Studio Code](https://code.visualstudio.com/docs/setup/linux) - -- Install -[Robot Framework Intellisense](https://marketplace.visualstudio.com/items?itemName=TomiTurtiainen.rf-intellisense) - - ### Run configurations (PyCharm) Two sample configurations have been created: diff --git a/scripts/configure.ps1 b/scripts/configure.ps1 new file mode 100644 index 00000000..8464f031 --- /dev/null +++ b/scripts/configure.ps1 @@ -0,0 +1,85 @@ +$choco_version = &{choco --version} 2>&1 +if ($choco_version -is [System.Management.Automation.ErrorRecord]) +{ + powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" + + $env:Path += ";$env:PROGRAMDATA\Chocolatey\bin" +} else { + echo "Chocolatey already installed" +} + +$git_version = &{git --version} 2>&1 +if ($git_version -is [System.Management.Automation.ErrorRecord]) +{ + choco install git -y + $env:Path += ";C:\Program Files\Git\cmd" +} else { + echo "git already installed" +} + +# - Install python if it doesn't exists - +# Define the version of Python to install +$pythonVersion = "3.11.4" + +$python_installed_version = &{python --version} 2>&1 +if ($python_installed_version -is [System.Management.Automation.ErrorRecord]) +{ + + # Define the download URL for the Python installer + $pythonInstallerUrl = "https://www.python.org/ftp/python/$pythonVersion/python-$pythonVersion-amd64.exe" + + # Define the path to download the Python installer + $installerPath = "$env:TEMP\python-$pythonVersion.exe" + + # Download the Python installer + Invoke-WebRequest -Uri $pythonInstallerUrl -OutFile $installerPath + + # Install Python silently with the necessary settings to add it to the PATH + echo "... installing python. This takes some time." + Start-Process -FilePath $installerPath -ArgumentList "/quiet", "InstallAllUsers=1", "PrependPath=1" -Wait + + # Remove the installer + Remove-Item $installerPath + #$env:Path += "C:\Python311\Scripts\;C:\Python311\" + $env:Path = "C:\Program Files\Python311\Scripts;C:\Program Files\Python311;$env:Path" +} else { + echo "python is already installed" +} + + +$python_installed_version = &{python --version} 2>&1 +if ($python_installed_version -is [System.Management.Automation.ErrorRecord]) { + sleep 60 + $python_installed_version = &{python --version} 2>&1 + if ($python_installed_version -is [System.Management.Automation.ErrorRecord]) { + echo "Restart powershell and run this script again. Python not detected" + exit 1 + } +} + +# Install virtualenv - +python -m pip install virtualenv + +$cloned = &{Test-path .\ngsi-ld-test-suite} + +echo "=======================" +echo $cloned +echo "=======================" + +if ( $cloned -eq $false ) { + echo "------------- doing git clone" + # Clone the repo - somehow. + git clone https://forge.etsi.org/rep/cim/ngsi-ld-test-suite.git -b windows11 >$null 2>&1 + cd ngsi-ld-test-suite >$null 2>&1 +} else { + cd ngsi-ld-test-suite + git pull + Remove-Item -force -recurse .\.venv +} + +# Create the virtualenv +virtualenv -ppython3 .venv >$null 2>&1 + +.\.venv\Scripts\activate.bat +pip install -r requirements.txt + diff --git a/scripts/run_tests.ps1 b/scripts/run_tests.ps1 new file mode 100644 index 00000000..662e5039 --- /dev/null +++ b/scripts/run_tests.ps1 @@ -0,0 +1,25 @@ +# run all tests +robot --outputdir .\results .\TP\NGSI-LD + +# run all tests with base url overriden +robot --variable url:"URL_HERE" --outputdir .\results . + +# run by specific tag(s) +robot --include mandatory --outputdir .\results . + +# run all the tests for context information +robot --outputdir .\results .\TP\NGSI-LD\ContextInformation + +# run a specific test case +robot --outputdir .\results .\TP\NGSI-LD\ContextInformation\Provision\Entities\CreateEntity\001_01.robot +robot --outputdir .\results --suite 001_01 . + +# run specific test case +robot --outputdir .\results -t "SuccessCases_MinimalEntity" +robot --outputdir .\results -t "SuccessCases_MinimalEntity" .\TP\NGSI-LD\ContextInformation\Provision\Entities\CreateEntity\SuccessCases.robot + +# rerun failed tests +robot --rerunfailedsuites .\results\output.xml --outputdir .\results . + +# stop the suite after a failed test +robot --exitonfailure --outputdir .\results . -- GitLab From 7bf13ce195e3c36a82957e4dfa00a93ec7e84484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Fri, 25 Aug 2023 14:33:15 +0200 Subject: [PATCH 08/10] Update README information --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 650682cd..37abe162 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ In order to install the ETSI NGSI-LD Test Suite, download the configuration scri - For Windows, using Powershell download the following file (curl is an alias for Invoke-WebRequest in Powershell): -```$ curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure.ps1 > configure.ps1``` +```> curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure.ps1 > configure.ps1``` - For MacOS and Ubuntu, Be sure that you have the proper execution permission of the file and execute it: @@ -96,6 +96,19 @@ For Windows system, you can lauch the tests with the following command: For more running instructions, please consult [scripts/run_tests.sh](./scripts/run_tests.sh) or [scripts/run_tests.ps1](./scripts/run_tests.ps1) +To have the whole messages, it is necessary to modify the width of the test execution output with the option +--consolewidth (-W). The default width is 78 characters. + +```$ robot --consolewidth 150 .``` + +The messages in the console are clear and without noise, only the strictly necessary (request and response to the +Context Brokers and a nice message which shows the difference between two documents when they are). However, it can be +difficult to follow all the messages in the console when there is a lot of testing and a lot of Context Broker calls. +This is why a command to redirect the console output to a file can be used. You must add a chevron at the end of the +test launch command followed by the file name. + +```$ robot . > 'results.log``` + If we want to generate a documentation for the support keywords: ```$ python3 -m robot.libdoc resources/ApiUtils.resource api_docs/ApiUtils.html``` @@ -108,9 +121,7 @@ And if we want to tidy the Test Cases: ```$ python3 -m robot.tidy --recursive TP/NGSI-LD``` -Note: if we want to deactivate the Python Virtual Environment just execute the command `deactivate` in MacOS and Ubuntu -systems and `.venv\scripts\deactivate.bat` in Windows system. -> :information_source: **Note:** if we want to deactivate the Python Virtual Environment just execute the command in +> **Note:** if we want to deactivate the Python Virtual Environment just execute the command in > MacOS and Ubuntu systems: > > ```console -- GitLab From 1bdeb27a9c2d5e1d81860c1bdeb1fb6bba4feee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Mon, 28 Aug 2023 15:38:26 +0200 Subject: [PATCH 09/10] Resolution PR comments --- README.md | 35 +++++++++++++++++------------------ requirements.txt | 4 ++-- scripts/configure.ps1 | 2 +- scripts/configure.sh | 3 --- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 37abe162..b6f54bcb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ETSI NGSI-LD Test Suite -This repository contain the ETSI NGSI-LD Test Suite to test the complaint of the Context Brokers with the -specification of the ETSI NGSI-LD. +This repository contains the ETSI NGSI-LD Test Suite to test the compliance of the Context Brokers with the +specification of the ETSI NGSI-LD API. ## Contents @@ -43,14 +43,13 @@ In order to install the ETSI NGSI-LD Test Suite, download the configuration scri ```> powershell -executionpolicy bypass configure.ps1``` -This script will install the corresponding requirements to execute the Test Suite: - -- Python3.11 -- Git -- Virtualenv -- Pip - -Clone the NGSI-LD Test Suite repository in the local folder and create the corresponding Python Virtual Environment +These scripts develop a set of operations, the same in the different Operating System, which consist of: +- Installation of the corresponding software requirements: + - Python3.11 + - Git + - Virtualenv + - Pip +- Cloning the NGSI-LD Test Suite repository in the local folder and create the corresponding Python Virtual Environment taking into account the content of `requirements.txt` file. Further details on each library can be found in [PyPi](https://pypi.org/) and [Robot Framework Standard Libraries](http://robotframework.org/robotframework/#standard-libraries). @@ -72,7 +71,7 @@ and `notification_server_port`). Default value: `0.0.0.0` and `8085`. 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 -some mockup services to provide teh required functionality. +some mockup services to provide the required functionality. ## Execute the NGSI-LD Test Suite @@ -86,7 +85,7 @@ In case of Windows, you need to execute the following command: ```> .\.venv\scripts\activate.bat ``` -Now, we can launch the tests with the following command in MacOS or Linux: +Now, you can launch the tests with the following command in MacOS or Linux: ```$ robot --outputdir ./results .``` @@ -107,21 +106,21 @@ difficult to follow all the messages in the console when there is a lot of testi This is why a command to redirect the console output to a file can be used. You must add a chevron at the end of the test launch command followed by the file name. -```$ robot . > 'results.log``` +```$ robot . > results.log``` -If we want to generate a documentation for the support keywords: +If you want to generate a documentation for the support keywords: ```$ python3 -m robot.libdoc resources/ApiUtils.resource api_docs/ApiUtils.html``` -If we want to generate a documentation for the Test Cases: +If you want to generate a documentation for the Test Cases: ```$ python3 -m robot.testdoc TP/NGSI-LD api_docs/TestCases.html``` -And if we want to tidy the Test Cases: +And if you want to tidy the Test Cases: ```$ python3 -m robot.tidy --recursive TP/NGSI-LD``` -> **Note:** if we 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: > > ```console @@ -136,7 +135,7 @@ And if we want to tidy the Test Cases: ## Contribute to the Test Suite -In order to contribute to the ETSI NGSI-LD Test Suite, we recommend the installation of an IDE with the corresponding +In order to contribute to the ETSI NGSI-LD Test Suite, you recommend the installation of an IDE with the corresponding Robot Framework. Our recommendations are: - PyCharm diff --git a/requirements.txt b/requirements.txt index c38834a0..971526e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ # python3.11 project -robotframework==6.1 +robotframework==6.1.1 robotframework-jsonlibrary==0.5 robotframework-requests==0.9.5 deepdiff==6.3.1 prettydiff==0.1.0 robotframework-httpctrl==0.3.1 -robotframework-tidy==4.4.0 +robotframework-tidy==4.5.0 diff --git a/scripts/configure.ps1 b/scripts/configure.ps1 index 8464f031..83128c90 100644 --- a/scripts/configure.ps1 +++ b/scripts/configure.ps1 @@ -69,7 +69,7 @@ echo "=======================" if ( $cloned -eq $false ) { echo "------------- doing git clone" # Clone the repo - somehow. - git clone https://forge.etsi.org/rep/cim/ngsi-ld-test-suite.git -b windows11 >$null 2>&1 + git clone https://forge.etsi.org/rep/cim/ngsi-ld-test-suite.git >$null 2>&1 cd ngsi-ld-test-suite >$null 2>&1 } else { cd ngsi-ld-test-suite diff --git a/scripts/configure.sh b/scripts/configure.sh index 126521b7..00649518 100644 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -66,9 +66,6 @@ configure_virtualenv() { exit 1; } - # Temporal need to change the git branch - git checkout windows11 >/dev/null 2>/dev/null - echo " - Creating Python Virtual Environment" if [ -d "./.venv" ]; then -- GitLab From 85835f4e02ee59d54bc3664a8cf576a9d50febcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Fri, 8 Sep 2023 12:17:34 +0200 Subject: [PATCH 10/10] Update README content to answer review comments --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b6f54bcb..dd954b72 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,12 @@ In order to install the ETSI NGSI-LD Test Suite, download the configuration scri ```> curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure.ps1 > configure.ps1``` -- For MacOS and Ubuntu, Be sure that you have the proper execution permission of the file and execute it: +- For MacOS and Ubuntu, be sure that you have the proper execution permissions of the file and the user is included +in the sudoers group, then execute the following script: ```$ configure.sh``` -- In Windows 11, using Powershell, make sure you can run the script +- In Windows 11, using Powershell, make sure you can run the script: ```> powershell -executionpolicy bypass configure.ps1``` -- GitLab