tests: fix builds on alpine and centos

Submitted by Adrian Reber on June 21, 2018, 8:50 p.m.

Details

Message ID 1529614253-7339-1-git-send-email-adrian@lisas.de
State New
Series "tests: fix builds on alpine and centos"
Headers show

Commit Message

Adrian Reber June 21, 2018, 8:50 p.m.
From: Adrian Reber <areber@redhat.com>

Install sudo, create test user with ID 1000, install bash,
fix pidfile creation and pidfile chmod.

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 scripts/build/Dockerfile.alpine | 7 ++++++-
 scripts/build/Dockerfile.centos | 1 +
 test/others/rpc/Makefile        | 4 +++-
 3 files changed, 10 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/build/Dockerfile.alpine b/scripts/build/Dockerfile.alpine
index a210d06..4163bce 100644
--- a/scripts/build/Dockerfile.alpine
+++ b/scripts/build/Dockerfile.alpine
@@ -4,6 +4,7 @@  ARG ENV1=FOOBAR
 
 RUN apk update && apk add \
 	$CC \
+	bash \
 	build-base \
 	ccache \
 	coreutils \
@@ -15,7 +16,8 @@  RUN apk update && apk add \
 	pkgconfig \
 	protobuf-c-dev \
 	protobuf-dev \
-	python
+	python \
+	sudo
 
 COPY . /criu
 WORKDIR /criu
@@ -37,5 +39,8 @@  RUN apk add \
 	e2fsprogs \
 	asciidoc xmlto
 
+# The rpc test cases are running as user #1000, let's add the user
+RUN adduser -u 1000 -D test
+
 RUN pip install protobuf ipaddress junit_xml
 RUN make -C test/zdtm
diff --git a/scripts/build/Dockerfile.centos b/scripts/build/Dockerfile.centos
index 5f84707..0160b75 100644
--- a/scripts/build/Dockerfile.centos
+++ b/scripts/build/Dockerfile.centos
@@ -27,6 +27,7 @@  RUN yum install -y \
 	python2-junit_xml \
 	python-yaml \
 	python-six \
+	sudo \
 	tar \
 	which \
 	e2fsprogs \
diff --git a/test/others/rpc/Makefile b/test/others/rpc/Makefile
index 5b383cf..f2a7710 100644
--- a/test/others/rpc/Makefile
+++ b/test/others/rpc/Makefile
@@ -7,9 +7,11 @@  LDLIBS +=  -lprotobuf-c
 run: all
 	mkdir -p build
 	chmod a+rwx build
+	@# Create pidfile first to chmod without waiting
+	touch build/pidfile
+	chmod a+rw build/pidfile
 	@# need to start the criu daemon here to access the pidfile
 	sudo -g '#1000' -u '#1000' ./criu service -v4 -W build -o service.log --address criu_service.socket -d --pidfile pidfile
-	chmod a+rw build/pidfile
 	sudo -g '#1000' -u '#1000' ./run.sh
 	sudo -g '#1000' -u '#1000' ./version.py
 

Comments

Adrian Reber June 21, 2018, 8:53 p.m.
This is a follow up on Cyrill's patch

 'tests: others,rpc -- Tune up header'

and tries to fix the build failures introduced by the rpc test case.

		Adrian

On Thu, Jun 21, 2018 at 08:50:53PM +0000, Adrian Reber wrote:
> From: Adrian Reber <areber@redhat.com>
> 
> Install sudo, create test user with ID 1000, install bash,
> fix pidfile creation and pidfile chmod.
> 
> Signed-off-by: Adrian Reber <areber@redhat.com>
> ---
>  scripts/build/Dockerfile.alpine | 7 ++++++-
>  scripts/build/Dockerfile.centos | 1 +
>  test/others/rpc/Makefile        | 4 +++-
>  3 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/build/Dockerfile.alpine b/scripts/build/Dockerfile.alpine
> index a210d06..4163bce 100644
> --- a/scripts/build/Dockerfile.alpine
> +++ b/scripts/build/Dockerfile.alpine
> @@ -4,6 +4,7 @@ ARG ENV1=FOOBAR
>  
>  RUN apk update && apk add \
>  	$CC \
> +	bash \
>  	build-base \
>  	ccache \
>  	coreutils \
> @@ -15,7 +16,8 @@ RUN apk update && apk add \
>  	pkgconfig \
>  	protobuf-c-dev \
>  	protobuf-dev \
> -	python
> +	python \
> +	sudo
>  
>  COPY . /criu
>  WORKDIR /criu
> @@ -37,5 +39,8 @@ RUN apk add \
>  	e2fsprogs \
>  	asciidoc xmlto
>  
> +# The rpc test cases are running as user #1000, let's add the user
> +RUN adduser -u 1000 -D test
> +
>  RUN pip install protobuf ipaddress junit_xml
>  RUN make -C test/zdtm
> diff --git a/scripts/build/Dockerfile.centos b/scripts/build/Dockerfile.centos
> index 5f84707..0160b75 100644
> --- a/scripts/build/Dockerfile.centos
> +++ b/scripts/build/Dockerfile.centos
> @@ -27,6 +27,7 @@ RUN yum install -y \
>  	python2-junit_xml \
>  	python-yaml \
>  	python-six \
> +	sudo \
>  	tar \
>  	which \
>  	e2fsprogs \
> diff --git a/test/others/rpc/Makefile b/test/others/rpc/Makefile
> index 5b383cf..f2a7710 100644
> --- a/test/others/rpc/Makefile
> +++ b/test/others/rpc/Makefile
> @@ -7,9 +7,11 @@ LDLIBS +=  -lprotobuf-c
>  run: all
>  	mkdir -p build
>  	chmod a+rwx build
> +	@# Create pidfile first to chmod without waiting
> +	touch build/pidfile
> +	chmod a+rw build/pidfile
>  	@# need to start the criu daemon here to access the pidfile
>  	sudo -g '#1000' -u '#1000' ./criu service -v4 -W build -o service.log --address criu_service.socket -d --pidfile pidfile
> -	chmod a+rw build/pidfile
>  	sudo -g '#1000' -u '#1000' ./run.sh
>  	sudo -g '#1000' -u '#1000' ./version.py
>  
> -- 
> 1.8.3.1
>
Adrian Reber June 21, 2018, 9:09 p.m.
This does not work. V2 on its way.

On Thu, Jun 21, 2018 at 10:53:27PM +0200, Adrian Reber wrote:
> This is a follow up on Cyrill's patch
> 
>  'tests: others,rpc -- Tune up header'
> 
> and tries to fix the build failures introduced by the rpc test case.
> 
> 		Adrian
> 
> On Thu, Jun 21, 2018 at 08:50:53PM +0000, Adrian Reber wrote:
> > From: Adrian Reber <areber@redhat.com>
> > 
> > Install sudo, create test user with ID 1000, install bash,
> > fix pidfile creation and pidfile chmod.
> > 
> > Signed-off-by: Adrian Reber <areber@redhat.com>
> > ---
> >  scripts/build/Dockerfile.alpine | 7 ++++++-
> >  scripts/build/Dockerfile.centos | 1 +
> >  test/others/rpc/Makefile        | 4 +++-
> >  3 files changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/scripts/build/Dockerfile.alpine b/scripts/build/Dockerfile.alpine
> > index a210d06..4163bce 100644
> > --- a/scripts/build/Dockerfile.alpine
> > +++ b/scripts/build/Dockerfile.alpine
> > @@ -4,6 +4,7 @@ ARG ENV1=FOOBAR
> >  
> >  RUN apk update && apk add \
> >  	$CC \
> > +	bash \
> >  	build-base \
> >  	ccache \
> >  	coreutils \
> > @@ -15,7 +16,8 @@ RUN apk update && apk add \
> >  	pkgconfig \
> >  	protobuf-c-dev \
> >  	protobuf-dev \
> > -	python
> > +	python \
> > +	sudo
> >  
> >  COPY . /criu
> >  WORKDIR /criu
> > @@ -37,5 +39,8 @@ RUN apk add \
> >  	e2fsprogs \
> >  	asciidoc xmlto
> >  
> > +# The rpc test cases are running as user #1000, let's add the user
> > +RUN adduser -u 1000 -D test
> > +
> >  RUN pip install protobuf ipaddress junit_xml
> >  RUN make -C test/zdtm
> > diff --git a/scripts/build/Dockerfile.centos b/scripts/build/Dockerfile.centos
> > index 5f84707..0160b75 100644
> > --- a/scripts/build/Dockerfile.centos
> > +++ b/scripts/build/Dockerfile.centos
> > @@ -27,6 +27,7 @@ RUN yum install -y \
> >  	python2-junit_xml \
> >  	python-yaml \
> >  	python-six \
> > +	sudo \
> >  	tar \
> >  	which \
> >  	e2fsprogs \
> > diff --git a/test/others/rpc/Makefile b/test/others/rpc/Makefile
> > index 5b383cf..f2a7710 100644
> > --- a/test/others/rpc/Makefile
> > +++ b/test/others/rpc/Makefile
> > @@ -7,9 +7,11 @@ LDLIBS +=  -lprotobuf-c
> >  run: all
> >  	mkdir -p build
> >  	chmod a+rwx build
> > +	@# Create pidfile first to chmod without waiting
> > +	touch build/pidfile
> > +	chmod a+rw build/pidfile
> >  	@# need to start the criu daemon here to access the pidfile
> >  	sudo -g '#1000' -u '#1000' ./criu service -v4 -W build -o service.log --address criu_service.socket -d --pidfile pidfile
> > -	chmod a+rw build/pidfile
> >  	sudo -g '#1000' -u '#1000' ./run.sh
> >  	sudo -g '#1000' -u '#1000' ./version.py
> >  
> > -- 
> > 1.8.3.1
> > 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
Andrei Vagin June 21, 2018, 9:11 p.m.
On Thu, Jun 21, 2018 at 08:50:53PM +0000, Adrian Reber wrote:
> From: Adrian Reber <areber@redhat.com>
> 
> Install sudo, create test user with ID 1000, install bash,
> fix pidfile creation and pidfile chmod.
> 
> Signed-off-by: Adrian Reber <areber@redhat.com>
> ---
>  scripts/build/Dockerfile.alpine | 7 ++++++-
>  scripts/build/Dockerfile.centos | 1 +
>  test/others/rpc/Makefile        | 4 +++-
>  3 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/build/Dockerfile.alpine b/scripts/build/Dockerfile.alpine
> index a210d06..4163bce 100644
> --- a/scripts/build/Dockerfile.alpine
> +++ b/scripts/build/Dockerfile.alpine
> @@ -4,6 +4,7 @@ ARG ENV1=FOOBAR
>  
>  RUN apk update && apk add \
>  	$CC \
> +	bash \
>  	build-base \
>  	ccache \
>  	coreutils \
> @@ -15,7 +16,8 @@ RUN apk update && apk add \
>  	pkgconfig \
>  	protobuf-c-dev \
>  	protobuf-dev \
> -	python
> +	python \
> +	sudo
>  
>  COPY . /criu
>  WORKDIR /criu
> @@ -37,5 +39,8 @@ RUN apk add \
>  	e2fsprogs \
>  	asciidoc xmlto
>  
> +# The rpc test cases are running as user #1000, let's add the user
> +RUN adduser -u 1000 -D test
> +
>  RUN pip install protobuf ipaddress junit_xml
>  RUN make -C test/zdtm
> diff --git a/scripts/build/Dockerfile.centos b/scripts/build/Dockerfile.centos
> index 5f84707..0160b75 100644
> --- a/scripts/build/Dockerfile.centos
> +++ b/scripts/build/Dockerfile.centos
> @@ -27,6 +27,7 @@ RUN yum install -y \
>  	python2-junit_xml \
>  	python-yaml \
>  	python-six \
> +	sudo \
>  	tar \
>  	which \
>  	e2fsprogs \
> diff --git a/test/others/rpc/Makefile b/test/others/rpc/Makefile
> index 5b383cf..f2a7710 100644
> --- a/test/others/rpc/Makefile
> +++ b/test/others/rpc/Makefile
> @@ -7,9 +7,11 @@ LDLIBS +=  -lprotobuf-c
>  run: all
>  	mkdir -p build
>  	chmod a+rwx build
> +	@# Create pidfile first to chmod without waiting
> +	touch build/pidfile
> +	chmod a+rw build/pidfile

I don't understand how it can work. pidfile is created with O_EXCL, so
it should fail if a file exists.

int write_pidfile(int pid)
{
        int fd;

        fd = open(opts.pidfile, O_WRONLY | O_EXCL | O_CREAT, 0600);

O_EXCL Ensure that this call creates the file: if this flag  is speci‐
      fied  in  conjunction with O_CREAT, and pathname already exists,
      then open() fails with the error EEXIST.


>  	@# need to start the criu daemon here to access the pidfile
>  	sudo -g '#1000' -u '#1000' ./criu service -v4 -W build -o service.log --address criu_service.socket -d --pidfile pidfile
> -	chmod a+rw build/pidfile
>  	sudo -g '#1000' -u '#1000' ./run.sh
>  	sudo -g '#1000' -u '#1000' ./version.py
>  
> -- 
> 1.8.3.1
>
Adrian Reber June 21, 2018, 9:33 p.m.
On Thu, Jun 21, 2018 at 02:11:17PM -0700, Andrei Vagin wrote:
> On Thu, Jun 21, 2018 at 08:50:53PM +0000, Adrian Reber wrote:
> > From: Adrian Reber <areber@redhat.com>
> > 
> > Install sudo, create test user with ID 1000, install bash,
> > fix pidfile creation and pidfile chmod.
> > 
> > Signed-off-by: Adrian Reber <areber@redhat.com>
> > ---
> >  scripts/build/Dockerfile.alpine | 7 ++++++-
> >  scripts/build/Dockerfile.centos | 1 +
> >  test/others/rpc/Makefile        | 4 +++-
> >  3 files changed, 10 insertions(+), 2 deletions(-)
[...]
> > diff --git a/test/others/rpc/Makefile b/test/others/rpc/Makefile
> > index 5b383cf..f2a7710 100644
> > --- a/test/others/rpc/Makefile
> > +++ b/test/others/rpc/Makefile
> > @@ -7,9 +7,11 @@ LDLIBS +=  -lprotobuf-c
> >  run: all
> >  	mkdir -p build
> >  	chmod a+rwx build
> > +	@# Create pidfile first to chmod without waiting
> > +	touch build/pidfile
> > +	chmod a+rw build/pidfile
> 
> I don't understand how it can work. pidfile is created with O_EXCL, so
> it should fail if a file exists.
> 
> int write_pidfile(int pid)
> {
>         int fd;
> 
>         fd = open(opts.pidfile, O_WRONLY | O_EXCL | O_CREAT, 0600);
> 
> O_EXCL Ensure that this call creates the file: if this flag  is speci‐
>       fied  in  conjunction with O_CREAT, and pathname already exists,
>       then open() fails with the error EEXIST.

It does not work :(. That is why I sent a V2. My local tests were wrong
and I was also surprised that it works. But travis already told me that
it was wrong. The V2 looks good for alpine in travis, still waiting for
the centos results.

		Adrian