From 91574b53d9b823697dfbbf2c75e4c1c24066a94a Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Tue, 17 May 2022 17:48:38 -0500 Subject: [PATCH] Add functional tests for Azure publishing Signed-off-by: Ryan Gonzalez --- system/azure_lib.py | 110 ++++++++++ system/requirements.txt | 1 + system/run.py | 4 +- system/t06_publish/AzurePublish1Test_binary | 27 +++ system/t06_publish/AzurePublish1Test_gold | 13 ++ system/t06_publish/AzurePublish1Test_release | 11 + system/t06_publish/AzurePublish1Test_sources | 57 +++++ system/t06_publish/AzurePublish2Test_binary | 27 +++ system/t06_publish/AzurePublish2Test_gold | 8 + system/t06_publish/AzurePublish2Test_release | 11 + system/t06_publish/AzurePublish2Test_sources | 0 system/t06_publish/AzurePublish3Test_binary | 30 +++ system/t06_publish/AzurePublish3Test_gold | 8 + system/t06_publish/AzurePublish3Test_release | 11 + system/t06_publish/AzurePublish4Test_gold | 4 + system/t06_publish/AzurePublish5Test_gold | 3 + system/t06_publish/azure.py | 211 +++++++++++++++++++ 17 files changed, 535 insertions(+), 1 deletion(-) create mode 100644 system/azure_lib.py create mode 100644 system/t06_publish/AzurePublish1Test_binary create mode 100644 system/t06_publish/AzurePublish1Test_gold create mode 100644 system/t06_publish/AzurePublish1Test_release create mode 100644 system/t06_publish/AzurePublish1Test_sources create mode 100644 system/t06_publish/AzurePublish2Test_binary create mode 100644 system/t06_publish/AzurePublish2Test_gold create mode 100644 system/t06_publish/AzurePublish2Test_release create mode 100644 system/t06_publish/AzurePublish2Test_sources create mode 100644 system/t06_publish/AzurePublish3Test_binary create mode 100644 system/t06_publish/AzurePublish3Test_gold create mode 100644 system/t06_publish/AzurePublish3Test_release create mode 100644 system/t06_publish/AzurePublish4Test_gold create mode 100644 system/t06_publish/AzurePublish5Test_gold create mode 100644 system/t06_publish/azure.py diff --git a/system/azure_lib.py b/system/azure_lib.py new file mode 100644 index 00000000..97cd7740 --- /dev/null +++ b/system/azure_lib.py @@ -0,0 +1,110 @@ +from lib import BaseTest +import uuid +import os + +try: + from azure.storage.blob import BlobServiceClient + + azure_storage_account = os.environ.get('AZURE_STORAGE_ACCOUNT') + azure_storage_access_key = os.environ.get('AZURE_STORAGE_ACCESS_KEY') + azure_storage_endpoint = os.environ.get( + 'AZURE_STORAGE_ENDPOINT', + f'https://{azure_storage_account}.blob.core.windows.net', + ) + if azure_storage_account is not None and azure_storage_access_key is not None: + blob_client = BlobServiceClient( + account_url=azure_storage_endpoint, + credential=azure_storage_access_key, + ) + else: + print('Azure tests disabled: Azure creds not found in the environment') + blob_client = None +except ImportError as e: + print("Azure tests disabled: can't import azure.storage.blob", e) + blob_client = None + + +class AzureTest(BaseTest): + """ + BaseTest + support for Azure Blob Storage + """ + + use_azure_pool = False + + def __init__(self) -> None: + super(AzureTest, self).__init__() + self.container_name = None + self.container = None + self.container_contents = None + + def fixture_available(self): + return super(AzureTest, self).fixture_available() and blob_client is not None + + def prepare(self): + self.container_name = 'aptly-sys-test-' + str(uuid.uuid1()) + self.container = blob_client.create_container( + self.container_name, public_access='blob' + ) + + self.azure_endpoint = { + 'accountName': azure_storage_account, + 'accountKey': azure_storage_access_key, + 'container': self.container_name, + 'endpoint': azure_storage_endpoint, + } + + self.configOverride = { + 'AzurePublishEndpoints': { + 'test1': self.azure_endpoint, + }, + } + if self.use_azure_pool: + self.configOverride['packagePoolStorage'] = { + 'azure': self.azure_endpoint, + } + + super(AzureTest, self).prepare() + + def shutdown(self): + if self.container_name is not None: + blob_client.delete_container(self.container_name) + + super(AzureTest, self).shutdown() + + def check_path(self, path): + if self.container_contents is None: + self.container_contents = [ + p.name for p in self.container.list_blobs() if p.name is not None + ] + + if path.startswith('public/'): + path = path[7:] + + if path in self.container_contents: + return True + + if not path.endswith('/'): + path = path + '/' + + for item in self.container_contents: + if item.startswith(path): + return True + + return False + + def check_exists(self, path): + if not self.check_path(path): + raise Exception("path %s doesn't exist" % (path,)) + + def check_not_exists(self, path): + if self.check_path(path): + raise Exception('path %s exists' % (path,)) + + def read_file(self, path, mode=''): + assert not mode + + if path.startswith('public/'): + path = path[7:] + + blob = self.container.download_blob(path) + return blob.readall().decode('utf-8') diff --git a/system/requirements.txt b/system/requirements.txt index 39b43f15..33ed79c2 100644 --- a/system/requirements.txt +++ b/system/requirements.txt @@ -1,3 +1,4 @@ +azure-storage-blob boto requests==2.28.2 requests-unixsocket diff --git a/system/run.py b/system/run.py index 39a14661..bd6de289 100755 --- a/system/run.py +++ b/system/run.py @@ -15,6 +15,7 @@ import subprocess from lib import BaseTest from s3_lib import S3Test from swift_lib import SwiftTest +from azure_lib import AzureTest from api_lib import APITest from fs_endpoint_lib import FileSystemEndpointTest @@ -82,7 +83,8 @@ def run(include_long_tests=False, capture_results=False, tests=None, filters=Non o = getattr(testModule, name) if not (inspect.isclass(o) and issubclass(o, BaseTest) and o is not BaseTest and - o is not SwiftTest and o is not S3Test and o is not APITest and o is not FileSystemEndpointTest): + o is not SwiftTest and o is not S3Test and o is not AzureTest and + o is not APITest and o is not FileSystemEndpointTest): continue newBase = o.__bases__[0] diff --git a/system/t06_publish/AzurePublish1Test_binary b/system/t06_publish/AzurePublish1Test_binary new file mode 100644 index 00000000..1fd182e4 --- /dev/null +++ b/system/t06_publish/AzurePublish1Test_binary @@ -0,0 +1,27 @@ + + + (name, value) pairs from the user, via conventional methods such as + . + . + Boost version (currently 1.49). + Library to let program developers obtain program options, that is + This package forms part of the Boost C++ Libraries collection. + This package is a dependency package, which depends on Debian's default + command line and config file. +Architecture: i386 +Depends: libboost-program-options1.49-dev +Description: program options library for C++ (default version) +Filename: pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb +Homepage: http://www.boost.org/libs/program_options/ +Installed-Size: 26 +MD5sum: 0035d7822b2f8f0ec4013f270fd650c2 +Maintainer: Debian Boost Team +Package: libboost-program-options-dev +Priority: optional +SHA1: 36895eb64cfe89c33c0a2f7ac2f0c6e0e889e04b +SHA256: c76b4bd12fd92e4dfe1b55b18a67a669d92f62985d6a96c8a21d96120982cf12 +SHA512: d7302241373da972aa9b9e71d2fd769b31a38f71182aa71bc0d69d090d452c69bb74b8612c002ccf8a89c279ced84ac27177c8b92d20f00023b3d268e6cec69c +Section: libdevel +Size: 2738 +Source: boost-defaults +Version: 1.49.0.1 \ No newline at end of file diff --git a/system/t06_publish/AzurePublish1Test_gold b/system/t06_publish/AzurePublish1Test_gold new file mode 100644 index 00000000..b65701eb --- /dev/null +++ b/system/t06_publish/AzurePublish1Test_gold @@ -0,0 +1,13 @@ +Loading packages... +Generating metadata files and linking package files... +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: + +Local repo local-repo has been successfully published. +Now you can add following line to apt sources: + deb http://your-server/ maverick main + deb-src http://your-server/ maverick main +Don't forget to add your GPG key to apt with apt-key. + +You can also use `aptly serve` to publish your repositories over HTTP quickly. diff --git a/system/t06_publish/AzurePublish1Test_release b/system/t06_publish/AzurePublish1Test_release new file mode 100644 index 00000000..78154c5b --- /dev/null +++ b/system/t06_publish/AzurePublish1Test_release @@ -0,0 +1,11 @@ +Origin: . maverick +Label: . maverick +Suite: maverick +Codename: maverick +Architectures: i386 +Components: main +Description: Generated by aptly +MD5Sum: +SHA1: +SHA256: +SHA512: diff --git a/system/t06_publish/AzurePublish1Test_sources b/system/t06_publish/AzurePublish1Test_sources new file mode 100644 index 00000000..f561df83 --- /dev/null +++ b/system/t06_publish/AzurePublish1Test_sources @@ -0,0 +1,57 @@ + + + + 22ff26db69b73d3438fdde21ab5ba2f1 3456 pyspi_0.6.1-1.3.diff.gz + 22ff26db69b73d3438fdde21ab5ba2f1 3456 pyspi_0.6.1-1.3.diff.gz + 262cac59a2e81c7f110851ff9670c97ffc3d192d9937b880422a0907f26340d43e7de7e68b904a4fb10bedb02b65c3bd1f7bdd20ea8c4293e690e7a8e0e70ee5 893 pyspi-0.6.1-1.3.stripped.dsc + 289d3aefa970876e9c43686ce2b02f478d7f3ed35a713928464a98d54ae4fca3 893 pyspi-0.6.1-1.3.stripped.dsc + 2e770b28df948f3197ed0b679bdea99f3f2bf745e9ddb440c677df9c3aeaee3c 3456 pyspi_0.6.1-1.3.diff.gz + 2e770b28df948f3197ed0b679bdea99f3f2bf745e9ddb440c677df9c3aeaee3c 3456 pyspi_0.6.1-1.3.diff.gz + 2f5bd47cf38852b6fc927a50f98c1448 893 pyspi-0.6.1-1.3.stripped.dsc + 384b5e94b4113262e41bda1a2563f4f439cb8c97f43e2caefe16d7626718c21b36d3145b915eed24053eaa7fe3b6186494a87a3fcf9627f6e653b54bb3caa897 3456 pyspi_0.6.1-1.3.diff.gz + 384b5e94b4113262e41bda1a2563f4f439cb8c97f43e2caefe16d7626718c21b36d3145b915eed24053eaa7fe3b6186494a87a3fcf9627f6e653b54bb3caa897 3456 pyspi_0.6.1-1.3.diff.gz + 5005fbd1f30637edc1d380b30f45db9b79100d07 893 pyspi-0.6.1-1.3.stripped.dsc + 56c8a9b1f4ab636052be8966690998cbe865cd6c 1782 pyspi_0.6.1-1.3.dsc + 64069ee828c50b1c597d10a3fefbba279f093a4723965388cdd0ac02f029bfb9 29063 pyspi_0.6.1.orig.tar.gz + 64069ee828c50b1c597d10a3fefbba279f093a4723965388cdd0ac02f029bfb9 29063 pyspi_0.6.1.orig.tar.gz + 95a2468e4bbce730ba286f2211fa41861b9f1d90 3456 pyspi_0.6.1-1.3.diff.gz + 95a2468e4bbce730ba286f2211fa41861b9f1d90 3456 pyspi_0.6.1-1.3.diff.gz + 9694b80acc171c0a5bc99f707933864edfce555e 29063 pyspi_0.6.1.orig.tar.gz + 9694b80acc171c0a5bc99f707933864edfce555e 29063 pyspi_0.6.1.orig.tar.gz + b72cb94699298a117b7c82641c68b6fd 1782 pyspi_0.6.1-1.3.dsc + c278f52953203292bcc828bcf05aee456b160f91716f51ec1a1dbbcdb8b08fc29183d0a1135629fc0ebe86a3e84cedc685c3aa1714b70cc5db8877d40e754d7f 29063 pyspi_0.6.1.orig.tar.gz + c278f52953203292bcc828bcf05aee456b160f91716f51ec1a1dbbcdb8b08fc29183d0a1135629fc0ebe86a3e84cedc685c3aa1714b70cc5db8877d40e754d7f 29063 pyspi_0.6.1.orig.tar.gz + d494aaf526f1ec6b02f14c2f81e060a5722d6532ddc760ec16972e45c2625989 1782 pyspi_0.6.1-1.3.dsc + def336bd566ea688a06ec03db7ccf1f4 29063 pyspi_0.6.1.orig.tar.gz + def336bd566ea688a06ec03db7ccf1f4 29063 pyspi_0.6.1.orig.tar.gz + fde06b7dc5762a04986d0669420822f6a1e82b195322ae9cbd2dae40bda557c57ad77fe3546007ea645f801c4cd30ef4eb0e96efb2dee6b71c4c9a187d643683 1782 pyspi_0.6.1-1.3.dsc +Architecture: any +Architecture: any +Binary: python-at-spi +Binary: python-at-spi +Build-Depends: debhelper (>= 5), cdbs, libatspi-dev, python-pyrex, python-support (>= 0.4), python-all-dev, libx11-dev +Build-Depends: debhelper (>= 5), cdbs, libatspi-dev, python-pyrex, python-support (>= 0.4), python-all-dev, libx11-dev +Checksums-Sha1: +Checksums-Sha1: +Checksums-Sha256: +Checksums-Sha256: +Checksums-Sha512: +Checksums-Sha512: +Directory: pool/main/p/pyspi +Directory: pool/main/p/pyspi +Files: +Files: +Format: 1.0 +Format: 1.0 +Homepage: http://people.redhat.com/zcerza/dogtail +Homepage: http://people.redhat.com/zcerza/dogtail +Maintainer: Jose Carlos Garcia Sogo +Maintainer: Jose Carlos Garcia Sogo +Package: pyspi +Package: pyspi +Standards-Version: 3.7.3 +Standards-Version: 3.7.3 +Vcs-Svn: svn://svn.tribulaciones.org/srv/svn/pyspi/trunk +Vcs-Svn: svn://svn.tribulaciones.org/srv/svn/pyspi/trunk +Version: 0.6.1-1.3 +Version: 0.6.1-1.4 \ No newline at end of file diff --git a/system/t06_publish/AzurePublish2Test_binary b/system/t06_publish/AzurePublish2Test_binary new file mode 100644 index 00000000..1fd182e4 --- /dev/null +++ b/system/t06_publish/AzurePublish2Test_binary @@ -0,0 +1,27 @@ + + + (name, value) pairs from the user, via conventional methods such as + . + . + Boost version (currently 1.49). + Library to let program developers obtain program options, that is + This package forms part of the Boost C++ Libraries collection. + This package is a dependency package, which depends on Debian's default + command line and config file. +Architecture: i386 +Depends: libboost-program-options1.49-dev +Description: program options library for C++ (default version) +Filename: pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb +Homepage: http://www.boost.org/libs/program_options/ +Installed-Size: 26 +MD5sum: 0035d7822b2f8f0ec4013f270fd650c2 +Maintainer: Debian Boost Team +Package: libboost-program-options-dev +Priority: optional +SHA1: 36895eb64cfe89c33c0a2f7ac2f0c6e0e889e04b +SHA256: c76b4bd12fd92e4dfe1b55b18a67a669d92f62985d6a96c8a21d96120982cf12 +SHA512: d7302241373da972aa9b9e71d2fd769b31a38f71182aa71bc0d69d090d452c69bb74b8612c002ccf8a89c279ced84ac27177c8b92d20f00023b3d268e6cec69c +Section: libdevel +Size: 2738 +Source: boost-defaults +Version: 1.49.0.1 \ No newline at end of file diff --git a/system/t06_publish/AzurePublish2Test_gold b/system/t06_publish/AzurePublish2Test_gold new file mode 100644 index 00000000..d9fa9ada --- /dev/null +++ b/system/t06_publish/AzurePublish2Test_gold @@ -0,0 +1,8 @@ +Loading packages... +Generating metadata files and linking package files... +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: +Cleaning up prefix "." components main... + +Publish for local repo azure:test1:./maverick [i386, source] publishes {main: [local-repo]} has been successfully updated. diff --git a/system/t06_publish/AzurePublish2Test_release b/system/t06_publish/AzurePublish2Test_release new file mode 100644 index 00000000..78154c5b --- /dev/null +++ b/system/t06_publish/AzurePublish2Test_release @@ -0,0 +1,11 @@ +Origin: . maverick +Label: . maverick +Suite: maverick +Codename: maverick +Architectures: i386 +Components: main +Description: Generated by aptly +MD5Sum: +SHA1: +SHA256: +SHA512: diff --git a/system/t06_publish/AzurePublish2Test_sources b/system/t06_publish/AzurePublish2Test_sources new file mode 100644 index 00000000..e69de29b diff --git a/system/t06_publish/AzurePublish3Test_binary b/system/t06_publish/AzurePublish3Test_binary new file mode 100644 index 00000000..aea5c35d --- /dev/null +++ b/system/t06_publish/AzurePublish3Test_binary @@ -0,0 +1,30 @@ + + + . + . + C-like language. Can perform smoothing, spline-fitting, or nonlinear fits, + Data files and self-defined functions can be manipulated by the internal + Gnuplot is a portable command-line driven interactive data and function + This package contains the terminal driver that enables gnuplot to plot + and can work with complex numbers. + for many printers, (La)TeX, (x)fig, Postscript, and so on. The X11-output + gnuplot. + images interactively under X11. Most users will want this, it is however + is packaged in gnuplot-x11. + packaged separately so that low-end systems don't need X installed to use + plotting utility that supports lots of output formats, including drivers +Architecture: i386 +Depends: gnuplot-nox (>= 4.6.1-1~maverick2), libc6 (>= 2.11), libcairo2 (>= 1.6.0), libedit2 (>= 2.5.cvs.20010821-1), libgcc1 (>= 1:4.1.1), libgd2-noxpm (>= 2.0.36~rc1~dfsg) | libgd2-xpm (>= 2.0.36~rc1~dfsg), libglib2.0-0 (>= 2.12.0), liblua5.1-0, libpango1.0-0 (>= 1.14.0), libstdc++6 (>= 4.1.1), libwxbase2.8-0 (>= 2.8.11.0), libwxgtk2.8-0 (>= 2.8.11.0), libx11-6 +Description: Command-line driven interactive plotting program +Filename: pool/main/g/gnuplot/gnuplot-x11_4.6.1-1~maverick2_i386.deb +Installed-Size: 1604 +MD5sum: fcad938905d0ace50a6ce0c73b2c6583 +Maintainer: Debian Science Team +Package: gnuplot-x11 +Priority: optional +Replaces: gnuplot (<< 4.0.0) +SHA1: 02f9a93097a8f798a054e26154dbe5789088c069 +Section: math +Size: 724388 +Source: gnuplot +Version: 4.6.1-1~maverick2 \ No newline at end of file diff --git a/system/t06_publish/AzurePublish3Test_gold b/system/t06_publish/AzurePublish3Test_gold new file mode 100644 index 00000000..fbcd2e79 --- /dev/null +++ b/system/t06_publish/AzurePublish3Test_gold @@ -0,0 +1,8 @@ +Loading packages... +Generating metadata files and linking package files... +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: +Cleaning up prefix "." components main... + +Publish for snapshot azure:test1:./maverick (origin: LP-PPA-gladky-anton-gnuplot) [amd64, i386] publishes {main: [snap3]: Pulled into 'snap2' with 'snap1' as source, pull request was: 'gnuplot-x11'} has been successfully switched to new snapshot. diff --git a/system/t06_publish/AzurePublish3Test_release b/system/t06_publish/AzurePublish3Test_release new file mode 100644 index 00000000..91ff3759 --- /dev/null +++ b/system/t06_publish/AzurePublish3Test_release @@ -0,0 +1,11 @@ +Origin: LP-PPA-gladky-anton-gnuplot +Label: . maverick +Suite: maverick +Codename: maverick +Architectures: amd64 i386 +Components: main +Description: Generated by aptly +MD5Sum: +SHA1: +SHA256: +SHA512: diff --git a/system/t06_publish/AzurePublish4Test_gold b/system/t06_publish/AzurePublish4Test_gold new file mode 100644 index 00000000..b5d583c1 --- /dev/null +++ b/system/t06_publish/AzurePublish4Test_gold @@ -0,0 +1,4 @@ +Published repositories: + * azure:test1:./maverick [amd64, i386] publishes {main: [local-repo]} + * azure:test1:./xyz [amd64, i386] publishes {main: [local-repo]} + * azure:test1:prefix/maverick [amd64, i386] publishes {main: [local-repo]} diff --git a/system/t06_publish/AzurePublish5Test_gold b/system/t06_publish/AzurePublish5Test_gold new file mode 100644 index 00000000..cadce02c --- /dev/null +++ b/system/t06_publish/AzurePublish5Test_gold @@ -0,0 +1,3 @@ +Cleaning up prefix "." components main... + +Published repository has been removed successfully. diff --git a/system/t06_publish/azure.py b/system/t06_publish/azure.py new file mode 100644 index 00000000..962021e1 --- /dev/null +++ b/system/t06_publish/azure.py @@ -0,0 +1,211 @@ +from azure_lib import AzureTest + + +def strip_processor(output): + return '\n'.join( + [ + l + for l in output.split('\n') + if not l.startswith(' ') and not l.startswith('Date:') + ] + ) + + +class AzurePublish1Test(AzureTest): + """ + publish to Azure: from repo + """ + + fixtureCmds = [ + 'aptly repo create -distribution=maverick local-repo', + 'aptly repo add local-repo ${files}', + 'aptly repo remove local-repo libboost-program-options-dev_1.62.0.1_i386', + ] + runCmd = 'aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec local-repo azure:test1:' + + def check(self): + super(AzurePublish1Test, self).check() + + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/main/binary-i386/Packages') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/main/source/Sources') + self.check_exists('public/dists/maverick/main/source/Sources.gz') + self.check_exists('public/dists/maverick/main/source/Sources.bz2') + + self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.dsc') + self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.diff.gz') + self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz') + self.check_exists('public/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc') + self.check_exists( + 'public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb' + ) + + # # verify contents except of sums + self.check_file_contents( + 'public/dists/maverick/Release', 'release', match_prepare=strip_processor + ) + self.check_file_contents( + 'public/dists/maverick/main/source/Sources', + 'sources', + match_prepare=lambda s: '\n'.join(sorted(s.split('\n'))), + ) + self.check_file_contents( + 'public/dists/maverick/main/binary-i386/Packages', + 'binary', + match_prepare=lambda s: '\n'.join(sorted(s.split('\n'))), + ) + + +class AzurePublish2Test(AzureTest): + """ + publish to Azure: publish update removed some packages + """ + + fixtureCmds = [ + 'aptly repo create -distribution=maverick local-repo', + 'aptly repo add local-repo ${files}/', + 'aptly repo remove local-repo libboost-program-options-dev_1.62.0.1_i386', + 'aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec local-repo azure:test1:', + 'aptly repo remove local-repo pyspi', + ] + runCmd = 'aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick azure:test1:' + + def check(self): + super(AzurePublish2Test, self).check() + + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/main/binary-i386/Packages') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/main/source/Sources') + self.check_exists('public/dists/maverick/main/source/Sources.gz') + self.check_exists('public/dists/maverick/main/source/Sources.bz2') + + self.check_not_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.dsc') + self.check_not_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.diff.gz') + self.check_not_exists('public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz') + self.check_not_exists('public/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc') + self.check_exists( + 'public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb' + ) + + # verify contents except of sums + self.check_file_contents( + 'public/dists/maverick/Release', 'release', match_prepare=strip_processor + ) + self.check_file_contents( + 'public/dists/maverick/main/source/Sources', + 'sources', + match_prepare=lambda s: '\n'.join(sorted(s.split('\n'))), + ) + self.check_file_contents( + 'public/dists/maverick/main/binary-i386/Packages', + 'binary', + match_prepare=lambda s: '\n'.join(sorted(s.split('\n'))), + ) + + +class AzurePublish3Test(AzureTest): + """ + publish to Azure: publish switch - removed some packages + """ + + fixtureDB = True + fixturePool = True + fixtureCmds = [ + 'aptly snapshot create snap1 from mirror gnuplot-maverick', + 'aptly snapshot create snap2 empty', + 'aptly snapshot pull -no-deps -architectures=i386,amd64 snap2 snap1 snap3 gnuplot-x11', + 'aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick snap1 azure:test1:', + ] + runCmd = 'aptly publish switch -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick azure:test1: snap3' + + def check(self): + super(AzurePublish3Test, self).check() + + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/main/binary-amd64/Packages') + self.check_exists('public/dists/maverick/main/binary-amd64/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-amd64/Packages.bz2') + + self.check_exists( + 'public/pool/main/g/gnuplot/gnuplot-x11_4.6.1-1~maverick2_i386.deb' + ) + self.check_exists( + 'public/pool/main/g/gnuplot/gnuplot-x11_4.6.1-1~maverick2_amd64.deb' + ) + self.check_not_exists( + 'public/pool/main/g/gnuplot/gnuplot-nox_4.6.1-1~maverick2_i386.deb' + ) + self.check_not_exists( + 'public/pool/main/g/gnuplot/gnuplot-nox_4.6.1-1~maverick2_amd64.deb' + ) + + # verify contents except of sums + self.check_file_contents( + 'public/dists/maverick/Release', 'release', match_prepare=strip_processor + ) + self.check_file_contents( + 'public/dists/maverick/main/binary-i386/Packages', + 'binary', + match_prepare=lambda s: '\n'.join(sorted(s.split('\n'))), + ) + + +class AzurePublish4Test(AzureTest): + """ + publish to Azure: multiple repos, list + """ + + fixtureCmds = [ + 'aptly repo create -distribution=maverick local-repo', + 'aptly repo add local-repo ${udebs}', + 'aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec local-repo azure:test1:', + 'aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=xyz local-repo azure:test1:', + 'aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec local-repo azure:test1:prefix', + ] + runCmd = 'aptly publish list' + + +class AzurePublish5Test(AzureTest): + """ + publish to Azure: publish drop - component cleanup + """ + + fixtureCmds = [ + 'aptly repo create local1', + 'aptly repo create local2', + 'aptly repo add local1 ${files}/libboost-program-options-dev_1.49.0.1_i386.deb', + 'aptly repo add local2 ${files}', + 'aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=sq1 local1 azure:test1:', + 'aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=sq2 local2 azure:test1:', + ] + runCmd = 'aptly publish drop sq2 azure:test1:' + + def check(self): + super(AzurePublish5Test, self).check() + + self.check_exists('public/dists/sq1') + self.check_not_exists('public/dists/sq2') + self.check_exists('public/pool/main/') + + self.check_not_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.dsc') + self.check_not_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.diff.gz') + self.check_not_exists('public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz') + self.check_not_exists('public/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc') + self.check_exists( + 'public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb' + )