Skip to content

Commit

Permalink
Run ATR in Docker (#82)
Browse files Browse the repository at this point in the history
Relates to PRJLTVA-797
  • Loading branch information
ppaneksamsung authored and GitHub Enterprise committed Feb 2, 2021
1 parent abdb7d7 commit 1b356df
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 13 deletions.
34 changes: 21 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ jobs:
- persist_to_workspace:
root: .
paths:
- ./JuvoPlayer.TizenTests/bin/*/*/*.tpk
- ./JuvoPlayer.TizenTests/bin/Release/tizen60/*.tpk
- ./scripts/nunit3-junit.xlst
- ./atr_tests/*
run_integration_tests:
working_directory: /build
docker:
Expand Down Expand Up @@ -95,19 +96,26 @@ jobs:
no_output_timeout: 20m
command: >
scp -o StrictHostKeyChecking=no ${TPK_PATH} ${ATR_RUNNER_USER}@${ATR_RUNNER_IP}:/tmp/ &&
ssh -o StrictHostKeyChecking=no ${ATR_RUNNER_USER}@${ATR_RUNNER_IP} scp /tmp/${TPK_NAME} streamsrv:/srv/www/pnacl/juvo-player/ &&
ssh -o StrictHostKeyChecking=no ${ATR_RUNNER_USER}@${ATR_RUNNER_IP} rm -rf /home/${ATR_RUNNER_USER}/atr/results/ &&
ssh -o StrictHostKeyChecking=no ${ATR_RUNNER_USER}@${ATR_RUNNER_IP} /home/${ATR_RUNNER_USER}/atr/atr task
--name "JuvoPlayerTest"
--scenario JuvoPlayerTest
--payload "{\\\"tpk\\\":\\\"http://stream-srv.sprc.samsung.pl/pnacl/juvo-player/${TPK_NAME}\\\"}"
--dlog_tags JuvoPlayer UT DOTNET_LAUNCHER
--image_url ${IMAGE_URL}
--tizen_version ${TIZEN_VERSION}
--board ${BOARD}
scp -r -o StrictHostKeyChecking=no /build/atr_tests ${ATR_RUNNER_USER}@${ATR_RUNNER_IP}:/tmp/ &&
ssh -t -o StrictHostKeyChecking=no ${ATR_RUNNER_USER}@${ATR_RUNNER_IP} "cd /home/${ATR_RUNNER_USER}/weed/atr &&
rm -rf results &&
rm -rf atr_tests &&
mkdir atr_tests &&
cp -rf /tmp/atr_tests/* atr_tests &&
cp /tmp/${TPK_NAME} atr_tests &&
python3 atr_in_docker.py
--task-scenario JuvoPlayerTest
--tty ${TTY_DEV}
--irda-device ${IRDA_DEV}
--log-level debug
--dlog-tags JuvoPlayer UT DOTNET_LAUNCHER
--url ${IMAGE_URL}
--tizen ${TIZEN_VERSION}
--custom-docker-arguments=\"-v /home/${ATR_RUNNER_USER}/weed/atr/atr_tests:/root/atr/src/tests/juvo_player_test:ro\"
--board-version ${BOARD_VERSION}"
- run:
name: Download test results
command: scp -o StrictHostKeyChecking=no -r ${ATR_RUNNER_USER}@${ATR_RUNNER_IP}:/home/${ATR_RUNNER_USER}/atr/results/* results/
command: scp -o StrictHostKeyChecking=no -r ${ATR_RUNNER_USER}@${ATR_RUNNER_IP}:/home/${ATR_RUNNER_USER}/weed/atr/results/* results/
when: always
- store_artifacts:
path: results
Expand All @@ -118,7 +126,7 @@ jobs:
command: >
mkdir -p TestResults &&
xsltproc -o TestResults/output.xml scripts/nunit3-junit.xlst
results/JuvoPlayerTest/JuvoPlayerTest/JuvoPlayerTest/JuvoPlayer.TizenTests.xml
results/ATR_Task/JuvoPlayerTest/JuvoPlayerTest/JuvoPlayer.TizenTests.xml
when: always
- store_test_results:
path: TestResults/
Expand Down
99 changes: 99 additions & 0 deletions atr_tests/juvo_player_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import glob
import json
import os
import shutil
import time
import xml.etree.ElementTree as ET

import atr_lib
from core.downloader import download_parallel
from core.tv_board import TvBoard
from core.widget import Widget
from result import Result
from test import Test


class JuvoPlayerTest(Test):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.tpk_dir = None
self.tpk_name = None
self.widget = None

def prepare(self):
self._resolve_tpk_path()
self._prepare_widget()
return True

def _resolve_tpk_path(self):
script_path = os.path.realpath(__file__)
self.tpk_dir = os.path.dirname(script_path)
tpk_path = glob.glob('{}/*.tpk'.format(self.tpk_dir))[0]
self.tpk_name = os.path.basename(tpk_path)

def _prepare_widget(self):
if self.tpk_name is None:
raise RuntimeError('TPK is missing')
self.widget = Widget(self.tpk_dir, self.tpk_name, self.board)
self.widget.install()

def _get_results(self):
result_paths = self.board.exe_cmd_with_result('ls /tmp/Juvo*.xml')
if result_paths.return_code != 0:
if self._has_crashed():
self._pull_core_dump_files()
raise RuntimeError('Tests results are missing')

for result_path in result_paths.stdout.split():
self.board.pull_file(result_path, self.result_path)
basename = os.path.basename(result_path)
local_result_path = os.path.join(self.result_path, basename)
root = ET.parse(local_result_path).getroot()
for test_case in root.iter('test-case'):
if test_case.attrib['result'] == 'Skipped':
continue
name = test_case.attrib['name']
result = test_case.attrib['result'] == 'Passed'
self.results.add_results(Result(name, result=result))
if not result:
self.results.result = result

def _has_crashed(self):
if self.widget.pid is None:
return False
pid = self.widget.pid
version, build = self.board.get_image_ver()
for mount_point in TvBoard.UsbStorage(self.board).drive_path():
result = self.board.exe_cmd_with_result(
'ls {}/Coredump*{}*{}*'.format(mount_point, pid,
build))
if result.return_code == 0 and len(result.stdout.split()) == 1:
return True
return False

def _pull_core_dump_files(self):
# Sometimes, this method may pull more files than needed,
# but it shouldn't be a problem
pid = self.widget.pid
for mount_point in TvBoard.UsbStorage(self.board).drive_path():
result = self.board.exe_cmd_with_result(
'ls {}/*{}*'.format(mount_point, pid))
if result.return_code != 0:
continue
for path in result.stdout.split():
self.board.pull_file(path, self.result_path)

def run(self):
try:
self.widget.launch()
while self.widget.check_if_running():
time.sleep(5)
finally:
if self.widget.check_if_running():
self.widget.terminate()
self.widget.uninstall()
self._get_results()
return self.results.result

def collect_results(self):
return self.results

0 comments on commit 1b356df

Please sign in to comment.