github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/tests/performance/scripts/update_configmap.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright 2019 The KubeEdge Authors.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #    http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  SRC_DIR=${GOPATH}/src/github.com/kubeedge/kubeedge
    17  EDGE_PATH=${SRC_DIR}/tests/performance/assets/02-edgeconfigmap.yaml
    18  CLOUD_PATH=${SRC_DIR}/tests/performance/assets/01-configmap.yaml
    19  
    20  nodename=$2
    21  Url=$3
    22  configmapName=$4
    23  nodelimit=$5
    24  
    25  
    26  create_edge_config() {
    27      if [ ! -f ${EDGE_PATH} ]; then
    28          echo "There is no 03-configmap-edgenodeconf.yaml!"
    29          exit 1
    30      fi
    31      echo "file found !!!!!!!!!!!!!"
    32      sed -i "s|namespace: .*|namespace: default|g" ${EDGE_PATH}
    33      sed -i "s|name: edgecore-configmap.*|name: ${configmapName}|g" ${EDGE_PATH}
    34      sed -i "s|node-id: .*|node-id: ${nodename}|g" ${EDGE_PATH}
    35      sed -i "s|hostname-override: .*|hostname-override: ${nodename}|g" ${EDGE_PATH}
    36      if [[ ${Url} == *"wss"* ]]; then
    37          sed -i "20s|url: .*|url: ${Url}/e632aba927ea4ac2b575ec1603d56f10/${nodename}/events|g" ${EDGE_PATH}
    38          sed -i "s|protocol: .*|protocol: websocket|g" ${EDGE_PATH}
    39      else
    40          sed -i "28s|url: .*|url: ${Url}|g" ${EDGE_PATH}
    41          sed -i "s|protocol: .*|protocol: quic|g" ${EDGE_PATH}
    42      fi
    43  }
    44  
    45  create_cloud_config() {
    46      if [ ! -f ${CLOUD_PATH} ]; then
    47          echo "There is no 01-configmap.yaml!"
    48          exit 1
    49      fi
    50      echo "file found !!!!!!!!!!!!!"
    51      sed -i "s|master: .*|master: ${Url}|g" ${CLOUD_PATH}
    52      sed -i "s|name: .*|name: ${configmapName}|g" ${CLOUD_PATH}
    53      sed -i "s|node-limit: .*|node-limit: ${nodelimit}|g" ${CLOUD_PATH}
    54  }
    55  
    56  "$@"