diff mbox series

[testsuite] travis: skip kernel update+reboot if it's not necessary

Message ID 20201030212108.112831-1-omosnace@redhat.com (mailing list archive)
State Accepted
Delegated to: Ondrej Mosnáček
Headers show
Series [testsuite] travis: skip kernel update+reboot if it's not necessary | expand

Commit Message

Ondrej Mosnacek Oct. 30, 2020, 9:21 p.m. UTC
Only do it when we can't install the kernel-modules package for the
running kernel to make the CI run faster. Now that rawhide images are
updating regularly again, it is rarely necessary.

Also don't run `dnf clean all -y` before installing dependencies. There
really is no point and it just slows things down when we do need to
update the kernel.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
 travis-ci/run-testsuite.sh |  1 -
 2 files changed, 12 insertions(+), 10 deletions(-)

Comments

William Roberts Oct. 30, 2020, 10:22 p.m. UTC | #1
On Fri, Oct 30, 2020 at 4:22 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> Only do it when we can't install the kernel-modules package for the
> running kernel to make the CI run faster. Now that rawhide images are
> updating regularly again, it is rarely necessary.
>
> Also don't run `dnf clean all -y` before installing dependencies. There
> really is no point and it just slows things down when we do need to
> update the kernel.
>
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
>  travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
>  travis-ci/run-testsuite.sh |  1 -
>  2 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/travis-ci/run-kvm-test.sh b/travis-ci/run-kvm-test.sh
> index d22c92b..6afbf96 100755
> --- a/travis-ci/run-kvm-test.sh
> +++ b/travis-ci/run-kvm-test.sh
> @@ -121,15 +121,18 @@ fi
>  # so forks know where to go.
>  #
>
> -# First update to the latest kernel.
> -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> -    dnf install -y kernel
> -
> -# Then reboot.
> -sudo virsh reboot fedoravm
> -sleep 5
> -
> -while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> +# Check if kernel-modules-$(uname -r) can be installed from repos,
> +# otherwise update kernel and reboot.
> +kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
> +    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
> +if [ $kernel_avail -eq 0 ]; then
> +    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> +        dnf update -y kernel-core
> +
> +    sudo virsh reboot fedoravm
> +    sleep 5
> +    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> +fi
>
>  # And run the testsuite.
>  project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh
> index 9b5f954..051f9d8 100755
> --- a/travis-ci/run-testsuite.sh
> +++ b/travis-ci/run-testsuite.sh
> @@ -16,7 +16,6 @@ pwd
>  # the CI.
>  setenforce 0
>
> -dnf clean all -y
>  dnf install -y \
>      --allowerasing \
>      --skip-broken \
> --
> 2.26.2
>

Ack
Ondrej Mosnacek Oct. 31, 2020, 10:37 a.m. UTC | #2
On Fri, Oct 30, 2020 at 11:22 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
> On Fri, Oct 30, 2020 at 4:22 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > Only do it when we can't install the kernel-modules package for the
> > running kernel to make the CI run faster. Now that rawhide images are
> > updating regularly again, it is rarely necessary.
> >
> > Also don't run `dnf clean all -y` before installing dependencies. There
> > really is no point and it just slows things down when we do need to
> > update the kernel.
> >
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > ---
> >  travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
> >  travis-ci/run-testsuite.sh |  1 -
> >  2 files changed, 12 insertions(+), 10 deletions(-)
> >
> > diff --git a/travis-ci/run-kvm-test.sh b/travis-ci/run-kvm-test.sh
> > index d22c92b..6afbf96 100755
> > --- a/travis-ci/run-kvm-test.sh
> > +++ b/travis-ci/run-kvm-test.sh
> > @@ -121,15 +121,18 @@ fi
> >  # so forks know where to go.
> >  #
> >
> > -# First update to the latest kernel.
> > -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> > -    dnf install -y kernel
> > -
> > -# Then reboot.
> > -sudo virsh reboot fedoravm
> > -sleep 5
> > -
> > -while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> > +# Check if kernel-modules-$(uname -r) can be installed from repos,
> > +# otherwise update kernel and reboot.
> > +kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
> > +    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
> > +if [ $kernel_avail -eq 0 ]; then
> > +    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> > +        dnf update -y kernel-core
> > +
> > +    sudo virsh reboot fedoravm
> > +    sleep 5
> > +    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> > +fi
> >
> >  # And run the testsuite.
> >  project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> > diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh
> > index 9b5f954..051f9d8 100755
> > --- a/travis-ci/run-testsuite.sh
> > +++ b/travis-ci/run-testsuite.sh
> > @@ -16,7 +16,6 @@ pwd
> >  # the CI.
> >  setenforce 0
> >
> > -dnf clean all -y
> >  dnf install -y \
> >      --allowerasing \
> >      --skip-broken \
> > --
> > 2.26.2
> >
>
> Ack

Thanks, but I'm not sure if you realized that this is a patch for the
testsuite CI, not the userspace one :) Can I still add you ack?

Note that userspace CI doesn't need the kernel update + reboot (nor
this patch), as it doesn't test on development images.
William Roberts Oct. 31, 2020, 1:55 p.m. UTC | #3
On Sat, Oct 31, 2020 at 5:37 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> On Fri, Oct 30, 2020 at 11:22 PM William Roberts
> <bill.c.roberts@gmail.com> wrote:
> > On Fri, Oct 30, 2020 at 4:22 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> > >
> > > Only do it when we can't install the kernel-modules package for the
> > > running kernel to make the CI run faster. Now that rawhide images are
> > > updating regularly again, it is rarely necessary.
> > >
> > > Also don't run `dnf clean all -y` before installing dependencies. There
> > > really is no point and it just slows things down when we do need to
> > > update the kernel.
> > >
> > > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > > ---
> > >  travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
> > >  travis-ci/run-testsuite.sh |  1 -
> > >  2 files changed, 12 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/travis-ci/run-kvm-test.sh b/travis-ci/run-kvm-test.sh
> > > index d22c92b..6afbf96 100755
> > > --- a/travis-ci/run-kvm-test.sh
> > > +++ b/travis-ci/run-kvm-test.sh
> > > @@ -121,15 +121,18 @@ fi
> > >  # so forks know where to go.
> > >  #
> > >
> > > -# First update to the latest kernel.
> > > -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> > > -    dnf install -y kernel
> > > -
> > > -# Then reboot.
> > > -sudo virsh reboot fedoravm
> > > -sleep 5
> > > -
> > > -while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> > > +# Check if kernel-modules-$(uname -r) can be installed from repos,
> > > +# otherwise update kernel and reboot.
> > > +kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
> > > +    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
> > > +if [ $kernel_avail -eq 0 ]; then
> > > +    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> > > +        dnf update -y kernel-core
> > > +
> > > +    sudo virsh reboot fedoravm
> > > +    sleep 5
> > > +    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> > > +fi
> > >
> > >  # And run the testsuite.
> > >  project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> > > diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh
> > > index 9b5f954..051f9d8 100755
> > > --- a/travis-ci/run-testsuite.sh
> > > +++ b/travis-ci/run-testsuite.sh
> > > @@ -16,7 +16,6 @@ pwd
> > >  # the CI.
> > >  setenforce 0
> > >
> > > -dnf clean all -y
> > >  dnf install -y \
> > >      --allowerasing \
> > >      --skip-broken \
> > > --
> > > 2.26.2
> > >
> >
> > Ack
>
> Thanks, but I'm not sure if you realized that this is a patch for the
> testsuite CI, not the userspace one :) Can I still add you ack?
>
> Note that userspace CI doesn't need the kernel update + reboot (nor
> this patch), as it doesn't test on development images.
>

Well aware, thanks. That ack really means reviewed by and tested by lines.
I was just being lazy.

I've been following the testsuite project closely as selinux now depends on it
in it's CI. I wouldn't be opposed to being a miantiner for the testsuite either.

Thanks for your work on this BTW, glad to see that KVM paradigm
getting used more.

Bill
Ondrej Mosnacek Oct. 31, 2020, 4:27 p.m. UTC | #4
On Sat, Oct 31, 2020 at 2:55 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
> On Sat, Oct 31, 2020 at 5:37 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > On Fri, Oct 30, 2020 at 11:22 PM William Roberts
> > <bill.c.roberts@gmail.com> wrote:
> > > On Fri, Oct 30, 2020 at 4:22 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> > > >
> > > > Only do it when we can't install the kernel-modules package for the
> > > > running kernel to make the CI run faster. Now that rawhide images are
> > > > updating regularly again, it is rarely necessary.
> > > >
> > > > Also don't run `dnf clean all -y` before installing dependencies. There
> > > > really is no point and it just slows things down when we do need to
> > > > update the kernel.
> > > >
> > > > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > > > ---
> > > >  travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
> > > >  travis-ci/run-testsuite.sh |  1 -
> > > >  2 files changed, 12 insertions(+), 10 deletions(-)
> > > >
> > > > diff --git a/travis-ci/run-kvm-test.sh b/travis-ci/run-kvm-test.sh
> > > > index d22c92b..6afbf96 100755
> > > > --- a/travis-ci/run-kvm-test.sh
> > > > +++ b/travis-ci/run-kvm-test.sh
> > > > @@ -121,15 +121,18 @@ fi
> > > >  # so forks know where to go.
> > > >  #
> > > >
> > > > -# First update to the latest kernel.
> > > > -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> > > > -    dnf install -y kernel
> > > > -
> > > > -# Then reboot.
> > > > -sudo virsh reboot fedoravm
> > > > -sleep 5
> > > > -
> > > > -while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> > > > +# Check if kernel-modules-$(uname -r) can be installed from repos,
> > > > +# otherwise update kernel and reboot.
> > > > +kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
> > > > +    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
> > > > +if [ $kernel_avail -eq 0 ]; then
> > > > +    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> > > > +        dnf update -y kernel-core
> > > > +
> > > > +    sudo virsh reboot fedoravm
> > > > +    sleep 5
> > > > +    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> > > > +fi
> > > >
> > > >  # And run the testsuite.
> > > >  project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> > > > diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh
> > > > index 9b5f954..051f9d8 100755
> > > > --- a/travis-ci/run-testsuite.sh
> > > > +++ b/travis-ci/run-testsuite.sh
> > > > @@ -16,7 +16,6 @@ pwd
> > > >  # the CI.
> > > >  setenforce 0
> > > >
> > > > -dnf clean all -y
> > > >  dnf install -y \
> > > >      --allowerasing \
> > > >      --skip-broken \
> > > > --
> > > > 2.26.2
> > > >
> > >
> > > Ack
> >
> > Thanks, but I'm not sure if you realized that this is a patch for the
> > testsuite CI, not the userspace one :) Can I still add you ack?
> >
> > Note that userspace CI doesn't need the kernel update + reboot (nor
> > this patch), as it doesn't test on development images.
> >
>
> Well aware, thanks. That ack really means reviewed by and tested by lines.
> I was just being lazy.

Ok, great!

> I've been following the testsuite project closely as selinux now depends on it
> in it's CI. I wouldn't be opposed to being a miantiner for the testsuite either.

Even greater :) Paul, Stephen, do we want to make Bill another
testsuite maintainer? It seems I don't have permission to add people
to the GH team, so one of you would have to do it.

> Thanks for your work on this BTW, glad to see that KVM paradigm
> getting used more.

Yeah, it's cool and it makes maintaining the testsuite so much easier.
But you don't need to thank me, you're the one who started it all :)
Ondrej Mosnacek Oct. 31, 2020, 4:54 p.m. UTC | #5
On Fri, Oct 30, 2020 at 11:22 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
>
> On Fri, Oct 30, 2020 at 4:22 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > Only do it when we can't install the kernel-modules package for the
> > running kernel to make the CI run faster. Now that rawhide images are
> > updating regularly again, it is rarely necessary.
> >
> > Also don't run `dnf clean all -y` before installing dependencies. There
> > really is no point and it just slows things down when we do need to
> > update the kernel.
> >
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > ---
> >  travis-ci/run-kvm-test.sh  | 21 ++++++++++++---------
> >  travis-ci/run-testsuite.sh |  1 -
> >  2 files changed, 12 insertions(+), 10 deletions(-)
> >
> > diff --git a/travis-ci/run-kvm-test.sh b/travis-ci/run-kvm-test.sh
> > index d22c92b..6afbf96 100755
> > --- a/travis-ci/run-kvm-test.sh
> > +++ b/travis-ci/run-kvm-test.sh
> > @@ -121,15 +121,18 @@ fi
> >  # so forks know where to go.
> >  #
> >
> > -# First update to the latest kernel.
> > -ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> > -    dnf install -y kernel
> > -
> > -# Then reboot.
> > -sudo virsh reboot fedoravm
> > -sleep 5
> > -
> > -while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> > +# Check if kernel-modules-$(uname -r) can be installed from repos,
> > +# otherwise update kernel and reboot.
> > +kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
> > +    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
> > +if [ $kernel_avail -eq 0 ]; then
> > +    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
> > +        dnf update -y kernel-core
> > +
> > +    sudo virsh reboot fedoravm
> > +    sleep 5
> > +    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
> > +fi
> >
> >  # And run the testsuite.
> >  project_dir="$(basename "$TRAVIS_BUILD_DIR")"
> > diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh
> > index 9b5f954..051f9d8 100755
> > --- a/travis-ci/run-testsuite.sh
> > +++ b/travis-ci/run-testsuite.sh
> > @@ -16,7 +16,6 @@ pwd
> >  # the CI.
> >  setenforce 0
> >
> > -dnf clean all -y
> >  dnf install -y \
> >      --allowerasing \
> >      --skip-broken \
> > --
> > 2.26.2
> >
>
> Ack

And I just applied this one as well:
https://github.com/SELinuxProject/selinux-testsuite/commit/69d9e8bd648ace3516d6da7e51a2fd6e012538b1
diff mbox series

Patch

diff --git a/travis-ci/run-kvm-test.sh b/travis-ci/run-kvm-test.sh
index d22c92b..6afbf96 100755
--- a/travis-ci/run-kvm-test.sh
+++ b/travis-ci/run-kvm-test.sh
@@ -121,15 +121,18 @@  fi
 # so forks know where to go.
 #
 
-# First update to the latest kernel.
-ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
-    dnf install -y kernel
-
-# Then reboot.
-sudo virsh reboot fedoravm
-sleep 5
-
-while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+# Check if kernel-modules-$(uname -r) can be installed from repos,
+# otherwise update kernel and reboot.
+kernel_avail="$(ssh -tt -o StrictHostKeyChecking=no -q "root@$ipaddy" \
+    sh -c "dnf check-update kernel-modules-\$(uname -r) | wc -l")"
+if [ $kernel_avail -eq 0 ]; then
+    ssh -tt -o StrictHostKeyChecking=no -o LogLevel=QUIET "root@$ipaddy" \
+        dnf update -y kernel-core
+
+    sudo virsh reboot fedoravm
+    sleep 5
+    while ! nc -w 10 -z "$ipaddy" 22; do sleep 0.5s; done
+fi
 
 # And run the testsuite.
 project_dir="$(basename "$TRAVIS_BUILD_DIR")"
diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh
index 9b5f954..051f9d8 100755
--- a/travis-ci/run-testsuite.sh
+++ b/travis-ci/run-testsuite.sh
@@ -16,7 +16,6 @@  pwd
 # the CI.
 setenforce 0
 
-dnf clean all -y
 dnf install -y \
     --allowerasing \
     --skip-broken \