Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | # Copyright 2016 Hewlett Packard Enterprise Development Company, L.P. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
| 17 | # This script is intended to be run as part of a periodic proposal bot |
| 18 | # job in OpenStack infrastructure. |
| 19 | # |
| 20 | # In order to function correctly, the environment in which the |
| 21 | # script runs must have |
caoyuan | 349ba75 | 2019-04-23 19:40:06 +0800 | [diff] [blame] | 22 | # * network access to the review.opendev.org Gerrit API |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 23 | # working directory |
caoyuan | 349ba75 | 2019-04-23 19:40:06 +0800 | [diff] [blame] | 24 | # * network access to https://opendev.org/openstack |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 25 | |
| 26 | import json |
| 27 | import re |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 28 | import sys |
Masayuki Igawa | 134d9f7 | 2017-02-10 18:05:26 +0900 | [diff] [blame] | 29 | |
Masayuki Igawa | 411f4bb | 2019-08-08 16:15:11 +0900 | [diff] [blame] | 30 | import urllib3 |
| 31 | from urllib3.util import retry |
Masayuki Igawa | 73c3345 | 2017-06-19 12:08:58 +0900 | [diff] [blame] | 32 | |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 33 | # List of projects having tempest plugin stale or unmaintained for a long time |
| 34 | # (6 months or more) |
| 35 | # TODO(masayukig): Some of these can be removed from BLACKLIST in the future |
| 36 | # when the patches are merged. |
| 37 | BLACKLIST = [ |
Masayuki Igawa | 6617b83 | 2019-06-20 14:48:37 +0900 | [diff] [blame] | 38 | 'x/gce-api', # It looks gce-api doesn't support python3 yet. |
Masayuki Igawa | 14d66b6 | 2020-04-13 09:32:11 +0900 | [diff] [blame] | 39 | 'x/glare', # To avoid sanity-job failure |
Masayuki Igawa | 8913b1d | 2019-08-29 11:21:28 +0900 | [diff] [blame] | 40 | 'x/group-based-policy', # It looks this doesn't support python3 yet. |
Masayuki Igawa | 6617b83 | 2019-06-20 14:48:37 +0900 | [diff] [blame] | 41 | 'x/intel-nfv-ci-tests', # https://review.opendev.org/#/c/634640/ |
Masayuki Igawa | 6617b83 | 2019-06-20 14:48:37 +0900 | [diff] [blame] | 42 | 'openstack/networking-generic-switch', |
| 43 | # https://review.opendev.org/#/c/634846/ |
Ghanshyam Mann | ff145e6 | 2020-06-25 21:21:58 -0500 | [diff] [blame] | 44 | 'x/networking-l2gw-tempest-plugin', |
Masayuki Igawa | 6617b83 | 2019-06-20 14:48:37 +0900 | [diff] [blame] | 45 | # https://review.opendev.org/#/c/635093/ |
| 46 | 'openstack/networking-midonet', # https://review.opendev.org/#/c/635096/ |
| 47 | 'x/networking-plumgrid', # https://review.opendev.org/#/c/635096/ |
| 48 | 'x/networking-spp', # https://review.opendev.org/#/c/635098/ |
| 49 | 'openstack/neutron-dynamic-routing', |
| 50 | # https://review.opendev.org/#/c/637718/ |
| 51 | 'openstack/neutron-vpnaas', # https://review.opendev.org/#/c/637719/ |
Masayuki Igawa | 14d66b6 | 2020-04-13 09:32:11 +0900 | [diff] [blame] | 52 | 'x/tap-as-a-service', # To avoid sanity-job failure |
Masayuki Igawa | 6617b83 | 2019-06-20 14:48:37 +0900 | [diff] [blame] | 53 | 'x/valet', # https://review.opendev.org/#/c/638339/ |
Martin Kopec | e743e5d | 2020-03-30 13:50:15 +0000 | [diff] [blame] | 54 | 'x/kingbird', # https://bugs.launchpad.net/kingbird/+bug/1869722 |
Martin Kopec | 4c709ec | 2020-06-19 08:27:46 +0000 | [diff] [blame] | 55 | # vmware-nsx is blacklisted since https://review.opendev.org/#/c/736952 |
| 56 | 'x/vmware-nsx-tempest-plugin', |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 57 | ] |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 58 | |
caoyuan | 349ba75 | 2019-04-23 19:40:06 +0800 | [diff] [blame] | 59 | url = 'https://review.opendev.org/projects/' |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 60 | |
| 61 | # This is what a project looks like |
| 62 | ''' |
| 63 | "openstack-attic/akanda": { |
| 64 | "id": "openstack-attic%2Fakanda", |
| 65 | "state": "READ_ONLY" |
| 66 | }, |
| 67 | ''' |
| 68 | |
Masayuki Igawa | 411f4bb | 2019-08-08 16:15:11 +0900 | [diff] [blame] | 69 | http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED') |
| 70 | retries = retry.Retry(status_forcelist=[500], backoff_factor=1.0) |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 71 | |
Masayuki Igawa | 411f4bb | 2019-08-08 16:15:11 +0900 | [diff] [blame] | 72 | |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 73 | def has_tempest_plugin(proj): |
Chandan Kumar | 1b1e6df | 2017-06-11 17:07:50 +0530 | [diff] [blame] | 74 | try: |
Masayuki Igawa | 411f4bb | 2019-08-08 16:15:11 +0900 | [diff] [blame] | 75 | r = http.request('GET', "https://opendev.org/%s/raw/branch/" |
| 76 | "master/setup.cfg" % proj, retries=retries) |
| 77 | if r.status == 404: |
Chandan Kumar | 1b1e6df | 2017-06-11 17:07:50 +0530 | [diff] [blame] | 78 | return False |
Masayuki Igawa | 411f4bb | 2019-08-08 16:15:11 +0900 | [diff] [blame] | 79 | except urllib3.exceptions.MaxRetryError as err: |
Masayuki Igawa | 2957b40 | 2019-06-24 15:22:13 +0900 | [diff] [blame] | 80 | # We should not ignore non 404 errors. |
| 81 | raise err |
Stephen Finucane | 7f4a621 | 2018-07-06 13:58:21 +0100 | [diff] [blame] | 82 | p = re.compile(r'^tempest\.test_plugins', re.M) |
Masayuki Igawa | 411f4bb | 2019-08-08 16:15:11 +0900 | [diff] [blame] | 83 | if p.findall(r.data.decode('utf-8')): |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 84 | return True |
| 85 | else: |
| 86 | False |
| 87 | |
Stephen Finucane | 7f4a621 | 2018-07-06 13:58:21 +0100 | [diff] [blame] | 88 | |
Masayuki Igawa | ac8ae64 | 2019-05-23 11:39:02 +0200 | [diff] [blame] | 89 | if len(sys.argv) > 1 and sys.argv[1] == 'blacklist': |
| 90 | for black_plugin in BLACKLIST: |
| 91 | print(black_plugin) |
| 92 | # We just need BLACKLIST when we use this `blacklist` option. |
| 93 | # So, this exits here. |
| 94 | sys.exit() |
| 95 | |
Masayuki Igawa | 411f4bb | 2019-08-08 16:15:11 +0900 | [diff] [blame] | 96 | r = http.request('GET', url, retries=retries) |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 97 | # Gerrit prepends 4 garbage octets to the JSON, in order to counter |
| 98 | # cross-site scripting attacks. Therefore we must discard it so the |
| 99 | # json library won't choke. |
Masayuki Igawa | 411f4bb | 2019-08-08 16:15:11 +0900 | [diff] [blame] | 100 | content = r.data.decode('utf-8')[4:] |
Masayuki Igawa | e36fe67 | 2019-05-23 13:43:46 +0200 | [diff] [blame] | 101 | projects = sorted(json.loads(content)) |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 102 | |
Masayuki Igawa | e36fe67 | 2019-05-23 13:43:46 +0200 | [diff] [blame] | 103 | # Retrieve projects having no deployment tool repo (such as deb, |
| 104 | # puppet, ansible, etc.), infra repos, ui or spec namespace as those |
ghanshyam | 95b68be | 2018-02-01 02:17:08 +0000 | [diff] [blame] | 105 | # namespaces do not contains tempest plugins. |
| 106 | projects_list = [i for i in projects if not ( |
Masayuki Igawa | e36fe67 | 2019-05-23 13:43:46 +0200 | [diff] [blame] | 107 | i.startswith('openstack-dev/') or |
| 108 | i.startswith('openstack-infra/') or |
| 109 | i.startswith('openstack/ansible-') or |
| 110 | i.startswith('openstack/charm-') or |
| 111 | i.startswith('openstack/cookbook-openstack-') or |
| 112 | i.startswith('openstack/devstack-') or |
| 113 | i.startswith('openstack/fuel-') or |
ghanshyam | 95b68be | 2018-02-01 02:17:08 +0000 | [diff] [blame] | 114 | i.startswith('openstack/deb-') or |
| 115 | i.startswith('openstack/puppet-') or |
Masayuki Igawa | e36fe67 | 2019-05-23 13:43:46 +0200 | [diff] [blame] | 116 | i.startswith('openstack/openstack-ansible-') or |
| 117 | i.startswith('x/deb-') or |
| 118 | i.startswith('x/fuel-') or |
| 119 | i.startswith('x/python-') or |
| 120 | i.startswith('zuul/') or |
ghanshyam | 95b68be | 2018-02-01 02:17:08 +0000 | [diff] [blame] | 121 | i.endswith('-ui') or |
| 122 | i.endswith('-specs'))] |
Chandan Kumar | 3c81b41 | 2017-06-13 15:48:20 +0530 | [diff] [blame] | 123 | |
| 124 | found_plugins = list(filter(has_tempest_plugin, projects_list)) |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 125 | |
Masayuki Igawa | e36fe67 | 2019-05-23 13:43:46 +0200 | [diff] [blame] | 126 | # We have tempest plugins not only in 'openstack/' namespace but also the |
| 127 | # other name spaces such as 'airship/', 'x/', etc. |
| 128 | # So, we print all of them here. |
Clint Adams | a413652 | 2016-03-10 20:24:34 -0500 | [diff] [blame] | 129 | for project in found_plugins: |
Masayuki Igawa | e36fe67 | 2019-05-23 13:43:46 +0200 | [diff] [blame] | 130 | print(project) |