Optimize slow bottleneck test of DockerSuite.TestBuildDockerignoringWildDirs.
This PR fix the DockerSuite.TestBuildDockerignoringWildDirs test in #19425. Instead of having multiple RUN instructions in Dockerfile for every single directory tested, this PR tries to collapse multiple RUN instructions into one RUN instruction in Dockerfile. When a docker image is built, each RUN instruction in Dockerfile will generate one layer in history. It takes considerable amount of time to build many layers if there are many RUN instructions within the Dockerfile. Collapsing into one RUN instruction not only speeds up the execution significantly, it also conforms to the general guideline of the Dockerfile reference. Since the test (DockerSuite.TestBuildDockerignoringWildDirs) is really about testing the docker build with ignoring wild directories, the purpose of the test is not altered with this PR fix. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
17156ba98f
commit
c77bb28dfb
1 changed files with 19 additions and 24 deletions
|
@ -3694,30 +3694,25 @@ func (s *DockerSuite) TestBuildDockerignoringWildDirs(c *check.C) {
|
|||
FROM busybox
|
||||
COPY . /
|
||||
#RUN sh -c "[[ -e /.dockerignore ]]"
|
||||
RUN sh -c "[[ -e /Dockerfile ]]"
|
||||
|
||||
RUN sh -c "[[ ! -e /file0 ]]"
|
||||
RUN sh -c "[[ ! -e /dir1/file0 ]]"
|
||||
RUN sh -c "[[ ! -e /dir2/file0 ]]"
|
||||
|
||||
RUN sh -c "[[ ! -e /file1 ]]"
|
||||
RUN sh -c "[[ ! -e /dir1/file1 ]]"
|
||||
RUN sh -c "[[ ! -e /dir1/dir2/file1 ]]"
|
||||
|
||||
RUN sh -c "[[ ! -e /dir1/file2 ]]"
|
||||
RUN sh -c "[[ -e /dir1/dir2/file2 ]]"
|
||||
|
||||
RUN sh -c "[[ ! -e /dir1/dir2/file4 ]]"
|
||||
RUN sh -c "[[ ! -e /dir1/dir2/file5 ]]"
|
||||
RUN sh -c "[[ ! -e /dir1/dir2/file6 ]]"
|
||||
RUN sh -c "[[ ! -e /dir1/dir3/file7 ]]"
|
||||
RUN sh -c "[[ ! -e /dir1/dir3/file8 ]]"
|
||||
RUN sh -c "[[ -e /dir1/dir3 ]]"
|
||||
RUN sh -c "[[ -e /dir1/dir4 ]]"
|
||||
|
||||
RUN sh -c "[[ ! -e 'dir1/dir5/fileAA' ]]"
|
||||
RUN sh -c "[[ -e 'dir1/dir5/fileAB' ]]"
|
||||
RUN sh -c "[[ -e 'dir1/dir5/fileB' ]]" # "." in pattern means nothing
|
||||
RUN sh -c "[[ -e /Dockerfile ]] && \
|
||||
[[ ! -e /file0 ]] && \
|
||||
[[ ! -e /dir1/file0 ]] && \
|
||||
[[ ! -e /dir2/file0 ]] && \
|
||||
[[ ! -e /file1 ]] && \
|
||||
[[ ! -e /dir1/file1 ]] && \
|
||||
[[ ! -e /dir1/dir2/file1 ]] && \
|
||||
[[ ! -e /dir1/file2 ]] && \
|
||||
[[ -e /dir1/dir2/file2 ]] && \
|
||||
[[ ! -e /dir1/dir2/file4 ]] && \
|
||||
[[ ! -e /dir1/dir2/file5 ]] && \
|
||||
[[ ! -e /dir1/dir2/file6 ]] && \
|
||||
[[ ! -e /dir1/dir3/file7 ]] && \
|
||||
[[ ! -e /dir1/dir3/file8 ]] && \
|
||||
[[ -e /dir1/dir3 ]] && \
|
||||
[[ -e /dir1/dir4 ]] && \
|
||||
[[ ! -e 'dir1/dir5/fileAA' ]] && \
|
||||
[[ -e 'dir1/dir5/fileAB' ]] && \
|
||||
[[ -e 'dir1/dir5/fileB' ]]" # "." in pattern means nothing
|
||||
|
||||
RUN echo all done!`
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue