blob: 6470393980dd2b23653e8ea746ff2f9a535be624 [file] [log] [blame]
Joey Armstrong5c135fe2024-03-25 16:45:55 -04001#!/usr/bin/env bats
2# -----------------------------------------------------------------------
3# Copyright 2024 Open Networking Foundation Contributors
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain 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,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
17# SPDX-FileCopyrightText: 2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------#
20# Source: /sandbox/ci-management/jjb/pipeline/voltha/software-upgrades.groovy
21# -----------------------------------------------------------------------
22
23bats_require_minimum_version 1.5.0
24
25## -----------------------------------------------------------------------
26# This runs before each of the following tests are executed.
27## -----------------------------------------------------------------------
28setup() {
29 source './utils/check_repo_tags.sh'
30
Joey Armstrong8a765ba2024-03-27 10:27:29 -040031 ## Slurp a list of repositories to query
32 readarray -t buffer < 'conf/repos/voltha'
33 declare -g -a components=("${buffer[0]}")
34
35 # Uncomment for raw test results
36 # declare -g -i enable_fatal=1
37
38 # Uncomment to skip remaining checks within a test.
39 # declare -g -i enable_skip=1
Joey Armstrong5c135fe2024-03-25 16:45:55 -040040}
41
42## -----------------------------------------------------------------------
43## Intent:
44## -----------------------------------------------------------------------
45@test 'Validate comp_deploy_tag()' {
46
47 local component
48 for component in "${components[@]}";
49 do
50 ## --------------
51 ## Known problems
52 ## --------------
53 case "$component" in
Joey Armstrong8a765ba2024-03-27 10:27:29 -040054 device-management-interface)
55 if [[ -v enable_skip ]]; then
56 skip 'declare -a gerrit=([0]="1.15.0")'
57 fi
58 [[ ! -v enable_fatal ]] && { continue; }
59 ;;
Joey Armstrong5c135fe2024-03-25 16:45:55 -040060 voltha-docs)
Joey Armstrong8a765ba2024-03-27 10:27:29 -040061 if [[ -v enable_skip ]]; then
62 skip 'declare -a gerrit=([0]="2.12.35")'
63 fi
64 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -040065 ;;
66 voltha-lib-go)
Joey Armstrong8a765ba2024-03-27 10:27:29 -040067 if [[ -v enable_skip ]]; then
68 skip 'declare -a gerrit=([0]="7.5.3")'
69 fi
70 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -040071 ;;
72 voltha-onos)
Joey Armstrong8a765ba2024-03-27 10:27:29 -040073 if [[ -v enable_skip ]]; then
74 skip 'declare -a gerrit=([0]="2.11.0")'
75 fi
76 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -040077 ;;
Joey Armstrongdaa1f0a2024-04-03 18:07:59 -040078 voltha-openolt-adapter)
Joey Armstrong8a765ba2024-03-27 10:27:29 -040079 if [[ -v enable_skip ]]; then
80 skip 'declare -a gerrit=([0]="4.4.10")'
81 fi
82 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -040083 ;;
84 voltha-openonu-adapter-go)
Joey Armstrong8a765ba2024-03-27 10:27:29 -040085 if [[ -v enable_skip ]]; then
86 skip 'declare -a gerrit=([0]="2.12.0~beta")'
87 fi
88 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -040089 ;;
90 voltha-protos)
Joey Armstrong8a765ba2024-03-27 10:27:29 -040091 if [[ -v enable_skip ]]; then
92 skip 'declare -a gerrit=([0]="5.4.11")'
93 fi
94 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -040095 ;;
96 esac
97
98 # local component='voltha-openonu-adapter-go'
99 declare -a gerrit=()
100 gather_comp_deploy gerrit "http://gerrit.opencord.org/${component}"
101
102 declare -a github=()
103 gather_comp_deploy gerrit "http://github.com/opencord/${component}"
104
105 printf "\nCOMPONENT: %s\n" "$component" 1>&2
106 declare -p gerrit 1>&2
107 declare -p github 1>&2
108
109 ## Check for deltas
110 [[ "${gerrit[*]}" == "${github[@]}" ]]
111 done
Joey Armstrongdaa1f0a2024-04-03 18:07:59 -0400112
Joey Armstrong5c135fe2024-03-25 16:45:55 -0400113 ## -----------------------------------------
114 ## Compare by size, filtered list is smaller
115 ## -----------------------------------------
116 [ true ]
117}
118
119## -----------------------------------------------------------------------
120## Intent: Compare tags between gerrit and github repositories
121## -----------------------------------------------------------------------
122@test 'Validate comp_test_tag()' {
Joey Armstrongdaa1f0a2024-04-03 18:07:59 -0400123
Joey Armstrong5c135fe2024-03-25 16:45:55 -0400124 local component
125 for component in "${components[@]}";
126 do
127 ## --------------
128 ## Known problems
129 ## --------------
130 case "$component" in
Joey Armstrong8a765ba2024-03-27 10:27:29 -0400131 device-management-interface)
132 if [[ -v enable_skip ]]; then
133 skip 'declare -a gerrit=([0]="1.16.0")'
134 fi
135 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -0400136 ;;
137 voltha-onos)
Joey Armstrong8a765ba2024-03-27 10:27:29 -0400138 if [[ -v enable_skip ]]; then
139 skip "declare -a gerrit=([0]="2.12.0~beta")"
140 fi
141 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -0400142 ;;
143 voltha-lib-go)
Joey Armstrong8a765ba2024-03-27 10:27:29 -0400144 if [[ -v enable_skip ]]; then
145 skip "declare -a gerrit=([0]="7.6.0")"
146 fi
147 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -0400148 ;;
149 voltha-openolt-adapter)
Joey Armstrong8a765ba2024-03-27 10:27:29 -0400150 if [[ -v enable_skip ]]; then
151 skip "declare -a gerrit=([0]="4.4.11")"
152 fi
153 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -0400154 ;;
155 voltha-protos)
Joey Armstrong8a765ba2024-03-27 10:27:29 -0400156 if [[ -v enable_skip ]]; then
157 skip 'declare -a gerrit=([0]="5.5.0")'
158 fi
159 [[ ! -v enable_fatal ]] && { continue; }
Joey Armstrong5c135fe2024-03-25 16:45:55 -0400160 ;;
161 esac
162
163 # local component='voltha-openonu-adapter-go'
164 declare -a gerrit=()
165 gather_comp_test gerrit "http://gerrit.opencord.org/${component}"
166
167 declare -a github=()
168 gather_comp_test gerrit "http://github.com/opencord/${component}"
169
170 printf "\nCOMPONENT: %s\n" "$component" 1>&2
171 declare -p gerrit 1>&2
172 declare -p github 1>&2
173
174 ## Check for deltas
175 [[ "${gerrit[*]}" == "${github[@]}" ]]
176 done
177}
178
179## -----------------------------------------------------------------------
180## Intent:
181## -----------------------------------------------------------------------
182@test 'todo()' {
183
184 cat <<EOM
185
1861) Compare repository branches and tags:
187 - Iterate over all repositories.
188 - Retrieve branches and tags from gerrit.
189 - Retrieve branches and tags from github.
190 - Compare contents for discrepancies.
191EOM
192
193 [ true ]
194}
195
196# [EOF]