blob: c5059085e630e3a9dbc31497ed1c64e3c6e52174 [file] [log] [blame]
Clint Adamsa4136522016-03-10 20:24:34 -05001#! /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
caoyuan349ba752019-04-23 19:40:06 +080022# * network access to the review.opendev.org Gerrit API
Clint Adamsa4136522016-03-10 20:24:34 -050023# working directory
caoyuan349ba752019-04-23 19:40:06 +080024# * network access to https://opendev.org/openstack
Clint Adamsa4136522016-03-10 20:24:34 -050025
26import json
27import re
Masayuki Igawaac8ae642019-05-23 11:39:02 +020028import sys
Masayuki Igawa134d9f72017-02-10 18:05:26 +090029
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090030import urllib3
31from urllib3.util import retry
Masayuki Igawa73c33452017-06-19 12:08:58 +090032
Masayuki Igawaac8ae642019-05-23 11:39:02 +020033# 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.
37BLACKLIST = [
Masayuki Igawa6617b832019-06-20 14:48:37 +090038 'x/gce-api', # It looks gce-api doesn't support python3 yet.
Masayuki Igawa8913b1d2019-08-29 11:21:28 +090039 'x/group-based-policy', # It looks this doesn't support python3 yet.
Masayuki Igawa6617b832019-06-20 14:48:37 +090040 'x/intel-nfv-ci-tests', # https://review.opendev.org/#/c/634640/
Masayuki Igawa6617b832019-06-20 14:48:37 +090041 'openstack/networking-generic-switch',
42 # https://review.opendev.org/#/c/634846/
43 'openstack/networking-l2gw-tempest-plugin',
44 # https://review.opendev.org/#/c/635093/
45 'openstack/networking-midonet', # https://review.opendev.org/#/c/635096/
46 'x/networking-plumgrid', # https://review.opendev.org/#/c/635096/
47 'x/networking-spp', # https://review.opendev.org/#/c/635098/
48 'openstack/neutron-dynamic-routing',
49 # https://review.opendev.org/#/c/637718/
50 'openstack/neutron-vpnaas', # https://review.opendev.org/#/c/637719/
Masayuki Igawa6617b832019-06-20 14:48:37 +090051 'x/valet', # https://review.opendev.org/#/c/638339/
Martin Kopece743e5d2020-03-30 13:50:15 +000052 'x/kingbird', # https://bugs.launchpad.net/kingbird/+bug/1869722
Masayuki Igawaac8ae642019-05-23 11:39:02 +020053]
Clint Adamsa4136522016-03-10 20:24:34 -050054
caoyuan349ba752019-04-23 19:40:06 +080055url = 'https://review.opendev.org/projects/'
Clint Adamsa4136522016-03-10 20:24:34 -050056
57# This is what a project looks like
58'''
59 "openstack-attic/akanda": {
60 "id": "openstack-attic%2Fakanda",
61 "state": "READ_ONLY"
62 },
63'''
64
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090065http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED')
66retries = retry.Retry(status_forcelist=[500], backoff_factor=1.0)
Clint Adamsa4136522016-03-10 20:24:34 -050067
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090068
Clint Adamsa4136522016-03-10 20:24:34 -050069def has_tempest_plugin(proj):
Chandan Kumar1b1e6df2017-06-11 17:07:50 +053070 try:
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090071 r = http.request('GET', "https://opendev.org/%s/raw/branch/"
72 "master/setup.cfg" % proj, retries=retries)
73 if r.status == 404:
Chandan Kumar1b1e6df2017-06-11 17:07:50 +053074 return False
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090075 except urllib3.exceptions.MaxRetryError as err:
Masayuki Igawa2957b402019-06-24 15:22:13 +090076 # We should not ignore non 404 errors.
77 raise err
Stephen Finucane7f4a6212018-07-06 13:58:21 +010078 p = re.compile(r'^tempest\.test_plugins', re.M)
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090079 if p.findall(r.data.decode('utf-8')):
Clint Adamsa4136522016-03-10 20:24:34 -050080 return True
81 else:
82 False
83
Stephen Finucane7f4a6212018-07-06 13:58:21 +010084
Masayuki Igawaac8ae642019-05-23 11:39:02 +020085if len(sys.argv) > 1 and sys.argv[1] == 'blacklist':
86 for black_plugin in BLACKLIST:
87 print(black_plugin)
88 # We just need BLACKLIST when we use this `blacklist` option.
89 # So, this exits here.
90 sys.exit()
91
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090092r = http.request('GET', url, retries=retries)
Clint Adamsa4136522016-03-10 20:24:34 -050093# Gerrit prepends 4 garbage octets to the JSON, in order to counter
94# cross-site scripting attacks. Therefore we must discard it so the
95# json library won't choke.
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090096content = r.data.decode('utf-8')[4:]
Masayuki Igawae36fe672019-05-23 13:43:46 +020097projects = sorted(json.loads(content))
Clint Adamsa4136522016-03-10 20:24:34 -050098
Masayuki Igawae36fe672019-05-23 13:43:46 +020099# Retrieve projects having no deployment tool repo (such as deb,
100# puppet, ansible, etc.), infra repos, ui or spec namespace as those
ghanshyam95b68be2018-02-01 02:17:08 +0000101# namespaces do not contains tempest plugins.
102projects_list = [i for i in projects if not (
Masayuki Igawae36fe672019-05-23 13:43:46 +0200103 i.startswith('openstack-dev/') or
104 i.startswith('openstack-infra/') or
105 i.startswith('openstack/ansible-') or
106 i.startswith('openstack/charm-') or
107 i.startswith('openstack/cookbook-openstack-') or
108 i.startswith('openstack/devstack-') or
109 i.startswith('openstack/fuel-') or
ghanshyam95b68be2018-02-01 02:17:08 +0000110 i.startswith('openstack/deb-') or
111 i.startswith('openstack/puppet-') or
Masayuki Igawae36fe672019-05-23 13:43:46 +0200112 i.startswith('openstack/openstack-ansible-') or
113 i.startswith('x/deb-') or
114 i.startswith('x/fuel-') or
115 i.startswith('x/python-') or
116 i.startswith('zuul/') or
ghanshyam95b68be2018-02-01 02:17:08 +0000117 i.endswith('-ui') or
118 i.endswith('-specs'))]
Chandan Kumar3c81b412017-06-13 15:48:20 +0530119
120found_plugins = list(filter(has_tempest_plugin, projects_list))
Clint Adamsa4136522016-03-10 20:24:34 -0500121
Masayuki Igawae36fe672019-05-23 13:43:46 +0200122# We have tempest plugins not only in 'openstack/' namespace but also the
123# other name spaces such as 'airship/', 'x/', etc.
124# So, we print all of them here.
Clint Adamsa4136522016-03-10 20:24:34 -0500125for project in found_plugins:
Masayuki Igawae36fe672019-05-23 13:43:46 +0200126 print(project)