BjornMagnussonXA | 663566c | 2021-11-08 10:25:07 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # ============LICENSE_START=============================================== |
| 4 | # Copyright (C) 2020 Nordix Foundation. All rights reserved. |
| 5 | # ======================================================================== |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # ============LICENSE_END================================================= |
| 18 | # |
| 19 | |
| 20 | # This is a script that contains container/service management functions |
| 21 | # for PVCCLEANER |
| 22 | |
| 23 | ################ Test engine functions ################ |
| 24 | |
| 25 | # Create the image var used during the test |
| 26 | # arg: <image-tag-suffix> (selects staging, snapshot, release etc) |
| 27 | # <image-tag-suffix> is present only for images with staging, snapshot,release tags |
| 28 | __PVCCLEANER_imagesetup() { |
| 29 | __check_and_create_image_var PVCCLEANER "PVC_CLEANER_IMAGE" "PVC_CLEANER_IMAGE_BASE" "PVC_CLEANER_IMAGE_TAG" REMOTE_PROXY "$PVC_CLEANER_DISPLAY_NAME" |
| 30 | } |
| 31 | |
| 32 | # Pull image from remote repo or use locally built image |
| 33 | # arg: <pull-policy-override> <pull-policy-original> |
| 34 | # <pull-policy-override> Shall be used for images allowing overriding. For example use a local image when test is started to use released images |
| 35 | # <pull-policy-original> Shall be used for images that does not allow overriding |
| 36 | # Both var may contain: 'remote', 'remote-remove' or 'local' |
| 37 | __PVCCLEANER_imagepull() { |
| 38 | __check_and_pull_image $1 "$PVC_CLEANER_DISPLAY_NAME" $PVC_CLEANER_APP_NAME PVC_CLEANER_IMAGE |
| 39 | } |
| 40 | |
| 41 | # Build image (only for simulator or interfaces stubs owned by the test environment) |
| 42 | # arg: <image-tag-suffix> (selects staging, snapshot, release etc) |
| 43 | # <image-tag-suffix> is present only for images with staging, snapshot,release tags |
| 44 | __PVCCLEANER_imagebuild() { |
| 45 | echo -e $RED"Image for app PVCCLEANER shall never be built"$ERED |
| 46 | } |
| 47 | |
| 48 | # Generate a string for each included image using the app display name and a docker images format string |
| 49 | # If a custom image repo is used then also the source image from the local repo is listed |
| 50 | # arg: <docker-images-format-string> <file-to-append> |
| 51 | __PVCCLEANER_image_data() { |
| 52 | echo -e "$PVC_CLEANER_DISPLAY_NAME\t$(docker images --format $1 $PVC_CLEANER_IMAGE)" >> $2 |
| 53 | if [ ! -z "$PVC_CLEANER_IMAGE_SOURCE" ]; then |
| 54 | echo -e "-- source image --\t$(docker images --format $1 $PVC_CLEANER_IMAGE_SOURCE)" >> $2 |
| 55 | fi |
| 56 | } |
| 57 | |
| 58 | # Scale kubernetes resources to zero |
| 59 | # All resources shall be ordered to be scaled to 0, if relevant. If not relevant to scale, then do no action. |
| 60 | # This function is called for apps fully managed by the test script |
| 61 | __PVCCLEANER_kube_scale_zero() { |
| 62 | : |
| 63 | } |
| 64 | |
| 65 | # Scale kubernetes resources to zero and wait until this has been accomplished, if relevant. If not relevant to scale, then do no action. |
| 66 | # This function is called for prestarted apps not managed by the test script. |
| 67 | __PVCCLEANER_kube_scale_zero_and_wait() { |
| 68 | : |
| 69 | } |
| 70 | |
| 71 | # Delete all kube resouces for the app |
| 72 | # This function is called for apps managed by the test script. |
| 73 | __PVCCLEANER_kube_delete_all() { |
| 74 | : |
| 75 | } |
| 76 | |
| 77 | # Store docker logs |
| 78 | # This function is called for apps managed by the test script. |
| 79 | # args: <log-dir> <file-prexix> |
| 80 | __PVCCLEANER_store_docker_logs() { |
| 81 | if [ $RUNMODE == "KUBE" ]; then |
| 82 | kubectl logs -l "autotest=PRODSTUB" -A --tail=-1 > $1$2_pvs_cleaner.log 2>&1 |
| 83 | fi |
| 84 | } |
| 85 | |
| 86 | # Initial setup of protocol, host and ports |
| 87 | # This function is called for apps managed by the test script. |
| 88 | # args: - |
| 89 | __PVCCLEANER_initial_setup() { |
| 90 | : |
| 91 | } |
| 92 | |
BjornMagnussonXA | 6fc58fd | 2021-11-18 08:19:45 +0100 | [diff] [blame] | 93 | # Set app short-name, app name and namespace for logging runtime statistics of kubernets pods or docker containers |
| 94 | # For docker, the namespace shall be excluded |
| 95 | # This function is called for apps managed by the test script as well as for prestarted apps. |
| 96 | # args: - |
| 97 | __PVCCLEANER_statisics_setup() { |
| 98 | echo "" |
| 99 | } |
| 100 | |
BjornMagnussonXA | 663566c | 2021-11-08 10:25:07 +0100 | [diff] [blame] | 101 | ####################################################### |
| 102 | |
| 103 | # This is a system app, all usage in testcase_common.sh |