diff --git a/.gitignore b/.gitignore index 5393a5e16b5a93b6473c7c4550985ae474396223..b2e080cf73ee1e21d06317aaf88a08d336758e91 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/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..e4a76bdbca2a0aa71d728214aa9e3200e7994d2b --- /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 a8c5dc5d75d1f884a55981f7821ac23b1dd1979e..dd954b729c2d48a270a8b33b61d5c57386949b32 100644 --- a/README.md +++ b/README.md @@ -1,138 +1,192 @@ -# Quick start guide +# ETSI NGSI-LD Test Suite -## Install Python & PIP +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. -* Install Python3 by running the following command: +## Contents -```$ sudo dnf install python3``` (Ubuntu) +
-```$ brew install python3``` (MacOS) +Details -* Confirm its installation with: +- [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) + - [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) -```$ python3 --version``` (Ubuntu) +
-```$ python3 --version``` (MacOS) -* At this point, you can launch Python3 interpreter: +## Install the Test Suite -```$ python3``` (Ubuntu) +In order to install the ETSI NGSI-LD Test Suite, download the configuration script: -```$ python3``` (MacOS) +- For MacOS and Ubuntu, download the following file: -* Pip should be included by default. To confirm, run: +```$ curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure.sh > configure.sh``` -```$ command -v pip``` (Ubuntu) +- For Windows, using Powershell download the following file (curl is an alias for Invoke-WebRequest in Powershell): -```$ pip3 --version``` (MacOS) +```> curl https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/windows11/scripts/configure.ps1 > configure.ps1``` -* In case pip is not installed, [follow the official pip installation guide](https://pip.pypa.io/en/latest/installing/). +- 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: -## Install IDE (PyCharm) +```$ configure.sh``` -* Install [PyCharm](https://www.jetbrains.com/fr-fr/pycharm/download) +- In Windows 11, using Powershell, make sure you can run the script: -* Install [Robot Framework Language Server](https://plugins.jetbrains.com/plugin/16086-robot-framework-language-server) +```> powershell -executionpolicy bypass configure.ps1``` -* Define as variable the path of the working directory: in Settings > Languages & Frameworks > Robot Framework (Project), -insert the following: `{"EXECDIR": "{path}/auth-test-suite"}` +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). -## Install IDE (VSCode) -* Install [Visual Studio Code](https://code.visualstudio.com/docs/setup/linux) +## Configure the test suite -* Install [Robot Framework Intellisense](https://marketplace.visualstudio.com/items?itemName=TomiTurtiainen.rf-intellisense) +In the `resources/variables.py` file, configure the following parameters: -## Checkout the base project +- `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`. -```$ git clone git@forge.etsi.org:cim/ngsi-ld-test-suite.git``` +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. -## Configure the environment -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. +## Execute the NGSI-LD Test Suite -## Install the project requirements +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: -Browse the base project root folder and execute the following command: +```$ source .venv/bin/activate``` -```$ python3 -m pip install -r requirements.txt``` (Ubuntu) +In case of Windows, you need to execute the following command: -```$ python3 -m pip install -r requirements.txt``` (MacOS) +```> .\.venv\scripts\activate.bat ``` -Further details on each library can be found in [PyPi](https://pypi.org/) and [Robot Framework Standard Libraries](http://robotframework.org/robotframework/#standard-libraries) +Now, you can launch the tests with the following command in MacOS or Linux: -## Run configurations (PyCharm) +```$ robot --outputdir ./results .``` -Two sample configurations have been created: +For Windows system, you can lauch the tests with the following command: -- one to check if there are syntax or format changes to be done according to Robotidy (`Check Format`) -- one to make the syntax and format changes according to Robotidy (`Format Files`) +```> robot --outputdir .\results .\TP\NGSI-LD``` -To launch a run configuration, choose one of the two configurations from the Run menu and click on it to run it. +For more running instructions, please consult [scripts/run_tests.sh](./scripts/run_tests.sh) or [scripts/run_tests.ps1](./scripts/run_tests.ps1) -## Pre commit +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. -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. +```$ robot --consolewidth 150 .``` -To use it, install `pre-commit` with the following commands (using pip): +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. -```$ pip install pre-commit``` +```$ robot . > results.log``` -Then install the Git hook scripts: +If you want to generate a documentation for the support keywords: -```$ pre-commit install``` +```$ python3 -m robot.libdoc resources/ApiUtils.resource api_docs/ApiUtils.html``` -Now, it will run automatically on every commit. +If you want to generate a documentation for the Test Cases: -To manually launch the tool, the following command can be used: +```$ python3 -m robot.testdoc TP/NGSI-LD api_docs/TestCases.html``` -```$ ./venv/bin/python -m robotidy .``` +And if you want to tidy the Test Cases: -Further details can be found on the [pre-commit](https://pre-commit.com) site. +```$ python3 -m robot.tidy --recursive TP/NGSI-LD``` -## Execute the tests +> **Note:** if you 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 +> ``` -Configure the context broker URL in the resources/variables.py file -Launch the tests with the following command: +## Contribute to the Test Suite -```$ robot --outputdir ./results .``` +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: -For more running instructions please consult [scripts/run_tests.sh](./scripts/run_tests.sh). +- PyCharm -## Redirect console output to have -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. +### Install IDE (PyCharm) -```$ robot --consolewidth 150 .``` +- 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) -The messages in the console are clear and without noise, only the strictly necessary (request and response to the CB 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 CB 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. +- Define as variable the path of the working directory. In Settings > Languages & Frameworks > Robot Framework (Project), +insert the following: `{"EXECDIR": "{path}/auth-test-suite"}` -```$ robot . > 'results.log``` -## Generate a documentation for the support keywords +### Run configurations (PyCharm) -```$ python3 -m robot.libdoc resources/ApiUtils.resource api_docs/ApiUtils.html``` +Two sample configurations have been created: -## Generate a documentation for the Test Cases +- one to check if there are syntax or format changes to be done according to Robotidy (`Check Format`) +- one to make the syntax and format changes according to Robotidy (`Format Files`) -```$ python3 -m robot.testdoc TP/NGSI-LD api_docs/TestCases.html``` +To launch a run configuration, choose one of the two configurations from the Run menu and click on it to run it. -## Tidy the Test Cases -```$ python3 -m robot.tidy --recursive TP/NGSI-LD``` +### 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): + +```$ pip install pre-commit``` + +Then install the Git hook scripts: + +```$ pre-commit install``` + +Now, it will run automatically on every commit. + +To manually launch the tool, the following command can be used: + +```$ python -m robotidy .``` + +Further details can be found on the [pre-commit](https://pre-commit.com) site. -# 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) @@ -141,6 +195,15 @@ You must add a chevron at the end of the test launch command followed by the fil * [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 03455a4fc79385c4aab805fa7fc76eb4a7f680b5..971526e5e29034dfb28bf0cda779a0655c410234 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -# python3.10 project -robotframework==6.0.2 +# python3.11 project +robotframework==6.1.1 robotframework-jsonlibrary==0.5 -robotframework-requests==0.9.4 -deepdiff==6.3.0 +robotframework-requests==0.9.5 +deepdiff==6.3.1 prettydiff==0.1.0 robotframework-httpctrl==0.3.1 -robotframework-tidy==4.2.1 +robotframework-tidy==4.5.0 diff --git a/resources/variables.py b/resources/variables.py index f0c933b8e5528cd7b0fea055c0ed0fd1ac722f4c..017b8eb21fe49fa9ce203594c16cbfbf5b850042 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.ps1 b/scripts/configure.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..83128c9029294c3c6fc6e5f27630a7fea7f1f7b4 --- /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 >$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/configure.sh b/scripts/configure.sh new file mode 100644 index 0000000000000000000000000000000000000000..0064951876a3fe8ffd9147cf47fd1cf5a553d563 --- /dev/null +++ b/scripts/configure.sh @@ -0,0 +1,246 @@ +#!/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() { + command -v "$1" >/dev/null 2>&1 +} + + +# 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 +} + + +# Function to prompt for yes/no confirmation +confirm() { + local prompt="${1:-Are you sure? [Y/n]} " + local default_value="${2:-Y}" + + read -r -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 || { + echo "Failure, unable to change to the ngsi-ld-test-suite directory, maybe the git clone operation failed..."; + exit 1; + } + + 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" + pip3 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 + 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" + 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, 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." + 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 Virtualenv." + exit 1 + fi + fi + + echo + + # 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 +} + + + +# 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..." +else + echo "Unsupported operating system: $os" + exit 1 +fi + +exit 1 diff --git a/scripts/run_tests.ps1 b/scripts/run_tests.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..662e503987f4ce2a7160e98110c2ac7debde5e68 --- /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 .