Add initial code
[ta/build-tools.git] / tools / script / ci_build_diff_test_data.py
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # pylint: disable=line-too-long,invalid-name
16 import re
17
18 from copy import deepcopy
19
20
21 def _copy(d, pattern, repl):
22     x = deepcopy(d)
23     for k, v in x.items():
24         if isinstance(v, str):
25             x[k] = re.sub(pattern, repl, v)
26     return x
27
28
29 caas_grafana1 = {
30     "Architecture": "noarch",
31     "Build Date": "Wed May 30 11:39:05 2018",
32     "Build Host": "crf-dev",
33     "Crypto capable": False,
34     "Description": "This is grafana, this is SPARTAAAAA!",
35     "FOSS": "No",
36     "From repo": "caas-artifactory",
37     "Group": "Unspecified",
38     "Install Date": "Sun Nov 18 22:15:41 2018",
39     "Is sane": True,
40     "License": "Commercial",
41     "Name": "caas.grafana",
42     "Obsoletes": "",
43     "Release": "1.el7.centos",
44     "Relocations": "(not relocatable)",
45     "Repo": "installed",
46     "Repo data": {
47         "baseurl": "http://files/20181023",
48         "name": "caas-artifactory"
49     },
50     "Signature": "(none)",
51     "Size": "109683450",
52     "Source RPM": "caas.grafana-4.4.1.9-1.el7.centos.src.rpm",
53     "Source repo data": {
54         "baseurl": "http://files/20181023",
55         "name": "caas-artifactory"
56     },
57     "Source to be delivered": "No",
58     "Summary": "caasgrafana",
59     "Vendor": "Something",
60     "Version": "4.4.1.9"
61 }
62
63 caas_grafana1_sub = {
64     "Name": "grafana",
65     "Version": "4.4.1.9",
66     "Source RPM": "caas.grafana-4.4.1.9-1.el7.centos.src.rpm",
67     "Source URL": "https://some/grafana/url",
68     "FOSS": "yes"
69 }
70
71 caas_grafana1_sub_new_field = deepcopy(caas_grafana1_sub)
72 caas_grafana1_sub_new_field['ABC'] = True
73
74 caas_grafana2 = _copy(caas_grafana1, 'caas.grafana', 'caas.grafana2')
75 caas_grafana2_sub = _copy(caas_grafana1_sub, 'caas.grafana', 'caas.grafana2')
76
77 caas_grafana3 = _copy(caas_grafana1, 'caas.grafana', 'caas.grafana3')
78 caas_grafana3_sub = _copy(caas_grafana1_sub, 'caas.grafana', 'caas.grafana3')
79
80 caas_grafana1_v2 = _copy(caas_grafana1, '4.4.1.9', '4.4.1.10')
81 caas_grafana1_v2sub = _copy(caas_grafana1_sub, '4.4.1.9', '4.4.1.10')
82
83 caas_grafana1_r2 = _copy(caas_grafana1, '1.el7.centos', '2.el7.centos')
84 caas_grafana1_r2sub = _copy(caas_grafana1_sub, '1.el7.centos', '2.el7.centos')
85
86 caas_abc1 = {
87     "License": "Commercial",
88     "Name": "caas-abc",
89     "Version": "v1",
90     "Release": "r1",
91     "Source RPM": "caas-abc-v1-r1.src.rpm",
92 }
93
94 caas_abc1_sub = {
95     "Name": "abc",
96     "Version": "v1",
97     "Source RPM": "caas-abc-v1-r1.src.rpm",
98 }
99 caas_abc1_r2 = _copy(caas_abc1, 'r1', 'r2')
100 caas_abc1_sub_r2 = _copy(caas_abc1_sub, 'r1', 'r2')
101
102 abc1 = {
103     "License": "GPL",
104     "Name": "abc",
105     "Version": "v1",
106     "Release": "r1",
107     "Source RPM": "abc-v1-r1.src.rpm",
108 }
109 abc1_v2 = _copy(abc1, 'v1', 'v2')
110 abc2 = _copy(abc1, 'abc', 'abc2')
111 abc3 = _copy(abc1, 'abc', 'abc3')
112
113 component_added = {
114     'Architecture': 'noarch',
115     'Build Date': 'Sun Nov 11 12:54:39 2018',
116     'Build Host': 'build-7.novalocal',
117     'Description': 'This RPM contains configuration management openstack configuration override '
118                    'plugin',
119     'FOSS': 'No',
120     'From repo': 'localrepo',
121     'Group': 'Unspecified',
122     'Install Date': 'Tue Nov 13 19:14:29 2018',
123     'Is sane': True,
124     'License': 'Commercial',
125     'Name': 'openstack-config-overrides-validator',
126     'Obsoletes': '',
127     'Packager': 'Something',
128     'Release': '1.el7.centos',
129     'Relocations': '(not relocatable)',
130     'Repo': 'installed',
131     'Repo data': {
132         'baseurl': 'https://jenkins/ci-build/2490/artifact/results/repo',
133         'name': 'localrepo'},
134     'Signature': '(none)',
135     'Size': '3097',
136     'Source RPM': 'openstack-config-overrides-validator-c2.gd1b7aec-1.el7.centos.src.rpm',
137     'Source repo data': {
138         'baseurl': 'https://jenkins/ci-build/2490/artifact/results/src_repo',
139         'name': 'localrepo'},
140     'Source to be delivered': 'No',
141     'Summary': 'Openstack configuration override CM validator plugin.',
142     'Vendor': 'Something',
143     'Version': 'c2.gd1b7aec'
144 }
145
146 component_removed = {
147     'Architecture': 'x86_64',
148     'Build Date': 'Thu Aug 16 14:46:11 2018',
149     'Build Host': 'x86-01.bsys.centos.org',
150     'Description': 'The fence-agents-ibmblade package contains a fence agent for IBM BladeCenter '
151                    'devices that are accessed via the SNMP protocol.',
152     'FOSS': 'Undefined',
153     'From repo': 'purkki-centos-updates',
154     'Group': 'System Environment/Base',
155     'Install Date': 'Wed Nov  7 21:20:01 2018',
156     'Is sane': False,
157     'License': 'GPLv2+ and LGPLv2+',
158     'Name': 'fence-agents-ibmblade',
159     'Obsoletes': 'fence-agents,',
160     'Packager': 'CentOS BuildSystem <http://bugs.centos.org>',
161     'Release': '86.el7_5.3',
162     'Relocations': '(not relocatable)',
163     'Repo': 'installed',
164     'Repo data': {
165         'baseurl': 'http://purkki/mirror/centos/snapshot/20181024/7/updates/x86_64/',
166         'exclude': 'libgudev1 httpd httpd-devel systemd-libs.i686 resource-agents '
167                    'dhcp-libs dhclient dhcp-common php-fpm php-common php-cli php',
168         'name': 'purkki-centos-updates'},
169     'Signature': 'RSA/SHA256, Mon Aug 20 14:15:17 2018, Key ID 24c6a8a7f4a80eb5',
170     'Size': '3898',
171     'Source RPM': 'fence-agents-4.0.11-86.el7_5.3.src.rpm',
172     'Source repo data': {
173         'baseurl': 'http://purkki/mirror/centos/snapshot/20181024/7/updates/Source/',
174         'name': 'purkki-centos-updates'},
175     'Source to be delivered': 'Undefined',
176     'Summary': 'Fence agent for IBM BladeCenter',
177     'URL': 'https://github.com/ClusterLabs/fence-agents',
178     'Vendor': 'CentOS',
179     'Version': '4.0.11'
180 }
181 component_changed_old = {
182     'Architecture': 'noarch',
183     'Build Date': 'Fri Oct 19 00:22:00 2018',
184     'Build Host': 'f32725a719ce4c82a53b44644dfd2718',
185     'Description': 'This RPM contains source code for the Authentication, Authorization and '
186                    'Accounting cli',
187     'FOSS': 'No',
188     'From repo': 'localrepo',
189     'Group': 'Unspecified',
190     'Install Date': 'Wed Nov  7 21:22:14 2018',
191     'Is sane': True,
192     'License': 'Commercial',
193     'Name': 'aaacli',
194     'Obsoletes': '',
195     'Packager': 'Something',
196     'Release': '2.el7.centos',
197     'Relocations': '(not relocatable)',
198     'Repo': 'installed',
199     'Repo data': {
200         'baseurl': 'https://jenkins/ci-build/2432/artifact/results/repo',
201         'name': 'localrepo'},
202     'Signature': '(none)',
203     'Size': '43968',
204     'Source RPM': 'aaacli-c12.gc62d348-2.el7.centos.src.rpm',
205     'Source repo data': {
206         'baseurl': 'https://jenkins/ci-build/2432/artifact/results/src_repo',
207         'name': 'localrepo'},
208     'Source to be delivered': 'No',
209     'Summary': 'Authentication, Authorization and Accounting Command Line Interface',
210     'Vendor': 'Something',
211     'Version': 'c12.gc62d348'
212 }
213
214 component_changed_new = {
215     'Architecture': 'noarch',
216     'Build Date': 'Thu Nov  8 05:05:07 2018',
217     'Build Host': 'build-3.novalocal',
218     'Description': 'This RPM contains source code for the Authentication, '
219                    'Authorization and Accounting cli',
220     'FOSS': 'No',
221     'From repo': 'localrepo',
222     'Group': 'Unspecified',
223     'Install Date': 'Tue Nov 13 19:09:30 2018',
224     'Is sane': True,
225     'License': 'Commercial',
226     'Name': 'aaacli',
227     'Obsoletes': '',
228     'Packager': 'Something',
229     'Release': '1.el7.centos',
230     'Relocations': '(not relocatable)',
231     'Repo': 'installed',
232     'Repo data': {
233         'baseurl': 'https://jenkins/ci-build/2490/artifact/results/repo',
234         'name': 'localrepo'},
235     'Signature': '(none)',
236     'Size': '44034',
237     'Source RPM': 'aaacli-c13.gcb6b490-1.el7.centos.src.rpm',
238     'Source repo data': {
239         'baseurl': 'https://jenkins/ci-build/2490/artifact/results/src_repo',
240         'name': 'localrepo'},
241     'Source to be delivered': 'No',
242     'Summary': 'Authentication, Authorization and Accounting Command Line Interface',
243     'Vendor': 'Something',
244     'Version': 'c13.gcb6b490'
245 }
246
247 grafana_v1 = {
248     'Architecture': 'x86_64',
249     'Build Date': 'Mon Sep 17 14:30:25 2018',
250     'Build Host': 'd8fb00edf57f4254bb45073a941929ff',
251     'Description': 'Grafana is an open source, feature rich metrics dashboard and graph '
252                    'editor for\nGraphite, InfluxDB & OpenTSDB.',
253     'FOSS': 'Modified',
254     'From repo': 'localrepo',
255     'Group': 'Unspecified',
256     'Install Date': 'Fri Nov 16 02:23:02 2018',
257     'Is sane': True,
258     'License': 'Commercial and  ASL 2.0 and others',
259     'Name': 'grafana',
260     'Obsoletes': '',
261     'Packager': 'Something',
262     'Release': '1.el7.centos.1',
263     'Relocations': '(not relocatable)',
264     'Repo': 'installed',
265     'Repo data': {
266         'baseurl': 'https://jenkins/ci-build/2506/artifact/results/repo',
267         'name': 'localrepo'},
268     'Signature': '(none)',
269     'Size': '93957067',
270     'Source RPM': 'grafana-5.2.3-1.el7.centos.1.src.rpm',
271     'Source repo data': {
272         'baseurl': 'https://jenkins/ci-build/2506/artifact/results/src_repo',
273         'name': 'localrepo'},
274     'Source to be delivered': 'Upstream',
275     'Summary': 'Grafana is an open source, feature rich metrics dashboard and graph editor',
276     'URL': 'https://github.com/grafana/grafana',
277     'Vendor': 'Something and Grafana modified',
278     'Version': '5.2.3'
279 }
280
281 grafana_v2 = _copy(grafana_v1, '1.el7.centos.1', '1.el7.centos.2')