Synology CI System

Ouline

  • Introduction

  • Architecture

  • Setup & Run

  • Test Case

  • Q & A

Introduction

目標

  • 與 build system 串接
    • 每版跑 test
    • 每版跑 performance test
  • 提供統一介面運行各種 test
    • regression test
    • performance test
    • unit test
    • ...
  • 任何 RD/QC 都可輕易利用這套 framework 跑 test

參與人員

  • RD
    • regression test
    • unit test
  • QC
    • 將現有制式化的 check list 改寫成 test case

Schedule

Phase1 (Now)

  • 完成基礎的 CI framework
    • 快速布置 test 環境
    • 簡易的透過 command line 運行 test
    • 大量的 python wrapper webapi & utils 幫助部屬及測試 DSM
  • Output log
  • Regression test cases Examples

Schedule

 

Phase2

  • Support Unit Test
  • Test Case grouping
  • 連接 Build System 做 CI
    • CI 執行時間
      • DS: 新版本 DSM version build 出來後
    • CI 執行 branch
      • 目前只會 run 在 master 上
    • 執行結果可利用網站瀏覽並寄信告知 owner failed
  • 撰寫 CI framework 本身的 test case

Schedule

Phase3

  • 定義規範
    • 誰或是何時該寫 test、每天要跑哪些 test ...
  • 支援 Package CI (每 build 出一版 package 就跑)
  • 支援其他 branch CI (eg. SRM、NVR、5.2 branch ...)
  • CI 網頁
  • 許願池 ...

Architecture

Projects

 

synotestscripts

  • All Test Cases

  • synoci framework

    • Tow binaries

      • bin/synoci (BuildAll)

      • bin/mkpyenv (BaseAll)

Projects

 

python-synowebapi

  • provide python wrapper webapi

python-synodeploy (misc)

  • all python wrapper utils
    • eg. install DS, install package, execute remote command, create volume/share …

python-synopyro

  • DS、Win、Mac pyro related code
  • Use 4 space instead of tab
  • Class use camelcase others use underscores
    • eg.
      • class TestClass
      • def test_func()
      • test_num = 100
  • Library have to write usage comment
class DSMPatPath():
    """
    Get DSM pat path
    
    >>> with DSMPatPath("10.13.22.213") as pat:
    ...     print pat[7166]
    synostorage/DSM6.0/7166-dev-6.0.0/synology_alpine_ds2015xs/DSM_DS2015xs_7166.pat
    """

Setup & Run

Virtual Env

 

  • virtualenv is a tool to create isolated Python environments (like chroot)

  • All python library would install in ven

  • Setup

Synoci FHS

 

  • Test Suite
    • Sub Test Suite
      • Test Case
        • Test Case Item
synotestscripts/
├── bin
│   ├── mkpyenv
│   └── synoci
├── README.md
├── requirements.txt
├── suites
│   ├── __init__.py
│   ├── mailplus_server #Test suite
│   │   ├── bootstrap.py
│   │   ├── config.py
│   │   ├── ds_config.py
│   │   ├── __init__.py
│   │   └── test_webapi #Sub test suite
│   │       ├── smtp_webapi.py #Test case
│   │       └── __init__.py
│   │   └── test_cluster #Sub test suite
│   │       ├── setup.py #Test case
│   │       └── __init__.py
├── test
│   ├── main.py
│   ├── test_runner.py
│   └── test_synoci.py
└── utils
    ├── code_generator.py
    ├── code_update.py
    ├── __init__.py
    ├── loader.py
    ├── macro.py
    └── runner.py

mkpyenv

  • Create venv (similar chroot environment)

    • path "synotestscripts/.CIENVS/venv"
  • Install necessary python library base on "requirements.txt"

    • pip install -r requirements.txt
  • Into venv

  • Clone & Install python-syno* projects

  • Create template DS config

Create & Run Test Case Demo

Limitation

  • All operation have to run in venv
  • All operation have to in dir "synotestscripts"
    • eg.
      • cd synotestscripts
      • ./bin/synoci -h

Test Case

  • The python unit test framework
  • Useful built-in functions
    • Provide setup/teardown functions
    • Use self.assert* to check result
  • Only test function which name start with "test"

Pyro: Python Remove Object

A Python Remote Object Server

mac_os = PyroObject('192.168.55.66', 'os')
mac_os.uname()
('Darwin', 'flys-iMac.local' ...
mac_os.system('mount_afp ds.local/share /Volums/share')
mac_os.system('cp -rf ~/5G /Volumes/share')

What Can We Do Now?

  • Quickly deploy synoci environment
  • Lots library to setup DSM
    • baseInstall DSM to any version
    • Install Package
    • Create/Delete Volume,share
    • Remote command through SSH/Telnet
  • Pyro server to control Win/Mac/DSM
  • Easy way to test Webapi/CGI

Pyro Demo: AFP Performance

Synology CI System

By nit nit

Synology CI System

  • 46