blob: ae17a0ff724fa595c03fc6fd3ef8b94042ca7eac [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
Ghanshyam Maan3e1ec7a2026-03-26 21:01:18 +000033# List of openstack projects having tempest plugin stale or unmaintained for
34# a long time(6 months or more)
Martin Kopecdc844232020-12-24 15:57:53 +000035NON_ACTIVE_LIST = [
Masayuki Igawa6617b832019-06-20 14:48:37 +090036 'openstack/networking-generic-switch',
Anand Bhatf3627202021-06-16 20:39:31 +053037 # networking-spp is missing neutron-tempest-plugin as a dep plus
38 # test-requirements.txt is nested in a openstack dir and sanity script
39 # doesn't count with such scenario yet
Masayuki Igawa6617b832019-06-20 14:48:37 +090040 'openstack/neutron-dynamic-routing',
Anand Bhatf3627202021-06-16 20:39:31 +053041 # As tests have been migrated to neutron-tempest-plugin:
Masayuki Igawa6617b832019-06-20 14:48:37 +090042 # https://review.opendev.org/#/c/637718/
Anand Bhatf3627202021-06-16 20:39:31 +053043 'openstack/neutron-vpnaas',
Masayuki Igawaac8ae642019-05-23 11:39:02 +020044]
Clint Adamsa4136522016-03-10 20:24:34 -050045
caoyuan349ba752019-04-23 19:40:06 +080046url = 'https://review.opendev.org/projects/'
Clint Adamsa4136522016-03-10 20:24:34 -050047
48# This is what a project looks like
49'''
50 "openstack-attic/akanda": {
51 "id": "openstack-attic%2Fakanda",
52 "state": "READ_ONLY"
53 },
54'''
55
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090056http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED')
57retries = retry.Retry(status_forcelist=[500], backoff_factor=1.0)
Clint Adamsa4136522016-03-10 20:24:34 -050058
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090059
Clint Adamsa4136522016-03-10 20:24:34 -050060def has_tempest_plugin(proj):
Chandan Kumar1b1e6df2017-06-11 17:07:50 +053061 try:
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090062 r = http.request('GET', "https://opendev.org/%s/raw/branch/"
63 "master/setup.cfg" % proj, retries=retries)
64 if r.status == 404:
Chandan Kumar1b1e6df2017-06-11 17:07:50 +053065 return False
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090066 except urllib3.exceptions.MaxRetryError as err:
Masayuki Igawa2957b402019-06-24 15:22:13 +090067 # We should not ignore non 404 errors.
68 raise err
Stephen Finucane7f4a6212018-07-06 13:58:21 +010069 p = re.compile(r'^tempest\.test_plugins', re.M)
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090070 if p.findall(r.data.decode('utf-8')):
Clint Adamsa4136522016-03-10 20:24:34 -050071 return True
72 else:
73 False
74
Stephen Finucane7f4a6212018-07-06 13:58:21 +010075
Martin Kopecdc844232020-12-24 15:57:53 +000076if len(sys.argv) > 1 and sys.argv[1] == 'nonactivelist':
77 for non_active_plugin in NON_ACTIVE_LIST:
78 print(non_active_plugin)
79 # We just need NON_ACTIVE_LIST when we use this `nonactivelist` option.
Masayuki Igawaac8ae642019-05-23 11:39:02 +020080 # So, this exits here.
81 sys.exit()
82
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090083r = http.request('GET', url, retries=retries)
Clint Adamsa4136522016-03-10 20:24:34 -050084# Gerrit prepends 4 garbage octets to the JSON, in order to counter
85# cross-site scripting attacks. Therefore we must discard it so the
86# json library won't choke.
Masayuki Igawa411f4bb2019-08-08 16:15:11 +090087content = r.data.decode('utf-8')[4:]
Masayuki Igawae36fe672019-05-23 13:43:46 +020088projects = sorted(json.loads(content))
Clint Adamsa4136522016-03-10 20:24:34 -050089
Ghanshyam Maan3e1ec7a2026-03-26 21:01:18 +000090# Retrieve openstack projects having no deployment tool repo (such
91# as deb, puppet, ansible, etc.), infra repos, ui or spec namespace
92# as those namespaces do not contains tempest plugins.
93projects_list = [i for i in projects if
94 i.startswith('openstack/') and not (
95 i.startswith('openstack/ansible-') or
96 i.startswith('openstack/charm-') or
97 i.startswith('openstack/cookbook-openstack-') or
98 i.startswith('openstack/devstack-') or
99 i.startswith('openstack/fuel-') or
100 i.startswith('openstack/deb-') or
101 i.startswith('openstack/puppet-') or
102 i.startswith('openstack/openstack-ansible-') or
103 i.endswith('-ui') or
104 i.endswith('-specs'))]
Chandan Kumar3c81b412017-06-13 15:48:20 +0530105
106found_plugins = list(filter(has_tempest_plugin, projects_list))
Clint Adamsa4136522016-03-10 20:24:34 -0500107
Masayuki Igawae36fe672019-05-23 13:43:46 +0200108# We have tempest plugins not only in 'openstack/' namespace but also the
109# other name spaces such as 'airship/', 'x/', etc.
110# So, we print all of them here.
Clint Adamsa4136522016-03-10 20:24:34 -0500111for project in found_plugins:
Masayuki Igawae36fe672019-05-23 13:43:46 +0200112 print(project)