Skip to content

Commit

Permalink
[automation_test] add automation test action
Browse files Browse the repository at this point in the history
  • Loading branch information
jiumos authored and LYootsz committed Sep 25, 2023
1 parent f94a546 commit f44d6e5
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/automation-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: automation_test

on:
workflow_dispatch:
inputs:
DEEPFLOW_SERVER_IMAGE_TAG:
description: 'server image tag'
required: false
default: 'latest'
DEEPFLOW_AGENT_IMAGE_TAG:
description: 'agent image tag'
required: false
default: 'latest'
PYTEST_XDIST_WORKER_NUMBER:
description: 'Worker number, recommend 3-6'
required: true
default: '3'
PYTEST_DF_ENV_NUMBER:
description: 'Deepflow env number, recommend 1-3'
required: true
default: '1'
TEST_CASE:
description: 'case name'
required: false
default: 'all'
BRANCH:
description: 'df-test branch '
required: false
default: 'master'
DF_ENVS_FIXED:
description: 'Does test case need server, 1 means no server required'
required: false
default: '0'

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 200
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install Pip
run: |
python -m ensurepip --default-pip
python -m pip install --upgrade pip
- name: Install Sio
run: |
pip install -r automation_test/requirements.txt
- name: set environment vars
run: |
echo "LC_ALL=en_US.utf8" >> $GITHUB_ENV
echo "PYTEST_XDIST_WORKER_NUMBER=${{ github.event.inputs.PYTEST_XDIST_WORKER_NUMBER }}" >> $GITHUB_ENV
echo "PYTEST_DF_ENV_NUMBER=${{ github.event.inputs.PYTEST_DF_ENV_NUMBER }}" >> $GITHUB_ENV
echo "TEST_CASE=${{ github.event.inputs.TEST_CASE }}" >> $GITHUB_ENV
echo "DEEPFLOW_SERVER_IMAGE_TAG=${{ github.event.inputs.DEEPFLOW_SERVER_IMAGE_TAG }}" >> $GITHUB_ENV
echo "DEEPFLOW_AGENT_IMAGE_TAG=${{ github.event.inputs.DEEPFLOW_AGENT_IMAGE_TAG }}" >> $GITHUB_ENV
echo "NO_REPORT=${{ github.event.inputs.BRANCH }}" >> $GITHUB_ENV
echo "DF_ENVS_FIXED=${{ github.event.inputs.DF_ENVS_FIXED }}" >> $GITHUB_ENV
# - name: Setup Debug Session
# uses: csexton/debugger-action@master
- name: run client
run: python3 automation_test/ws_client.py

2 changes: 2 additions & 0 deletions automation_test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python-socketio==5.8.0
requests==2.31.0
7 changes: 3 additions & 4 deletions automation_test/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import sys
import getopt
import os
import logging

UUID = ""
execed = False
Expand Down Expand Up @@ -43,7 +42,7 @@
"BRANCH": "CI_COMMIT_BRANCH",
"UUID": "TEST_EXEC_UUID",
"TIMESTAMP": "TEST_EXEC_TIMESTAMP",
"USER": "GITLAB_USER_LOGIN",
"USER": "GITHUB_ACTOR",
"DEBUG": "DEBUG"
}
for _, key in params_env_key.items():
Expand Down Expand Up @@ -94,7 +93,7 @@ def finished(data):
url = os.environ.get("AUTOMATION_TEST_PUBLIC_URL", "")
token = os.environ.get("AUTOMATION_TEST_TOKEN", "")
if not url or not token:
return
sys.exit(1)
if not params.get("UUID"):
params["UUID"] = UUID
for key in keys:
Expand All @@ -107,5 +106,5 @@ def finished(data):
params[key] = params_default[key]
print(params)
params["AUTOMATION_TEST_TOKEN"] = token
sio.connect(f'ws://{url}')
sio.connect(f'ws://{url}', wait_timeout = 10)
sio.wait()

0 comments on commit f44d6e5

Please sign in to comment.