Skip to content

Commit 684f019

Browse files
takanokageqianyizh
authored andcommitted
Docker test (#773)
* wip on docker test images. * wip on docker test images. * suppress confirmation requests. * cleanup Dockerfile. update path to googletest source package. added test.sh to replace run.sh eventually. * wip on docker test images. * cleanup. test building deps from source. * removed unused files. * cleanup. * build docker image from specific file. * use a different Dockerfile for different images - everything else is pretty much the same. * renamed test script to show purpose: test on a docker image with open3d dependencies installed. * use a custom tag to describe the current image/container. this should help differentiate from similar but not identical images/containers. * added test for Open3D with no dependencies installed & build dependencies from source. * relocated the open3d test image for ubuntu 18.04. * base the image with pre-installed dependencies on the image without the dependencies. * simplified the no_deps image & test file. * cleanup the docker images. image size reduced from ~0.89GB to ~0.66GB. * install numpy and matplotlib using apt-get. added googletest 1.8.0 to this repo - removes the need for installing wget in the docker image. * remove libpng. libpng gets installed indirectly. note that following this uninstall with an autoremove deletes packages required for building open3d. * made sure libpng doesn't get installed. replaced xorg-dev and its dependencies with a reduced set of packages that are enough to build Open3D. install googletest when testing building Open3D with preinstalled dependencies. * cleanup dockerfile. address the SSL CA cert issue in the .sh file. * no need for both scripts, use cmd line args for tags. valid tags: 1. no_deps 2. with_deps * added comments to Dockerfile and install-gtest.sh. perform googletest install at image build time rather than at open3d build test time. cleanup after installing googletest. * added comments to Dockerfile. * refactored the folder structure in preparation for extending support to Ubuntu 14.04 and 16.04. * added open3d-test:18.04-base image. added build-base.sh to build the base image. build-base.sh displays required arguments if none are provided. test.sh displays required arguments if none are provided. added dockerfiles for ubuntu 18.04, python 2 & 3 and with/without dependencies. In total there are 5 images generated all based on the Open3D base image thus the total disk space occupied by these images is about 700MB. * relocated dockerfiles based on Ubuntu 18.04 to the 18.04/ folder. * added bash scripts for building individual/all images and for cleaning up. * build.sh: display provided arguments if incorrect. use a for loop to build/delete all images. * test.sh only tests one image, doesn't delete any images, builds the image if it's missing. test-all.sh tests all images. simplified cleanup.sh. * cmd line args moved to set_variables.sh. added code for stopping any running open3d-test containers. simplified build.sh and test.sh through the inclusion of set_variables.sh. removed delete.sh as it is not needed anymore. * removed unused file. * added dockerfiles for Ubuntu 16.04. updated build-all.sh test-all.sh and cleanup.sh with Ubuntu 16.04. * added support for Ubuntu 14.04. updated test.sh to explicitely use python2 or python3 when building Open3D. * added debug tool that runs an image using the exact same arguments as test.sh * fixed bug where the PYTHON variable declared inside the script was not known inside the running container. * copied the build & test code to the base image as test.sh. simplified /tools/test.sh. * clone once - test twice: build shared libs after static libs. * more relevant status messages. * build dependencies before a Docker image gets built. * added ubuntu 14.04 and 16.04. * pull submodules. * one line git clone and pull submodules. * move declaration of the PYTHON env variable inside set_variables.sh * install prerequisites for building the pip package. * shebang changed to point to bash rather then sh because sh is less friendly when dealing with arrays. declared arrays for the expected arguments of set_variables.sh: the goal is to centralize the command line arguments. * added arguments.sh which is the central location for defining the accepted/required command line arguments. build.sh still hardcodes some values - find another way to build rdependent builds. * replaced hardcoded strings with data defined in arguments.sh * replaced hardcoded strings with data defined in arguments.sh * set the container timezone to be the same as the host timezone. * install tzdata in order to be able to sync container timezone with host timezone. * wip on changing the order of the arguments. bundle type (previously deps type) is the second argument. python version is the third argument. this simplifies the dependencies between images and the code but adds one more image per ubuntu version. further centralized the command line arguments and environment variables in order to make the code easier to read and maintain in the future. * removed comments and unused code. * fixed bug: incorrect dependency name. * fixed bug: python3 required. * added miniconda 2 and 3 (mc2 and mc3) image options. installed mc2 and mc3. not tested the building of the conda package yet. * added miniconda 2 and 3 (mc2 and mc3) image options. installed mc2 and mc3. not tested the building of the conda package yet. * WIP: - updated miniconda dockerfiles to install required conda dependencies - setup/test.sh updated with command line arguments in order to allow reuse for mc2/3. - tools/test.sh updated with (untested) example on how to build using conda environment. * download the miniconda installers only once. updated the miniconda dockerfiles to copy the installer from the host rather than downloading from the web. simplified miniconda docker image creation. * fixed bug: need env variable defined when running the container. * renamed python_version to env_type because py2/3 and mc2/3 are really referring to entire ecosystems not just to python versions anymore. * reduced code width to less than 80 cols by declaring/using the MC2/3_INSTALLER variables. removed: the PYTHON env variable is not needed anymore. * tell conda to display fewer messages and to not prompt for yes/no. when building an image, check if the image was already built; if yes skip. this reduces the total amount of messages when testing. * cleanup + comments. * update comments regarding native installation of python. * fixed bug: missing quotation marks when defining env variables. quatation marks needed when there are spaces in the strings passed as env variables. * improved feedback messages: specify python version and pip/conda environment. * reduced nr columns of help code lines to less than 80. simplified help messages. * timestamp each test. * renamed variables: - deps -> bundle - python -> env * cleanup. suppress messages about not found images. * reduce apt-get output messages. one line conda install for conda-build & conda-verify. perform conda update followed by conda clean. * pass the miniconda installer filename as an argument to the docker image build command. use the same approach for the conda destination directory. these two changes have the effect of making all the miniconda docker images pretty much identical with the target OS being the only difference. fix bug in /setup/test.sh where the library link mode was always STATIC. improved the way the conda command is enabled and activated. * the activation of the conda environment is now embedded in the dockerfiles. removed unnecessary code. * removed unnecessary code. * used the PYTHON ARG for specifying the python version in the command line of the docker image build command. this makes the native python based images have very similar dockerfiles. * pass the ubuntu version as a command line argument to the docker image build command. this causes the dockerfiles to become almost identical to eachother. * fixed bugs * encapsulate all variables with curly braces. fixed dockerfiles bug: ARG variables empty if placed at the begining of the file. * updated run.sh to the latest changes in the docker/open3d-test framework * alternate way of detecting whether we're operating under an active conda environment or not. the previous way failed on a miniconda3 installation - sys.version did not include the 'conda' substring. * removed the line that placed conda in path following the recommendation in https://github.com/conda/conda/blob/master/CHANGELOG.md#440-2017-12-20. updated conda dockerfiles to use the full explicit path to conda while building the image. * the conda settings in .bashrc only work with interactive shells, for this reason we need to explicitly activate conda for the mc2/mc3 path. * the bundle type is now passed as a command line argument to the build.sh script. this further eliminates differences between the Dockerfiles. * fixed bug: added missing ARG BUNDLE_TYPE. install libglfw3-dev only if the ubuntu version is not 14.04. this change further reduces differences between Dockerfiles. * merge all COPY layers into one layer. merge all RUN layers into one layer. * reorder ops, move rm ops at the end. * replaced 30 Dockerfiles with just 4. this was made possible through the use of docker ARGs which is a way to set image variables through image build arguments. * added code to upload the images to hub.docker.com and to download the images on demand for the tests. * test basic docker-travis integration. * wip: basic docker-travis integration. * no need to specify the workdir again. * wip: basic docker-travis integration. * added link_type to arguments.sh. this was done in order to allow specifying the link_type at test time. setup/test.sh will only test one link_type. test-all.sh will explicitly test both link_type(s). upload.sh renamed into upload-all.sh. added upload.sh to upload just one image (and its dependencies). repaired docker files to use the repository when specifying dependencies (FROM argument). IMAGE_EXISTS check moved to set_variables.sh. check if IMAGE_EXISTS before pulling an image. * stop.sh -> stop-all.sh. added stop.sh to stop just one container. * make sure the previous container is stopped before moving on. * test using the matrix option with docker. * test using the matrix option with docker. * test using the matrix option with docker. * make the scripts runable from any workdir. in other words, no need to cd into the <...>/open3d-test/tools folder in order to run them. * use env variables. this helps label the jobs. * fix path to script. * added package coreutils because of missing realpath utility. * test install coreutils in order to get the realpath command. * test install coreutils in order to get the realpath command. * test alternate way of installing realpath. * coreutils/realpath not needed here but on host. * remove the . in the TAG/Ubuntu version number. this allows displaying the full hostname in the prompt. otherwise the part in the hostname after the dot is not displayed. * modified command prompt to display hostname:basename(crt_dir) (.bashrc file). build.sh: check if an image exists before doing anything else. cleanup.sh: remove an image only if found on disk. also simplify output. upload.sh: upload an image only if found on disk. simplify output. * moved logic from inside the dockerfiles to dedicated setup scripts. added comments. run.sh: don't clone open3d, just show prompt. * stop.sh: print confirmation after stopping a container. stop-all.sh: stop base and deps containers too. * use the link type as a container name suffix in order to address the issue of container name collisions at test time. use a container hostname without the link type suffix - the name was getting too long. * wip: combine native and docker build tests. * moved before_install section into setup-linux.sh and setup-osx.sh scripts. * wip: before_install invokes bash scripts. * wip: before_install invokes bash scripts. * moved the script to run-travis.sh. * added run-travis.sh. cleanup setup-*.sh * can't use travis_wait inside bash script. * wip: use run_travis.sh in order to perform the build tests. * moved the git submodule update back to .travis.yml * test that git submodule update is not required. travis doc states that travis clones the submodules automatically. * test running docker based tests in parallel with the native build tests. * added 30min timeout on osx build tests. * cleanup the travis script. no need to install twice. cleanup at the end. the script can be tested on the host side if moved to the root of the Open3D folder. * fix bug. * updated docker test.sh to also install/uninstall open3d. updated run_travis.sh to display current progress. travis.yml: cosmetic change. * prepare to upload to the open3d docker repo. * have to use lowercase for the repo name. * open3d name is taken on hub.docker.com. * time the downloading of the test image. converted some comments into progress messages. * cosmetic changes: add more time/date labels and make the output more readable by separating it into paragraphs. * nproc command doesn't exist on macos - use an env variable instead. * added documentation on open3d-test docker solution and updated documentation on open3d-xvfb. * enhanced the description of the two docker solutions, one that allows the use of a GUI inside Docker and the other designed for testing which doesn't allow the use of a GUI. * updated links to point to github/IntelVCL. added note about the requirement for docker login when uploading the Open3D docker images. * test building a C++ example with installed Open3D. * added googletest 1.8.0 source code. kept the original archive as downloaded from the googletest repo for two reasons: 1. archive only 1.3MB while decompressed googletest takes 7.6MB 2. the source code is built/installed only once per system, independently from the process of building/installing Open3D. * placed googletest in wrong path. * updated HEAD of 3rdparty. * copy the gtest src code from the 3rdparty folder to the setup folder. * fragmented code in order to meet the 80 cols guideline. * cosmetic: converted comments into progress messages. * added the 'set -e' option to help catch all errors in scripts invoked by travis. * set -e breaks the installation of the dependencies. * clone open3d for the user when using run.sh. * removed set -e for now. * set -e on run-travis.sh. * set -e on the script running the tests inside the docker container.
1 parent c2875fc commit 684f019

34 files changed

+1294
-215
lines changed

.travis.yml

Lines changed: 23 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ env:
33
global:
44
- SHARED=OFF
55
- BUILD_DEPENDENCY_FROM_SOURCE=OFF
6+
- NPROC=2
67

78
notifications:
89
email:
@@ -27,6 +28,8 @@ matrix:
2728
- g++-4.8
2829
- cmake-data # to use cmake 3.0 or more recent
2930
- cmake
31+
before_install: ./util/scripts/setup-linux.sh
32+
script: ./util/scripts/run-travis.sh
3033

3134
- os: linux
3235
dist: trusty
@@ -43,6 +46,8 @@ matrix:
4346
- cmake-data # to use cmake 3.0 or more recent
4447
- cmake
4548
env: SHARED=ON
49+
before_install: ./util/scripts/setup-linux.sh
50+
script: ./util/scripts/run-travis.sh
4651

4752
- os: linux
4853
dist: trusty
@@ -59,6 +64,8 @@ matrix:
5964
- cmake-data # to use cmake 3.0 or more recent
6065
- cmake
6166
env: BUILD_DEPENDENCY_FROM_SOURCE=ON
67+
before_install: ./util/scripts/setup-linux.sh
68+
script: ./util/scripts/run-travis.sh
6269

6370
# Similar environment of Ubuntu 16.04 (gcc 5.4)
6471
# travis ci only supports Ubuntu 14.04 (trusty) gcc-5 and 6
@@ -77,98 +84,39 @@ matrix:
7784
- g++-6
7885
- cmake-data # to use cmake 3.0 or more recent
7986
- cmake
87+
before_install: ./util/scripts/setup-linux.sh
88+
script: ./util/scripts/run-travis.sh
8089

8190
# Default environment of MacOS El Capitan
8291
# compiled using clang shipped with xcode8
8392
- os: osx
8493
osx_image: xcode8
94+
script: travis_wait 30 ./util/scripts/run-travis.sh
95+
before_install: ./util/scripts/setup-osx.sh
8596

8697
- os: osx
8798
osx_image: xcode8
8899
env: SHARED=ON
100+
before_install: ./util/scripts/setup-osx.sh
101+
script: travis_wait 30 ./util/scripts/run-travis.sh
89102

90103
# Default environment of MacOS 10.13
91104
# compiled using clang shipped with xcode10.1
92105
- os: osx
93106
osx_image: xcode10.1
107+
script: travis_wait 30 ./util/scripts/run-travis.sh
108+
before_install: ./util/scripts/setup-osx.sh
94109

95110
- os: osx
96111
osx_image: xcode10.1
97112
env: BUILD_DEPENDENCY_FROM_SOURCE=ON
113+
script: travis_wait 30 ./util/scripts/run-travis.sh
114+
before_install: ./util/scripts/setup-osx.sh
98115

99-
before_install:
100-
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
101-
./util/scripts/install-deps-ubuntu.sh;
102-
./util/scripts/make-documentation.sh;
103-
./util/scripts/install-gtest.sh;
104-
fi
105-
# scripts/install-deps-osx.sh works well
106-
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
107-
./util/scripts/install-deps-osx.sh;
108-
./util/scripts/install-gtest.sh;
109-
fi
116+
- env: DOCKER=YES UBUNTU=16.04 BUNDLE=deps ENV=py3 LINK=STATIC
117+
script: ./util/docker/open3d-test/tools/test.sh $UBUNTU $BUNDLE $ENV $LINK
118+
before_install: sudo apt-get update && sudo apt-get install -y realpath
110119

111-
# for reference, display cmake and python version
112-
- python -V
113-
- cmake --version
114-
- export nproc=2
115-
# - pip install numpy
116-
117-
script:
118-
# Build and install to CMake's default install path
119-
- python -V
120-
- git submodule update --init --recursive
121-
- mkdir build
122-
- cd build
123-
- if [ "$BUILD_DEPENDENCY_FROM_SOURCE" == "OFF" ]; then
124-
cmake -DBUILD_SHARED_LIBS=$SHARED -DBUILD_UNIT_TESTS=ON ..;
125-
else
126-
cmake -DBUILD_SHARED_LIBS=$SHARED -DBUILD_UNIT_TESTS=ON -DBUILD_EIGEN3=ON
127-
-DBUILD_GLEW=ON -DBUILD_GLFW=ON -DBUILD_JPEG=ON -DBUILD_JSONCPP=ON
128-
-DBUILD_PNG=ON ..;
129-
fi
130-
# make -j brings 'virtual memory exhausted: Cannot allocate memory' message
131-
# this is presumably due to limited memory space of travis-ci
132-
# also set the time limit to 30 mins, this is a fix to issue #557
133-
- travis_wait 30 sudo make install -j$nproc
134-
- ./bin/unitTests
135-
- test=`cmake --find-package -DNAME=Open3D -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=EXIST`
136-
- if [ "$test" == "Open3D found." ]; then
137-
echo "PASSED find_package(Open3D) in default install path.";
138-
else
139-
echo "FAILED find_package(Open3D) in default install path.";
140-
exit 1;
141-
fi
142-
143-
# Reconfig and install in a specified CMAKE_INSTALL_PREFIX
144-
- sudo make uninstall
145-
- if [ "$BUILD_DEPENDENCY_FROM_SOURCE" == "OFF" ]; then
146-
cmake -DBUILD_SHARED_LIBS=$SHARED -DBUILD_UNIT_TESTS=ON
147-
-DCMAKE_INSTALL_PREFIX=~/open3d_install ..;
148-
else
149-
cmake -DBUILD_SHARED_LIBS=$SHARED -DBUILD_UNIT_TESTS=ON -DBUILD_EIGEN3=ON
150-
-DBUILD_GLEW=ON -DBUILD_GLFW=ON -DBUILD_JPEG=ON -DBUILD_JSONCPP=ON
151-
-DBUILD_PNG=ON -DCMAKE_INSTALL_PREFIX=~/open3d_install ..;
152-
fi
153-
- travis_wait 30 sudo make install -j$nproc
154-
- test=`cmake --find-package -DNAME=Open3D -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=EXIST
155-
-DCMAKE_PREFIX_PATH="~/open3d_install/lib/cmake"`
156-
- if [ "$test" == "Open3D found." ]; then
157-
echo "PASSED find_package(Open3D) in specified install path.";
158-
else
159-
echo "FAILED find_package(Open3D) in specified install path.";
160-
exit 1;
161-
fi
162-
163-
# Test building example with installed Open3D
164-
- cd ../docs/_static/C++
165-
- mkdir build
166-
- cd build
167-
- cmake -DCMAKE_INSTALL_PREFIX=~/open3d_install ..
168-
- make
169-
- ./TestVisualizer
170-
171-
# The following script has issues on SHARED = "ON"
172-
# - if [ "$SHARED" == "OFF" ]; then
173-
# cd lib/Tutorial/Basic/ && python file_io.py
174-
# fi
120+
- env: DOCKER=YES UBUNTU=16.04 BUNDLE=deps ENV=py3 LINK=SHARED
121+
script: ./util/docker/open3d-test/tools/test.sh $UBUNTU $BUNDLE $ENV $LINK
122+
before_install: sudo apt-get update && sudo apt-get install -y realpath

3rdparty

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
.. _docker-gui:
2+
3+
Docker GUI
4+
----------
5+
6+
The following document describes a solution for utilizing Open3D with GUI/visualization under Docker.
7+
8+
Utilizing this approach the user can:
9+
10+
- sandbox Open3D from other applications on a machine
11+
- operate Open3D on a headless machine using VNC or the terminal
12+
- edit the Open3D code on the host side but run it inside an Open3D container
13+
14+
This recipe was developed and tested on Ubuntu 18.04. Other distributions might need slightly different instructions.
15+
16+
.. _docker-gui-usage-notes:
17+
18+
Usage notes
19+
===========
20+
21+
.. _docker-gui-files:
22+
23+
Docker files
24+
````````````
25+
26+
The docker setup files and tools can be found under `Open3d/util/docker/open3d-xvfb <https://github.com/IntelVCL/Open3D/tree/docker/util/docker/open3d-xvfb>`_.
27+
28+
- Dockerfile
29+
- setup
30+
- entrypoint.s
31+
- docker_sample.sh
32+
- tools
33+
- attach.sh
34+
- build.sh
35+
- delete.sh
36+
- name.sh
37+
- prune.sh
38+
- run.sh
39+
- stop.sh
40+
41+
**Dockerfile**
42+
43+
``Dockerfile`` is the Docker script used to build the Open3D image.
44+
45+
**Tools**
46+
47+
We provide a number of Docker tools for convenience:
48+
49+
- ``attach.sh``
50+
Attach a terminal to a running Open3D docker container.
51+
- ``build.sh``
52+
Build the Open3D docker image.
53+
- ``delete.sh``
54+
Delete the Open3D image.
55+
- ``prune.sh``
56+
Delete **all** stopped containers and **all** dangling images.
57+
- ``run.sh``
58+
Run the Open3D container. Checkout Open3D, build and install.
59+
- ``stop.sh``
60+
Stop the Open3D container.
61+
62+
A typical flow of events when working with docker looks like this:
63+
64+
.. code-block:: sh
65+
66+
$ cd <open3d_path>/util/docker/open3d_xvfb/tools
67+
$ ./build.sh
68+
$ ./run.sh
69+
root@open3d-xvfb:~/open3d/build# <do some stuff>
70+
root@open3d-xvfb:~/open3d/build# exit
71+
$ ./attach.sh
72+
root@open3d-xvfb:~/open3d# <do some stuff>
73+
root@open3d-xvfb:~/open3d# exit
74+
$ ./stop.sh
75+
76+
Building the Open3D Docker image will take approximately 10-15 minutes to complete.
77+
At the end the image will be ~1GB in size.
78+
79+
Running the Open3D Docker container will perform the following steps:
80+
81+
- git clone Open3D master to ``~/open3d_docker``
82+
- run the container in interactive mode with the host path ``~/open3d_docker`` mounted inside the container at ``/root/Open3D``
83+
- build Open3D and install inside the docker container.
84+
- attach a terminal to the Open3D container for command line input from the host side
85+
86+
In order to disconnect from a running container type ``exit`` at the terminal.
87+
You can still attach to a running container at a later time.
88+
89+
The Open3D container is automatically removed when stopped.
90+
None of the Open3D files are removed as they in fact reside on the host due to the Docker bind mounting functionality.
91+
In order to keep the container around (and not have to rebuild the Open3D binaries every time) remove the ``-rm`` option in ``run.sh``.
92+
93+
Prunning images/containers is useful when modifying/testing a new image.
94+
It cleans up the docker workspace and frees up disk space.
95+
96+
.. _docker-gui-remote-access:
97+
98+
Remote access
99+
`````````````
100+
101+
VNC can be used to remote into a running docker container.
102+
103+
A running Open3D container listens to port 5920 on the host.
104+
The ``run.sh`` script redirects host port 5920 to container port 5900.
105+
106+
This allows remoting into the container using VNC to ``<host ip>:5920``.
107+
The default password is ``1234`` and can be changed in ``Open3D/issue_17/util/docker/open3d-xvfb/setup/entrypoint.sh`` (requires rebuilding the Open3D Docker image with ``build.sh``).
108+
Once connected you can use Open3D as usual.
109+
110+
.. _docker-gui-host-terminal:
111+
112+
Running at the host terminal
113+
````````````````````````````
114+
115+
It is also possible to run Open3D from a host terminal attached to a running Open3D Docker container.
116+
An example on how this can be perfomed:
117+
118+
.. code-block:: sh
119+
120+
# at the host terminal
121+
$ sudo cp ~/open3d_docker/util/docker/open3d-xvfb/setup/docker_sample.sh \
122+
~/open3d_docker/build/lib/Tutorial/Advanced
123+
$ cd ~/open3d_docker/utilities/docker/open3d-xvfb/tools
124+
$ ./attach.sh
125+
126+
# at the container terminal
127+
$ cd ~/open3d/build/lib/Tutorial/Advanced
128+
$ sh docker_sample.sh
129+
130+
.. _docker-gui-limitations:
131+
132+
Limitations
133+
===========
134+
135+
- | the ``lxde`` user interface needs more configuring.
136+
| Some things won't work as expected. For example the ``UXTerm`` doesn't start and ``lxterminal`` may crash occasionally.
137+
- | the container screen resolution is set to 1280x1024x8.
138+
| The resolution will be increased in the future.
139+
- | there are some rendering issues.
140+
| Some images may be saved incorrectly to the disk. For example, when running the ``headless_sample.py`` sample the color images saved to the disk are black.
141+
- | ``run.sh`` clones Open3D to a hardcoded location: ``~/open3d_docker``
142+
| We are considering the following alternatives:
143+
144+
- let the user specify the destination
145+
- reuse the current location of Open3D
146+

0 commit comments

Comments
 (0)