github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/test/integration/test-extra-remote-cmd.sh (about)

     1  #!/bin/bash
     2  
     3  # availeble environment varibale
     4  # CL_PATH: the path of the command launcher binary
     5  # CL_HOME: the path of the command launcher home directory
     6  # OUTPUT_DIR: the output folder
     7  SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
     8  
     9  # clean up the dropin folder
    10  rm -rf $CL_HOME/dropins
    11  mkdir -p $CL_HOME/dropins
    12  
    13  echo "> test download default remote command"
    14  RESULT=$($OUTPUT_DIR/cl config command_repository_base_url https://raw.githubusercontent.com/criteo/command-launcher/main/examples/remote-repo)
    15  RESULT=$($OUTPUT_DIR/cl)
    16  
    17  echo "* should have hello command installed"
    18  echo "$RESULT" | grep -q "hello"
    19  if [ $? -eq 0 ]; then
    20    # ok
    21    echo "OK"
    22  else
    23    echo "KO - hello command should exist"
    24    exit 1
    25  fi
    26  
    27  echo "* should contain default remote registry"
    28  RESULT=$($CL_PATH remote list)
    29  echo "$RESULT"
    30  echo "$RESULT" | grep -q "default         : https://raw.githubusercontent.com/criteo/command-launcher/main/examples/remote-repo"
    31  if [ $? -eq 0 ]; then
    32    # ok
    33    echo "OK"
    34  else
    35    echo "KO - should contain default remote registry"
    36    exit 1
    37  fi
    38  
    39  
    40  echo "> test add extra remote registry"
    41  RESULT=$($CL_PATH remote add extra1 https://raw.githubusercontent.com/criteo/command-launcher/main/test/remote-repo)
    42  RESULT=$($CL_PATH remote list)
    43  
    44  echo "* should contain default remote registry"
    45  echo "$RESULT" | grep -q "default         : https://raw.githubusercontent.com/criteo/command-launcher/main/examples/remote-repo"
    46  if [ $? -eq 0 ]; then
    47    # ok
    48    echo "OK"
    49  else
    50    echo "KO - should contain default remote registry"
    51    exit 1
    52  fi
    53  
    54  echo "* should contain extra remote registry"
    55  echo "$RESULT" | grep -q "extra1          : https://raw.githubusercontent.com/criteo/command-launcher/main/test/remote-repo"
    56  if [ $? -eq 0 ]; then
    57    # ok
    58    echo "OK"
    59  else
    60    echo "KO - should contain extra remote registry"
    61    exit 1
    62  fi
    63  
    64  echo "* should contain extra command: 'bonjour'"
    65  RESULT=$($CL_PATH)
    66  echo "$RESULT" | grep -q "bonjour"
    67  if [ $? -eq 0 ]; then
    68    # ok
    69    echo "OK"
    70  else
    71    echo "KO - should contain extra command 'bonjour'"
    72    exit 1
    73  fi
    74  
    75  echo "* should contain auto-renamed command: 'hello@@command-launcher-demo@extra1'"
    76  echo "$RESULT" | grep -q "hello@@command-launcher-demo@extra1"
    77  if [ $? -eq 0 ]; then
    78    # ok
    79    echo "OK"
    80  else
    81    echo "KO - should contain auto-renamed command 'hello@@command-launcher-demo@extra1'"
    82    exit 1
    83  fi
    84  
    85  echo "* should be able to run 'hello@@command-launcher-demo@extra1'"
    86  RESULT=$($CL_PATH hello@@command-launcher-demo@extra1)
    87  echo "$RESULT" | grep -q "Hello World v2!"
    88  if [ $? -eq 0 ]; then
    89    # ok
    90    echo "OK"
    91  else
    92    echo "KO - should successfully run command 'hello@@command-launcher-demo@extra1'"
    93    exit 1
    94  fi
    95  
    96  echo "* should be able to run 'hello'"
    97  RESULT=$($CL_PATH hello)
    98  echo "$RESULT" | grep -q "Hello World!"
    99  if [ $? -eq 0 ]; then
   100    # ok
   101    echo "OK"
   102  else
   103    echo "KO - should successfully run command 'hello'"
   104    exit 1
   105  fi
   106  
   107  echo "> test delete extra remote registry"
   108  RESULT=$($CL_PATH remote delete extra1)
   109  RESULT=$($CL_PATH remote list)
   110  echo "$RESULT" | grep -q "default         : https://raw.githubusercontent.com/criteo/command-launcher/main/examples/remote-repo"
   111  if [ $? -eq 0 ]; then
   112    # ok
   113    echo "OK"
   114  else
   115    echo "KO - should contain default remote registry"
   116    exit 1
   117  fi
   118  
   119  echo "* should NOT contain default remote registry"
   120  echo "$RESULT" | grep -q "extra1          : https://raw.githubusercontent.com/criteo/command-launcher/main/test/remote-repo"
   121  if [ $? -eq 0 ]; then
   122    echo "KO - should NOT contain extra remote registry"
   123    exit 1
   124  else
   125    echo "OK"
   126  fi
   127  
   128  echo "* should NOT contain extra command"
   129  RESULT=$($CL_PATH)
   130  echo "$RESULT" | grep -q "bonjour"
   131  if [ $? -eq 0 ]; then
   132    echo "KO - should NOT contain extra command 'bonjour'"
   133    exit 1
   134  else
   135    echo "OK"
   136  fi
   137  
   138