background
When the CI/CD of the current version of web automation triggers execution, the use case time increases significantly compared with the previous version, and then there is no submission and maintenance of web automation use cases. Check the reasons and decide to upgrade the Chrome version in the server to see if it can effectively reduce the time.
Upgrading ideas
echo "------------------------run_branch.sh params------------------------" echo "ACCOUNT=${ACCOUNT}" echo "PASSWORD=${PASSWORD}" echo "MODULES=${MODULES}" echo "MOD_MODULES=${MOD_MODULES}" echo "URL=${URL}" echo "DOCKER_LOG_PATH=${DOCKER_LOG_PATH}" echo "DOCKER_LOG_FILE=${DOCKER_LOG_FILE}" echo "" docker run -d -v /dev/shm:/dev/shm -v /var/log:/var/log --rm --name ${DOCKER_LOG_FILE} \ docker/robot-web-evn:latest bash -c \ "/opt/run_branch.sh -B ${TEST_BRANCH} -P '-M ${MOD_MODULES} -U ${URL} -R -A ${ACCOUNT} -P ${PASSWORD} -D $DOCKER_LOG_PATH'"
From this shell, we know that when executed on the server, a new container will be created for different modules, so we need to modify the Chrome version in the image and upgrade the corresponding Chrome driver.
Imported and exported image docker
View running instances
--docker ps -a root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 87cf238c109b 877e53b69c39 "bash" 5 weeks ago Up 5 weeks optimistic_wing
View the image on the server
[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker/robot-web-evn latest 877e53b69c39 9 months ago 1.73GB stf-poc_nginx latest 5b74c4e40526 9 months ago 127MB stf-poc_storage-temp latest 9269390e9255 9 months ago 950MB nginx latest 9beeba249f3e 9 months ago 127MB nginx mainline 9beeba249f3e 9 months ago 127MB jenkinsci/blueocean latest 9393ec9589f7 9 months ago 568MB rethinkdb latest cba833c1e775 9 months ago 125MB ubuntu 16.04 005d2078bdfa 10 months ago 125MB openstf/stf latest a65a9b509967 10 months ago 950MB pseudomuto/protoc-gen-doc latest 044fcab256f7 12 months ago 98MB rethinkdb 2.3 3bf9f80966f0 14 months ago 126MB sorccu/adb latest 7123ee61b746 2 years ago 30.5MB openstf/ambassador latest b1f0eb8297cf 5 years ago 6.46MB
Based on imageid:877e53b69c39, there are two corresponding container instances, so we can enter a container, modify the file in the container, export it as a tar file, and then import the file as image.
implement
docker exec -it 87cf238c109b /bin/bash
When entering the container, we need to know the path of Chrome and check the Dockerfile
FROM ubuntu:16.04 MAINTAINER homer RUN mkdir -p /home WORKDIR /opt RUN echo && cd /home \ && apt-get update \ && apt-get install -y python3.6 curl git vim wget \ # && curl https://bootstrap.pypa.io/get-pip.py -o get-pip3.py \ # && python3.6 get-pip3.py \ && apt-get install python3-pip \ && pip3 install --upgrade pip \ && pip install -r packages.txt \
There is a home folder in the root directory to download various installation packages
root@87cf238c109b:/# cd home root@87cf238c109b:/home# ls # result google-chrome-stable_current_amd64.deb
Go to the usr/local/bin directory to check the current Chrome version
google-chrome -version
The version number before upgrading is 55
Since Chrome dependency has been installed before, we only need to download the latest installation package
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Then unzip the installation package, which will automatically overwrite the current chrome version, and the plug-in will not change
sudo dpkg -i ./google-chrome-stable_current_amd64.deb
At this time, the version number is
Google Chrome 88.0.4324.182
Then go to the website to find the chrome driver that matches the current version
wegt http://npm.taobao.org/mirrors/chromedriver/88.0.4324.96/chromedriver_linux64.zip
Unzip the downloaded file and put it in the following location
unzip chromedriver_linux64.zip /usr/bin/chromedriver
After the file of the container is modified, we can exit the container for export
[root@localhost ~]# docker export -o optimistic_wing.tar optimistic_wing
Where - o means output to file, optimal_ wing. Tar is the target file, which is optimal_ Wing is the name of the source container;
After the export, use this tar file to import as a new image
[root@localhost ~]# docker import optimistic_wing.tar docker/robot-web-evn
After successful execution of docker image, you can see that a new image has been created.