Skip to content

Commit

Permalink
Base image as prerequisite step
Browse files Browse the repository at this point in the history
New command is introduced to generate base image with all the
dependencies installed. This can be scheduled to run once in a day
to get the latest base image.

```
gluster-tester baseimg
```

`gluster-tester run ...` will use this base image to create tester
container and run.

Signed-off-by: Aravinda VK <[email protected]>
  • Loading branch information
aravindavk committed Jun 7, 2019
1 parent 0ec8f43 commit a2a1fa6
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 27 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ cd gluster-tester
sudo python setup.py install
```

Create the base image by running the following command.(This command
can be scheduled to run nightly)

```
gluster-tester baseimg
```

Cleanup the backend directory and log directories and run the tests
using the following command,

Expand Down
18 changes: 17 additions & 1 deletion glustertester/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,27 @@ def get_args():
default="")
parser_run.add_argument("--ignore-failure", action="store_true")

parser_baseimg = subparsers.add_parser('baseimg')
parser_baseimg.add_argument("--logdir",
help="Root Log directory for all testers",
default="/var/log/gluster-tester")
return parser.parse_args()


def subcmd_baseimg(args):
scriptsdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "scripts")
run_else_exit("bash %s/build-container.sh glusterfs-tester-base base.Dockerfile"
"&>%s/build-base-container.log" % (scriptsdir, args.logdir)
)


def subcmd_run(args):
scriptsdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "scripts")
test_env = os.environ.copy()
test_env["NPARALLEL"] = str(args.num_parallel)
test_env["REFSPEC"] = args.refspec

run_else_exit("bash %s/build-container.sh "
run_else_exit("bash %s/build-container.sh glusterfs-tester Dockerfile"
"&>%s/build-container.log" % (scriptsdir, args.logdir),
env=test_env
)
Expand All @@ -91,6 +102,7 @@ def subcmd_run(args):
name = "glusterfs-tester-%d" % num
run_else_exit(
"docker run -d"
" --cap-add sys_admin"
" --privileged=true"
" --device /dev/fuse"
" --name " + name +
Expand All @@ -115,6 +127,10 @@ def main():
if args.subcmd == "run":
subcmd_run(args)
return

if args.subcmd == "baseimg":
subcmd_baseimg(args)
return
except KeyboardInterrupt:
sys.exit(1)

Expand Down
26 changes: 1 addition & 25 deletions glustertester/scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
ARG baseversion=29
ARG baseos=fedora
FROM ${baseos}:${baseversion}
FROM gluster/glusterfs-tester-base

# Redefining since arg defined before FROM is not accessible here
ARG baseos=fedora

RUN mkdir -p /root/tests

# TODO: Handle CentOS dependencies
# TODO: Include sysvinit-tools, netstat in case of centos
RUN if [ "x$baseos" = "xfedora" ]; then \
yum install -y \
git autoconf automake bison dos2unix flex fuse-devel glib2-devel \
libaio-devel libattr-devel libibverbs-devel librdmacm-devel \
libtool libxml2-devel lvm2-devel make openssl-devel pkgconfig \
pyliblzma python-devel python-eventlet python-netifaces python-paste-deploy \
python-simplejson python-sphinx python-webob pyxattr readline-devel \
rpm-build systemtap-sdt-devel tar libcmocka-devel rpcgen libacl-devel \
sqlite-devel libtirpc-devel userspace-rcu-devel libselinux-python \
perl-Test-Harness which attr dbench git nfs-utils xfsprogs \
yajl openssh-clients openssh-server openssh python2-psutil userspace-rcu \
firewalld libcurl-devel python3-devel \
;fi

# For Geo-rep, Prepare password less ssh
RUN mkdir -p /root/.ssh
RUN rm -rf .ssh/id_rsa*
RUN ssh-keygen -N "" -f /root/.ssh/id_rsa
RUN cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

ARG refspec=""
RUN cd /root/ && git clone --depth 1 https://review.gluster.org/glusterfs
RUN if [ "x$refspec" != "x" ]; then \
Expand Down
50 changes: 50 additions & 0 deletions glustertester/scripts/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
ARG baseversion=29
ARG baseos=fedora
FROM ${baseos}:${baseversion}

# Redefining since arg defined before FROM is not accessible here
ARG baseos=fedora

RUN mkdir -p /root/tests

# TODO: Handle CentOS dependencies
# TODO: Include sysvinit-tools, netstat in case of centos
RUN if [ "x$baseos" = "xfedora" ]; then \
yum install -y \
git autoconf automake bison dos2unix flex fuse-devel glib2-devel \
libaio-devel libattr-devel libibverbs-devel librdmacm-devel \
libtool libxml2-devel lvm2-devel make openssl-devel pkgconfig \
pyliblzma python-devel python-eventlet python-netifaces python-paste-deploy \
python-simplejson python-sphinx python-webob pyxattr readline-devel \
rpm-build systemtap-sdt-devel tar libcmocka-devel rpcgen libacl-devel \
sqlite-devel libtirpc-devel userspace-rcu-devel libselinux-python \
perl-Test-Harness which attr dbench git nfs-utils xfsprogs \
yajl openssh-clients openssh-server openssh python2-psutil userspace-rcu \
firewalld libcurl-devel python3-devel cifs-utils e2fsprogs hostname \
iproute libldb libss libwbclient lmdb-libs net-tools psmisc \
python3-requests python3-urllib3 resource-agents rsync samba-client-libs \
samba-common samba-common-libs bc libtalloc libtdb libtevent linux-atm-libs \
python3-chardet python3-idna python3-prettytable python3-pysocks \
python3-pyxattr iproute-tc iputils \
;fi

# For Geo-rep, Prepare password less ssh
RUN mkdir -p /root/.ssh
RUN rm -rf .ssh/id_rsa*
RUN ssh-keygen -N "" -f /root/.ssh/id_rsa
RUN cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

ARG version="(unknown)"
# Container build time (date -u '+%Y-%m-%dT%H:%M:%S.%NZ')
ARG builddate="(unknown)"

LABEL build-date="${builddate}"
LABEL io.k8s.description="Glusterfs Tests"
LABEL name="glusterfs-tester-base"
LABEL Summary="GlusterFS Tester"
LABEL vcs-type="git"
LABEL vcs-url="https://github.com/gluster/glusterfs"
LABEL vendor="gluster"
LABEL version="${version}"

ENTRYPOINT ["tail", "-f", "/dev/null"]
2 changes: 1 addition & 1 deletion glustertester/scripts/build-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ function build_container()
exit 1
}

build_container "glusterfs-tester" "Dockerfile"
build_container $1 $2

0 comments on commit a2a1fa6

Please sign in to comment.