[Libguestfs] [PATCH nbdkit] s3: Only run the tests if boto3 is installed

Richard W.M. Jones rjones at redhat.com
Tue May 17 11:03:49 UTC 2022


On Tue, May 17, 2022 at 12:50:53PM +0200, Laszlo Ersek wrote:
> On 05/17/22 12:11, Richard W.M. Jones wrote:
> > 
> > OK I see what's going on.
> > 
> > test-S3.sh uses the mocked boto3 in tests/test-S3/ to do an end-to-end
> > test (nbdcopy).
> > 
> > test-S3-unit.sh runs the unit tests within the plugin.  It's basically
> > testing the plugin as if it was a standalone Python script (without
> > nbdkit being involved).  This uses an internal MockS3Client class also
> > inside the plugin.
> > 
> > The second one does actually need real boto3, just because there's an
> > "import boto3" at the top and we don't set up PYTHONPATH to pick up
> > the tests/test-S3/ subdirectory.
> > 
> > We could either fix the second one by skipping it if (real) boto3
> > isn't installed, or by making it use the mocked boto3 from tests/test-S3/
> > 
> > Either approach would work, but the second one (below) seems maybe
> > better because we'd get more test coverage this way?
> 
> I think so, yes: from your description, "test-S3-unit.sh" seems "less
> demanding" than "test-S3.sh", so if the mocked module satisfies the
> latter, it should be good enough for the former too.
> 
> > 
> > Rich.
> > 
> > 
> > diff --git a/tests/test-S3-unit.sh b/tests/test-S3-unit.sh
> > index 6b6adf02..11718be3 100755
> > --- a/tests/test-S3-unit.sh
> > +++ b/tests/test-S3-unit.sh
> > @@ -44,6 +44,6 @@ if [ "$NBDKIT_VALGRIND" = "1" ]; then
> >      exit 77
> >  fi
> >  
> > -export PYTHONPATH=$srcdir/../plugins/S3:$PYTHONPATH
> > +export PYTHONPATH=$srcdir/../plugins/S3:$srcdir/test-S3:$PYTHONPATH
> >  
> >  $PYTHON -m unittest S3
> > 
> > 
> 
> For this hunk above:
> 
> Acked-by: Laszlo Ersek <lersek at redhat.com>

Thanks - committed as:

https://gitlab.com/nbdkit/nbdkit/-/commit/306f94a3c54a7a697e56978dee09d2f3816c2dc4

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top


More information about the Libguestfs mailing list