dockerfile for running e2e tests against desktop app

Signed-off-by: yevh-berdnyk <ie.berdnyk@gmail.com>
This commit is contained in:
yevh-berdnyk 2018-09-15 20:18:29 +03:00
parent 3b589d03b7
commit 927038a1d7
No known key found for this signature in database
GPG Key ID: E9B425FDFC4DEA9C
7 changed files with 78 additions and 58 deletions

View File

@ -0,0 +1,31 @@
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y xvfb default-jre default-jdk xdotool curl
RUN update-alternatives --config java
RUN apt-get install -y libopencv3.2-java
RUN ln -s /usr/lib/jni/libopencv_java320.so /usr/lib/libopencv_java.so
RUN apt-get install -y icewm wmctrl x11vnc
RUN apt-get clean
RUN mkdir tools
RUN pwd
RUN curl -L "http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7.1/jython-installer-2.7.1.jar" -o /tools/jython_installer-2.7.1.jar
RUN java -jar /tools/jython_installer-2.7.1.jar -s -d jython-2.7.1 -i ensurepip
RUN curl -L "https://raiman.github.io/SikuliX1/sikulixapi.jar" -o /tools/sikulixapi.jar
ADD . /home
WORKDIR "/home"
RUN /jython-2.7.1/bin/jython -m pip install jip
RUN /jython-2.7.1/bin/jython -m pip install -r /home/requirements.txt
RUN chmod +x ./nightly.AppImage
RUN ./nightly.AppImage --appimage-extract
RUN chmod +x /home/squashfs-root/AppRun
EXPOSE 5900
RUN chmod +x start.sh
ENV CLASSPATH=/tools/sikulixapi.jar
ENV DISPLAY=:1
ENTRYPOINT ["./start.sh"]

View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
Xvfb :1 -screen 0 1024x768x24 +extension GLX +render -noreset&
x11vnc --display :1 -forever&
icewm&
/bin/bash

View File

@ -0,0 +1,33 @@
import requests
import re
import docker
from urllib.request import urlretrieve
raw_data = requests.request('GET', 'https://status-im.github.io/nightly/').text
app_url = re.findall('href="(.*AppImage)', raw_data)[0]
urlretrieve(app_url, 'nightly.AppImage')
ps = None
client = docker.from_env()
client.images.build(tag='status_desktop', path='.')
try:
a = client.containers.run("status_desktop",
detach=True, tty=True, ports={'5900/tcp': 5900})
it = a.attach(stdout=True, stderr=True)
print(it)
ps = a.exec_run(['/jython-2.7.1/bin/jython', '-m', 'pytest', '/home/tests/test_create_account.py'],
stdout=True, stderr=False)
except Exception:
pass
finally:
a.stop()
for line in ps.output.decode("utf-8").split("\n"):
print(line)

View File

@ -1,52 +1,13 @@
import org.sikuli.script.SikulixForJython
import pytest
from sikuli import *
from subprocess import check_output
def mac_os_setup():
check_output(['hdiutil', 'attach', 'nightly.dmg'])
check_output(['cp', '-rf', '/Volumes/Status/Status.app', '/Applications/'])
check_output(['hdiutil', 'detach', '/Volumes/Status/'])
import time
time.sleep(10)
openApp('Status.app')
def mac_os_teardown():
closeApp('Status.app')
for dir in '/Applications/Status.app', '/Library/Application\ Support/StatusIm', \
'/Users/yberdnyk/Library/Caches/StatusIm':
check_output(['rm', '-rf', dir])
def linux_setup():
check_output(['chmod', '+x', './nightly.AppImage'])
check_output(['./nightly.AppImage', '--appimage-extract'])
check_output(['chmod', '+x', '/src/squashfs-root/AppRun'])
openApp('/src/squashfs-root/AppRun')
def linux_teardown():
pass
# check_output(['killall', 'ubuntu-server'])
# check_output(['rm', '-rf', '~/.local/share/StatusIm/'])
# check_output(['rm', '-rf', '~/.cache/StatusIm/'])
class BaseTestCase:
Settings.ActionLogs = 0
Settings.OcrTextSearch = True
Settings.OcrTextRead = True
def setup_method(self, method):
if pytest.config.getoption('os') == 'linux':
linux_setup()
else:
mac_os_setup()
openApp('/home/squashfs-root/AppRun')
def teardown_method(self, method):
if pytest.config.getoption('os') == 'linux':
linux_teardown()
else:
mac_os_teardown()
pass

View File

@ -1,9 +1,4 @@
import org.sikuli.script.SikulixForJython
from sikuli import *
import pytest
import requests
import re
from urllib import urlretrieve
from subprocess import check_output
from tests.report import save_test_result, TEST_REPORT_DIR
@ -23,15 +18,7 @@ def pytest_addoption(parser):
def pytest_configure(config):
if config.getoption('nightly'):
raw_data = requests.request('GET', 'https://status-im.github.io/nightly/').text
if config.getoption('os') == 'linux':
app_url = re.findall('href="(.*AppImage)', raw_data)[0]
urlretrieve(app_url, 'nightly.AppImage')
else:
dmg_url = re.findall('href="(.*dmg)', raw_data)[0]
urlretrieve(dmg_url, 'nightly.dmg')
pass
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
@ -46,7 +33,8 @@ def pytest_runtest_makereport(item, call):
def after_all():
if pytest.config.getoption('os') == 'linux':
check_output(['rm', '-rf', 'nightly.AppImage'])
pass
# check_output(['rm', '-rf', 'nightly.AppImage'])
else:
check_output(['rm', '-rf', 'nightly.dmg'])

View File

@ -1,9 +1,11 @@
from tests.base_test_case import BaseTestCase
import pytest
from views.sign_in_view import SignInView
from tests.base_test_case import BaseTestCase
class TestCreateAccount(BaseTestCase):
@pytest.mark.desktop
def test_create_account(self):
sign_in = SignInView()
sign_in.create_account_button.click()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB