0%

RobotFramework执行镜像

团队使用RobotFramework作为主要自动化工具,将执行环境容器化,方便部署和扩展,以下为构建的Dockerfile

准备修改基础镜像,使其尺寸更小。同时考虑修改为python3
以下为疑似问题
1、尺寸大
2、python2字符问题
3、sqlite3有unicode问题
4、Jenkins(in docker)执行docker命令时,如果传参中文会报错,docker run rfwjs python /jobsubmit.py para1 para2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# This container is made to execute RobotFramework test.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

FROM devilrancy/robot-cx-python:2.7-slim

MAINTAINER Wu Jiansong <360517703@163.com>

ENV http_proxy=http://username:password@proxy.example.com:8080 \
https_proxy=http://username:password@proxy.example.com:8080 \
REMOTE_URL=http://100.100.154.250:4444/wd/hub

RUN pip install -U pip \
requests \
selenium \
xlrd \
cx-Oracle \
pyhive \
pymysql \
robotframework \
dbbot \
robotframework-selenium2library \
robotframework-databaselibrary \
robotframework-requests \
robotframework-sshlibrary \
robotframework-excelLibrary && \
sed -i "s#formatting_info=True,##g" /usr/local/lib/python2.7/site-packages/ExcelLibrary/ExcelLibrary.py && \
sed -i "s#remote_url=False#remote_url='$REMOTE_URL'#g" /usr/local/lib/python2.7/site-packages/SeleniumLibrary/keywords/browsermanagement.py && \
echo "\
def switch_base_url(self, alias, url):\n\
'''\n\
change base_url of current session. add by w00406273\n\
'''\n\
session = self._cache.switch(alias)\n\
session.url = url\n"\
>> /usr/local/lib/python2.7/site-packages/RequestsLibrary/RequestsKeywords.py && \
echo Asia/Shanghai > /etc/timezone && \
mv /etc/localtime /etc/localtime.bak && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ENV http_proxy= \
https_proxy=
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# This container is made to execute RobotFramework test.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

FROM python:2.7-slim

MAINTAINER Wu Jiansong <360517703@163.com>

ENV REMOTE_URL=http://localhost:4444/wd/hub

# Install Ubuntu packages
RUN apt-get update && apt-get install -y --no-install-recommends \
alien \
dpkg-dev \
debhelper \
build-essential \
libaio1 \
wget \
&& rm -rf /var/lib/apt/lists/*

# Install oracle
# Reference: https://help.ubuntu.com/community/Oracle%20Instant%20Client
# Download RPM files from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
# Get Oracle Client (this isn't the offical download location, but at least it works without logging in!)
RUN wget --no-check-certificate https://raw.githubusercontent.com/bumpx/oracle-instantclient/master/oracle-instantclient12.2-basiclite-12.2.0.1.0-1.x86_64.rpm \

# Alien RPM package installer
&& alien -i *.rpm \

# Cleaning up the packages downloaded
&& rm *.rpm \
&& apt-get purge -y --auto-remove wget alien

RUN echo "/usr/lib/oracle/12.2/client64/lib/" >> /etc/ld.so.conf.d/oracle.conf \
&& echo '#!/bin/bash\n\
export ORACLE_HOME=/usr/lib/oracle/12.2/client64\n\
export PATH=$PATH:$ORACLE_HOME/bin' >> /etc/profile.d/oracle.sh \
&& chmod +x /etc/profile.d/oracle.sh \
&& /etc/profile.d/oracle.sh \
&& ldconfig

RUN pip install -U pip \
requests \
selenium \
xlrd \
cx-Oracle \
pyhive \
pymysql \
robotframework \
dbbot \
robotframework-selenium2library \
robotframework-databaselibrary \
robotframework-requests \
robotframework-sshlibrary \
robotframework-excelLibrary && \
sed -i "s#formatting_info=True,##g" /usr/local/lib/python2.7/site-packages/ExcelLibrary/ExcelLibrary.py && \
sed -i "s#remote_url=False#remote_url='$REMOTE_URL'#g" /usr/local/lib/python2.7/site-packages/SeleniumLibrary/keywords/browsermanagement.py && \
echo "\
def switch_base_url(self, alias, url):\n\
'''\n\
change base_url of current session. add by w00406273\n\
'''\n\
session = self._cache.switch(alias)\n\
session.url = url\n"\
>> /usr/local/lib/python2.7/site-packages/RequestsLibrary/RequestsKeywords.py && \
echo Asia/Shanghai > /etc/timezone && \
mv /etc/localtime /etc/localtime.bak && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime