1. Add windows command shell to init python environment.
2. add init python entry code and log.
3. document dev env settings to development.md
This commit is contained in:
Chi Song 2020-07-28 17:51:43 +08:00
Родитель 539baf394b
Коммит a9b0a777fb
11 изменённых файлов: 213 добавлений и 0 удалений

8
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,8 @@
# IDE Settings
/.vscode
# lisa runtime folder
/runtime/*
# python cache
__pycache__

5
README.md Normal file
Просмотреть файл

@ -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.

31
docs/development.md Normal file
Просмотреть файл

@ -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
}
```

Просмотреть файл

@ -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"

64
lisa.cmd Normal file
Просмотреть файл

@ -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

3
lisa.sh Normal file
Просмотреть файл

@ -0,0 +1,3 @@
#!/bin/bash
# start entry of Linux platform, not implemented yet.

10
lisa/__init__.py Normal file
Просмотреть файл

@ -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

0
lisa/common/__init__.py Normal file
Просмотреть файл

14
lisa/common/logger.py Normal file
Просмотреть файл

@ -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")

16
lisa/main.py Normal file
Просмотреть файл

@ -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

5
requirements.txt Normal file
Просмотреть файл

@ -0,0 +1,5 @@
attrs==19.3.0
certifi==2020.6.20
pathspec==0.8.0
regex==2020.7.14
wincertstore==0.2