Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 1 | #!/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 | |
| 23 | bats_require_minimum_version 1.5.0 |
| 24 | |
| 25 | ## ----------------------------------------------------------------------- |
| 26 | # This runs before each of the following tests are executed. |
| 27 | ## ----------------------------------------------------------------------- |
| 28 | setup() { |
| 29 | source './utils/check_repo_tags.sh' |
| 30 | |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 31 | ## 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 Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 40 | } |
| 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 Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 54 | 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 Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 60 | voltha-docs) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 61 | if [[ -v enable_skip ]]; then |
| 62 | skip 'declare -a gerrit=([0]="2.12.35")' |
| 63 | fi |
| 64 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 65 | ;; |
| 66 | voltha-lib-go) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 67 | if [[ -v enable_skip ]]; then |
| 68 | skip 'declare -a gerrit=([0]="7.5.3")' |
| 69 | fi |
| 70 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 71 | ;; |
| 72 | voltha-onos) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 73 | if [[ -v enable_skip ]]; then |
| 74 | skip 'declare -a gerrit=([0]="2.11.0")' |
| 75 | fi |
| 76 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 77 | ;; |
Joey Armstrong | daa1f0a | 2024-04-03 18:07:59 -0400 | [diff] [blame] | 78 | voltha-openolt-adapter) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 79 | if [[ -v enable_skip ]]; then |
| 80 | skip 'declare -a gerrit=([0]="4.4.10")' |
| 81 | fi |
| 82 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 83 | ;; |
| 84 | voltha-openonu-adapter-go) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 85 | if [[ -v enable_skip ]]; then |
| 86 | skip 'declare -a gerrit=([0]="2.12.0~beta")' |
| 87 | fi |
| 88 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 89 | ;; |
| 90 | voltha-protos) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 91 | if [[ -v enable_skip ]]; then |
| 92 | skip 'declare -a gerrit=([0]="5.4.11")' |
| 93 | fi |
| 94 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 95 | ;; |
| 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 Armstrong | daa1f0a | 2024-04-03 18:07:59 -0400 | [diff] [blame] | 112 | |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 113 | ## ----------------------------------------- |
| 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 Armstrong | daa1f0a | 2024-04-03 18:07:59 -0400 | [diff] [blame] | 123 | |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 124 | local component |
| 125 | for component in "${components[@]}"; |
| 126 | do |
| 127 | ## -------------- |
| 128 | ## Known problems |
| 129 | ## -------------- |
| 130 | case "$component" in |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 131 | 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 Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 136 | ;; |
| 137 | voltha-onos) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 138 | if [[ -v enable_skip ]]; then |
| 139 | skip "declare -a gerrit=([0]="2.12.0~beta")" |
| 140 | fi |
| 141 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 142 | ;; |
| 143 | voltha-lib-go) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 144 | if [[ -v enable_skip ]]; then |
| 145 | skip "declare -a gerrit=([0]="7.6.0")" |
| 146 | fi |
| 147 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 148 | ;; |
| 149 | voltha-openolt-adapter) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 150 | if [[ -v enable_skip ]]; then |
| 151 | skip "declare -a gerrit=([0]="4.4.11")" |
| 152 | fi |
| 153 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 154 | ;; |
| 155 | voltha-protos) |
Joey Armstrong | 8a765ba | 2024-03-27 10:27:29 -0400 | [diff] [blame] | 156 | if [[ -v enable_skip ]]; then |
| 157 | skip 'declare -a gerrit=([0]="5.5.0")' |
| 158 | fi |
| 159 | [[ ! -v enable_fatal ]] && { continue; } |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 160 | ;; |
| 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 | |
| 186 | 1) 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. |
| 191 | EOM |
| 192 | |
| 193 | [ true ] |
| 194 | } |
| 195 | |
| 196 | # [EOF] |