Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package openSUSE-release-tools for openSUSE:Factory checked in at 2022-03-07 18:26:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/openSUSE-release-tools (Old) and /work/SRC/openSUSE:Factory/.openSUSE-release-tools.new.1958 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "openSUSE-release-tools" Mon Mar 7 18:26:19 2022 rev:392 rq:960026 version:20220307.7fa0e0de Changes: -------- --- /work/SRC/openSUSE:Factory/openSUSE-release-tools/openSUSE-release-tools.changes 2022-03-07 17:47:08.555116352 +0100 +++ /work/SRC/openSUSE:Factory/.openSUSE-release-tools.new.1958/openSUSE-release-tools.changes 2022-03-07 18:26:21.450766593 +0100 @@ -1,0 +2,20 @@ +Mon Mar 07 16:48:24 UTC 2022 - opensuse-releaset...@opensuse.org + +- Update to version 20220307.7fa0e0de: + * leapmicro: add leapmicro to pipeline + * installcheck: Report all delete requests + +------------------------------------------------------------------- +Mon Mar 07 13:30:18 UTC 2022 - opensuse-releaset...@opensuse.org + +- Update to version 20220307.a7a1aa83: + * Add some basic instructions on how our tests are written + * docs: Remove testing.asciidoc - it's severely outdated + +------------------------------------------------------------------- +Mon Mar 07 10:22:50 UTC 2022 - opensuse-releaset...@opensuse.org + +- Update to version 20220307.93f8244a: + * Rename the pkglistgen config for ring1 as well + +------------------------------------------------------------------- Old: ---- openSUSE-release-tools-20220306.b5436de6.obscpio New: ---- openSUSE-release-tools-20220307.7fa0e0de.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ openSUSE-release-tools.spec ++++++ --- /var/tmp/diff_new_pack.3vjsVw/_old 2022-03-07 18:26:22.190766414 +0100 +++ /var/tmp/diff_new_pack.3vjsVw/_new 2022-03-07 18:26:22.198766412 +0100 @@ -20,7 +20,7 @@ %define source_dir openSUSE-release-tools %define announcer_filename factory-package-news Name: openSUSE-release-tools -Version: 20220306.b5436de6 +Version: 20220307.7fa0e0de Release: 0 Summary: Tools to aid in staging and release work for openSUSE/SUSE License: GPL-2.0-or-later AND MIT ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.3vjsVw/_old 2022-03-07 18:26:22.246766400 +0100 +++ /var/tmp/diff_new_pack.3vjsVw/_new 2022-03-07 18:26:22.254766398 +0100 @@ -1,7 +1,7 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/openSUSE/openSUSE-release-tools.git</param> - <param name="changesrevision">762f129b4dbe3bee27ff0c6281aecb92a41e4f47</param> + <param name="changesrevision">7fa0e0de0d1ab1fb00fed7aad91ecc4d77f38123</param> </service> </servicedata> ++++++ openSUSE-release-tools-20220306.b5436de6.obscpio -> openSUSE-release-tools-20220307.7fa0e0de.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openSUSE-release-tools-20220306.b5436de6/README.md new/openSUSE-release-tools-20220307.7fa0e0de/README.md --- old/openSUSE-release-tools-20220306.b5436de6/README.md 2022-03-06 11:10:03.000000000 +0100 +++ new/openSUSE-release-tools-20220307.7fa0e0de/README.md 2022-03-07 17:47:13.000000000 +0100 @@ -78,9 +78,9 @@ osc -A local api /about -Some tests will attempt to run against the local OBS, but not all. +Some tests will attempt to run against the local OBS, but not all. It's still recommended to run this through docker-compose (see below) - nosetests + pytest tests/*.py ## Running Continuous Integration @@ -130,3 +130,60 @@ You can access your testing OBS instance at `http://0.0.0.0:3000` and log in using "Admin" as username and "opensuse" as password. To prevent the data being removed while you are inspecting the OBS instance, you can put a call to the `breakpoint()` function. Finally, if you miss anything for debugging, you can use `zypper` to install it. + +### Adding tests + +Testing the release tools isn't quite trivial as a lot of these tools rely on running openSUSE infrastructure. Some of the workflows we replay (not mock) in above described docker-compose setup. So each test will setup the required projects and e.g. staging workflows in a local containerized OBS installation and then do its assertions. If you want to add coverage, best check existing unit tests in tests/*.py. A generic test case looks similiar to this: + +``` {.python title="Basic Test Example" } +class TestExample(unittest.TestCase): + +def test_basic(self): + # Keep the workflow in local scope so that ending the test case will destroy it. + # Destroying the workflow will also delete all created projects and packages. The + # created workflow has a target project, but most of the test assets need to be created + # as needed + wf = OBSLocal.FactoryWorkflow() + staging = wf.create_staging('A', freeze=True) + wf.create_submit_request('devel:wine', 'wine') + + ret = SelectCommand(wf.api, staging.name).perform(['wine']) + self.assertEqual(True, ret) +``` + +To ease having many such tests, we also have the `OBSLocal` class, which moves the creation of the workflow into `setUp` and the destruction in `tearDwon` functions of pytest. The principle stays the same though. + +``` {.python title="OBSLocal Usage"} +class TestExampleWithOBS(OBSLocal.TestCase): + """ + Tests for various api calls to ensure we return expected content + """ + + def setUp(self): + super(TestExampleWithOBS, self).setUp() + self.wf = OBSLocal.FactoryWorkflow() + self.wf.setup_rings() + self.staging_b = self.wf.create_staging('B') + + def tearDown(self): + del self.wf + super(TestExampleWithOBS, self).tearDown() + + def test_list_projects(self): + """ + List projects and their content + """ + staging_a = self.wf.create_staging('A') + + # Prepare expected results + data = [staging_a.name, self.staging_b.name] + + # Compare the results + self.assertEqual(data, self.wf.api.get_staging_projects()) +``` + +Note that we have some (older) test cases using httpretty, but those are very special cases and require you a lot of extra mocking as you can't mix httpretty and testing against the minimal OBS. So every extra +call that osc libraries or our code do, will require changes in your test case. It can still be a viable option, especially if more than OBS is involved. + +The method that you can combine with `OBSLocal` though is using MagicMock. This class is used to mock individual functions. So splitting the code to use helper functions to retrieve information and then +mocking this inside the test case can be a good alternative to mocking the complete HTTP traffic. \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openSUSE-release-tools-20220306.b5436de6/docs/testing.asciidoc new/openSUSE-release-tools-20220307.7fa0e0de/docs/testing.asciidoc --- old/openSUSE-release-tools-20220306.b5436de6/docs/testing.asciidoc 2022-03-06 11:10:03.000000000 +0100 +++ new/openSUSE-release-tools-20220307.7fa0e0de/docs/testing.asciidoc 1970-01-01 01:00:00.000000000 +0100 @@ -1,136 +0,0 @@ -Testing -======= - -Dependencies ------------- - -Test suite is using +nose+, +httpretty+ and +mock+ for testing. You need these -three python modules installed to run tests. In openSUSE, you can do it using -the following command as a root: - --------------------------------------------------------------------------------- -zypper in python-nose python-httpretty python-mock --------------------------------------------------------------------------------- - -Running tests -------------- - -To run the tests, you need to be in the topmost directory of your checkout and -run the following command there: - --------------------------------------------------------------------------------- -nosetests --------------------------------------------------------------------------------- - -Structure of the suite ----------------------- - -Each object contains functions for the individual tests so split them per -area of interest. - -In directory fixtures there are resulting xml files obtained from the OBS with -osc api calls. - -Writing tests -------------- - -There are a few nice building stones available to implement test. - -OBS class -~~~~~~~~~ - -+OBS+ class provides simulation of OBS including keeping internal states. It -supports only a limited number of commands, but that can be extended. - -Extending OBS class -^^^^^^^^^^^^^^^^^^^ - -You can extend the OBS mockup class creating new method, and -decorating it with one of the @GET, @PUT, @POST or @DELETE. The -parameter of the decorator is the PATH of the URL or a regular -expression that matches one of the possible paths. - -If the new response can be implemented as a simple fixture, you can -create the file in the +fixtures/+ directory in a place compatible in -the expected path. - -Because we are decorating methods, we can maintain an internal status -inside the OBS mock-up instance. - -example -^^^^^^^ - -First we create a template for our response. We will be using pythons string -Template class therefore XML has some values replaced with +${variable}+ and we -will assign those later. - -.Template -[source,xml] --------------------------------------------------------------------------------- -<request id="${id}"> - <action type="submit"> - <source project="home:Admin" package="${package}" rev="59f0f46262d7b57b9cdc720c06d5e317"/> - <target project="openSUSE:Factory" package="${package}"/> - </action> - <state name="${request}" who="Admin" when="2014-02-17T12:38:52"> - <comment>...</comment> - </state> - <review state="${review}" when="2014-02-17T12:34:10" who="${who}" by_${by}="${by_who}"> - <comment>...</comment> - </review> - <description>test</description> -</request> --------------------------------------------------------------------------------- - -We can also define helpful local data structure representing actual state of OBS - -[source,python] --------------------------------------------------------------------------------- -# Initial request data -self.requests = { - '123': { - 'request': 'new', - 'review': 'accepted', - 'who': 'Admin', - 'by': 'group', - 'id': '123', - 'by_who': 'opensuse-review-team', - 'package': 'gcc', - }, - '321': { - 'request': 'review', - 'review': 'new', - 'who': 'Admin', - 'by': 'group', - 'id': '321', - 'by_who': 'factory-staging', - 'package': 'puppet', - }, -} --------------------------------------------------------------------------------- - -And the most important part is implementing OBS behaviour. - -[source,python] --------------------------------------------------------------------------------- -@GET(re.compile(r'/request/\d+')) -def request(self, request, uri, headers): - """Return a request XML description.""" - request_id = re.search(r'(\d+)', uri).group(1) - response = (404, headers, '<result>Not found</result>') - try: - template = string.Template(self._fixture(uri)) - response = (200, headers, template.substitute(self.requests[request_id])) - except Exception as e: - if DEBUG: - print uri, e - - if DEBUG: - print 'REQUEST', uri, response - - return response --------------------------------------------------------------------------------- - -The method +request+ will be called when a request to /request/NUMBER -is made. The previous code will load the XML template and replace -variables with the request dictionary content. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openSUSE-release-tools-20220306.b5436de6/gocd/leapmicro.target.gocd.yaml new/openSUSE-release-tools-20220307.7fa0e0de/gocd/leapmicro.target.gocd.yaml --- old/openSUSE-release-tools-20220306.b5436de6/gocd/leapmicro.target.gocd.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/openSUSE-release-tools-20220307.7fa0e0de/gocd/leapmicro.target.gocd.yaml 2022-03-07 17:47:13.000000000 +0100 @@ -0,0 +1,39 @@ +format_version: 3 +pipelines: + LeapMicro.RelPkgs: + group: LeapMicro.Target + lock_behavior: unlockWhenFinished + timer: + spec: 0 10 * ? * * + only_on_changes: false + materials: + git: + git: https://github.com/openSUSE/openSUSE-release-tools.git + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-staging-bot + stages: + - Create.Release.Packages: + approval: manual + resources: + - repo-checker + tasks: + - script: ./pkglistgen.py -A https://api.opensuse.org update_and_solve -p openSUSE:Leap:Micro:5.2 -s target --only-release-packages + + LeapMicro.Package.Lists: + group: LeapMicro.Target + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-staging-bot + timer: + spec: 0 40 * ? * * + only_on_changes: false + materials: + git: + git: https://github.com/openSUSE/openSUSE-release-tools.git + stages: + - Update.000product: + resources: + - repo-checker + tasks: + - script: ./pkglistgen.py -A https://api.opensuse.org --debug update_and_solve -p openSUSE:Leap:Micro:5.2 -s target + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openSUSE-release-tools-20220306.b5436de6/osclib/conf.py new/openSUSE-release-tools-20220307.7fa0e0de/osclib/conf.py --- old/openSUSE-release-tools-20220306.b5436de6/osclib/conf.py 2022-03-06 11:10:03.000000000 +0100 +++ new/openSUSE-release-tools-20220307.7fa0e0de/osclib/conf.py 2022-03-07 17:47:13.000000000 +0100 @@ -95,7 +95,7 @@ 'splitter-special-packages': '', 'pkglistgen-archs': 'x86_64', 'pkglistgen-locales-from': 'openSUSE.product', - 'pkglistgen-delete-kiwis-rings': 'openSUSE-ftp-ftp-x86_64.kiwi openSUSE-cd-mini-x86_64.kiwi', + 'pkglistgen-delete-kiwis-ring1': 'openSUSE-ftp-ftp-x86_64.kiwi openSUSE-cd-mini-x86_64.kiwi', 'pkglistgen-delete-kiwis-staging': 'openSUSE-ftp-ftp-x86_64.kiwi openSUSE-cd-mini-x86_64.kiwi', 'mail-list': 'fact...@lists.opensuse.org', 'mail-maintainer': 'Ludwig Nussel <ludwig.nus...@suse.de>', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openSUSE-release-tools-20220306.b5436de6/staging-installcheck.py new/openSUSE-release-tools-20220307.7fa0e0de/staging-installcheck.py --- old/openSUSE-release-tools-20220306.b5436de6/staging-installcheck.py 2022-03-06 11:10:03.000000000 +0100 +++ new/openSUSE-release-tools-20220307.7fa0e0de/staging-installcheck.py 2022-03-07 17:47:13.000000000 +0100 @@ -179,7 +179,7 @@ for req in status.findall('staged_requests/request'): if req.get('type') == 'delete': - result = result and self.check_delete_request(req, to_ignore, to_delete, result_comment) + result = self.check_delete_request(req, to_ignore, to_delete, result_comment) and result for arch in architectures: # hit the first repository in the target project (if existant) ++++++ openSUSE-release-tools.obsinfo ++++++ --- /var/tmp/diff_new_pack.3vjsVw/_old 2022-03-07 18:26:23.130766186 +0100 +++ /var/tmp/diff_new_pack.3vjsVw/_new 2022-03-07 18:26:23.134766185 +0100 @@ -1,5 +1,5 @@ name: openSUSE-release-tools -version: 20220306.b5436de6 -mtime: 1646561403 -commit: b5436de667683efd6c78fef71fcd3da40006cc3d +version: 20220307.7fa0e0de +mtime: 1646671633 +commit: 7fa0e0de0d1ab1fb00fed7aad91ecc4d77f38123