diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..5dcd4e5b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# IDE Settings +/.vscode + +# lisa runtime folder +/runtime/* + +# python cache +__pycache__ diff --git a/README.md b/README.md new file mode 100644 index 000000000..16d03f558 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Linux Integration Services Automation (LISA), 3.0 + +## Overview + +LISA v3 is a fresh new toolkit, and at very early stage. All v2 things are moved to core/runners/v2runner. diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 000000000..b11a3e9e9 --- /dev/null +++ b/docs/development.md @@ -0,0 +1,31 @@ +# Setup development environment + +## Python + +### Python version + +LISAv3 supports `Python 64bit 3.8.3`, and prefer to use latest stable version. + +### Development packages + +LISAv3 use `flake, isor, black, mypy` packages to enforce basic code guideline. Below command is an example to install them. + +```bash +python -m pip install flake8 isort black mypy --upgrade +``` + +## IDE settings + +### Visual Studio Code + +Make sure below settings are in root level of `.vscode/settings.json` + +```json +{ + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.enabled": true, + "python.formatting.provider": "black", + "python.linting.mypyEnabled": true +} +``` diff --git a/examples/configs/example.yaml b/examples/configs/example.yaml new file mode 100644 index 000000000..1545e02c6 --- /dev/null +++ b/examples/configs/example.yaml @@ -0,0 +1,57 @@ +name: best-guest # run name prefix +parent: parentconfig.yaml # share configurations for similar runs. +logLevel: debug # specify log level, can be overwritten in lower level. +# it uses to dispatch test suites on serveral environments. +# to be implement in next phase. +combinations: + parameters: + - platform: + - azure + - hyperv + - AzurePlatform: # Azure platform specified parameters + dataCenter: + - wu + - wu2 +# supports multiple artifacts in future. +artifacts: + - name: sample # optional. artifacts can be referred by name or index. + type: repo + git: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git + ref: v5.8-rc6 + baseDistro: ubuntu-1804 # there is a default value, but can be specified here. +platform: + - name: azure-1 # name is for reference only + type: azure + tag: vf # use tag to find some platform specified features. + secret: filepath.yaml + topology: crossRegion + totalInstances: 2 # two suites of environments can be created in same time. + - type: hyperv +environment: # ready environment are list directly, no need platform. + - type: existing + proxy: 240.x.x.x + tag: dpdk # meet requirement of dpdk test cases. + username: lisa # the same on all nodes. + nodes: + - ip: 10.0.0.1 + port: 22 + publicPort: 1111 + password: $PASSWORD # reference to environment variable + isPrimary: true + - name: secondary + ip: 10.0.0.2 + port: 22 + publicPort: 1111 + password: $PASSWORD2 +testSuites: + - name: set1 + type: lisav2 # know the runner, then it's possible to select cases. + tag: azure + - tag: vf # match case by tags + force: true # force to select. If any reason test cases are dropped, fail the run. + - name: unstable cases + pattern: "*-network*" # match case by name pattern + retry: 2 # retry one time + - name: set2 + include: false # use to exclude some test cases + pattern: "*-legacy" diff --git a/lisa.cmd b/lisa.cmd new file mode 100644 index 000000000..3a3b440e8 --- /dev/null +++ b/lisa.cmd @@ -0,0 +1,64 @@ +ECHO OFF + +SETLOCAL EnableDelayedExpansion + +SET PYTHON_VERSION=3.8.3 +SET RUNTIME_PATH=%CD%\runtime +SET RUNTIME_PYTHON_PATH=%RUNTIME_PATH%\bin\windows\python +SET RUNTIME_PYTHON_COMMAND=%RUNTIME_PYTHON_PATH%\python.exe +SET PATH=%RUNTIME_PYTHON_PATH%;%RUNTIME_PYTHON_PATH%\Scripts;%PATH% + +IF EXIST "!RUNTIME_PYTHON_COMMAND!" ( + FOR /F "tokens=2 USEBACKQ" %%F IN (`!RUNTIME_PYTHON_COMMAND! -V`) DO ( + SET ORIGINAL_PYTHON_VERSION=%%F + if !PYTHON_VERSION! NEQ %%F ( + ECHO SHELL: python version: expected: !PYTHON_VERSION!, current: %%F, removing it. + rmdir /s /q !RUNTIME_PYTHON_PATH! + IF %ERRORLEVEL% NEQ 0 ( + ECHO SHELL: "error on remove previous version python." + ENDLOCAL + exit %ERRORLEVEL% + ) + ) + ) +) + +IF NOT EXIST "!RUNTIME_PYTHON_COMMAND!" ( + ECHO SHELL: !RUNTIME_PYTHON_COMMAND! doesn't exists. + + SETLOCAL EnableDelayedExpansion + SET PYTHON_URL=https://www.python.org/ftp/python/%PYTHON_VERSION%/python-%PYTHON_VERSION%-embed-amd64.zip + SET PIP_URL=https://bootstrap.pypa.io/get-pip.py + SET RUNTIME_TEMP_PATH=%RUNTIME_PATH%\temp + SET PYTHON_ZIP_NAME=!RUNTIME_TEMP_PATH!\python_windows_%PYTHON_VERSION%.zip + mkdir !RUNTIME_TEMP_PATH! 2> nul + + ECHO SHELL: downloading from !PYTHON_URL! + powershell /c "Import-module BitsTransfer; Start-BitsTransfer -Source $Env:PYTHON_URL -Destination $Env:PYTHON_ZIP_NAME" + + ECHO SHELL: extracting !PYTHON_ZIP_NAME! to !RUNTIME_PYTHON_PATH! + powershell /c "Expand-Archive $Env:PYTHON_ZIP_NAME -DestinationPath $Env:RUNTIME_PYTHON_PATH" + del !PYTHON_ZIP_NAME! + + ECHO SHELL: downloading and install pip to !RUNTIME_PYTHON_PATH! + powershell /c "Import-module BitsTransfer; Start-BitsTransfer -Source $Env:PIP_URL -Destination $Env:RUNTIME_PYTHON_PATH\get-pip.py" + + !RUNTIME_PYTHON_PATH!\python !RUNTIME_PYTHON_PATH!\get-pip.py + + REM fix pip cannot be find, and add lisa to package list + FOR %%G IN (!RUNTIME_PYTHON_PATH!\*._pth) DO ( + echo lib>> %%G + echo lib\site-packages>> %%G + echo scripts>> %%G + echo %CD%>> %%G + ) +) + +REM updating Python packages +%RUNTIME_PYTHON_PATH%\python -m pip install -q -r requirements.txt + +pushd lisa +%RUNTIME_PYTHON_PATH%\python -m lisa.main %* +popd + +ENDLOCAL diff --git a/lisa.sh b/lisa.sh new file mode 100644 index 000000000..9d9984693 --- /dev/null +++ b/lisa.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +# start entry of Linux platform, not implemented yet. diff --git a/lisa/__init__.py b/lisa/__init__.py new file mode 100644 index 000000000..756034cbd --- /dev/null +++ b/lisa/__init__.py @@ -0,0 +1,10 @@ +from datetime import datetime +import random +import os + +result_path = "../runtime/results/{}-{}".format( + datetime.now().strftime("%Y%m%d-%H%M%S"), random.randint(0, 1000) +) + +os.makedirs(result_path) +os.environ["RESULT_PATH"] = result_path diff --git a/lisa/common/__init__.py b/lisa/common/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/lisa/common/logger.py b/lisa/common/logger.py new file mode 100644 index 000000000..212927c50 --- /dev/null +++ b/lisa/common/logger.py @@ -0,0 +1,14 @@ +import logging + +import os + +logging.basicConfig( + level=logging.INFO, + format="%(asctime)s [%(levelname)s] %(message)s", + handlers=[ + logging.FileHandler("%s/lisa.log" % os.environ["RESULT_PATH"]), + logging.StreamHandler(), + ], +) + +log = logging.getLogger("LISA") diff --git a/lisa/main.py b/lisa/main.py new file mode 100644 index 000000000..0811de451 --- /dev/null +++ b/lisa/main.py @@ -0,0 +1,16 @@ +import sys + +from lisa.common.logger import log + + +def main(): + log.info("Python version: %s" % sys.version) + log.info("args: %s" % sys.argv) + + +if __name__ == "__main__": + try: + main() + except Exception as exception: + log.exception(exception) + raise diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..23ecb5399 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +attrs==19.3.0 +certifi==2020.6.20 +pathspec==0.8.0 +regex==2020.7.14 +wincertstore==0.2