github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/test/integration/test-package-management.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 and local folder
    10  rm -rf $CL_HOME/dropins
    11  rm -rf $CL_HOME/current
    12  rm -f $CL_HOME/config.json
    13  mkdir -p $CL_HOME/dropins
    14  
    15  # copy the example to the dropin folder for the test
    16  cp -R $SCRIPT_DIR/../packages-src/bonjour $CL_HOME/dropins
    17  
    18  # download remote package
    19  RESULT=$($OUTPUT_DIR/cl config command_repository_base_url https://raw.githubusercontent.com/criteo/command-launcher/main/examples/remote-repo)
    20  RESULT=$($OUTPUT_DIR/cl)
    21  
    22  ################
    23  echo "> test list all packages"
    24  RESULT=$($CL_PATH package list)
    25  
    26  echo "* should contain managed packages section"
    27  echo "$RESULT" | grep -q "=== Managed Repository: Default ==="
    28  if [ $? -eq 0 ]; then
    29    echo "OK"
    30  else
    31    echo "KO - should have Default Managed Repository section"
    32    exit 1
    33  fi
    34  
    35  echo "* should contain 'command-launcher-demo' package as local package"
    36  echo "$RESULT" | grep -q "\- command-launcher-demo"
    37  if [ $? -eq 0 ]; then
    38    echo "OK"
    39  else
    40    echo "KO - should contain local package 'command-launcher-demo'"
    41    exit 1
    42  fi
    43  
    44  echo "* should contain dropin packages section"
    45  echo "$RESULT" | grep -q "=== Dropin Repository ==="
    46  if [ $? -eq 0 ]; then
    47    echo "OK"
    48  else
    49    echo "KO - should have Dropin Repository section"
    50    exit 1
    51  fi
    52  
    53  echo "* should contain 'bonjour' package as dropin"
    54  echo "$RESULT" | grep -q "\- bonjour"
    55  if [ $? -eq 0 ]; then
    56    echo "OK"
    57  else
    58    echo "KO - should contain dropin package 'bonjour'"
    59    exit 1
    60  fi
    61  
    62  ################
    63  echo "> test list --dropin command"
    64  RESULT=$($CL_PATH package list --dropin)
    65  
    66  echo "* should contain dropin packages section"
    67  echo "$RESULT" | grep -q "=== Dropin Repository ==="
    68  if [ $? -eq 0 ]; then
    69    echo "OK"
    70  else
    71    echo "KO - should have Dropin Repository section"
    72    exit 1
    73  fi
    74  
    75  echo "* should contain 'bonjour' package as dropin"
    76  echo "$RESULT" | grep -q "\- bonjour"
    77  if [ $? -eq 0 ]; then
    78    echo "OK"
    79  else
    80    echo "KO - should contain dropin package 'bonjour'"
    81    exit 1
    82  fi
    83  
    84  echo "* should NOT contain local packages section"
    85  echo "$RESULT" | grep -q "=== Local Repository ==="
    86  if [ $? -ne 0 ]; then
    87    echo "OK"
    88  else
    89    echo "KO - should NOT have Local Repository section"
    90    exit 1
    91  fi
    92  
    93  ################
    94  echo "> test list --local command"
    95  RESULT=$($CL_PATH package list --local)
    96  
    97  echo "* should contain local packages section"
    98  echo "$RESULT" | grep -q "=== Managed Repository: Default ==="
    99  if [ $? -eq 0 ]; then
   100    echo "OK"
   101  else
   102    echo "KO - should have Local Repository section"
   103    exit 1
   104  fi
   105  
   106  echo "* should contain 'command-launcher-demo' package as local package"
   107  echo "$RESULT" | grep -q "\- command-launcher-demo"
   108  if [ $? -eq 0 ]; then
   109    echo "OK"
   110  else
   111    echo "KO - should contain local package 'command-launcher-demo'"
   112    exit 1
   113  fi
   114  
   115  echo "* should NOT contain dropin packages section"
   116  echo "$RESULT" | grep -q "=== Dropin Repository ==="
   117  if [ $? -ne 0 ]; then
   118    echo "OK"
   119  else
   120    echo "KO - should NOT have Dropin Repository section"
   121    exit 1
   122  fi
   123  
   124  ################
   125  echo "> test list local --include-cmd"
   126  RESULT=$($CL_PATH package list --local --include-cmd)
   127  
   128  echo "* should contain package version"
   129  echo "$RESULT" | grep -q "1.0.0"
   130  if [ $? -eq 0 ]; then
   131    echo "OK"
   132  else
   133    echo "KO - should contain package version"
   134    exit 1
   135  fi
   136  
   137  echo "* should contain group"
   138  echo "$RESULT" | grep -q "* __no_group__                                      (group)"
   139  if [ $? -eq 0 ]; then
   140    echo "OK"
   141  else
   142    echo "KO - should contain __no_group__"
   143    exit 1
   144  fi
   145  
   146  echo "* should contain command"
   147  echo "$RESULT" | grep -q "\- hello                                           (cmd)"
   148  if [ $? -eq 0 ]; then
   149    echo "OK"
   150  else
   151    echo "KO - should contain command"
   152    exit 1
   153  fi
   154  
   155  ################
   156  echo "> test list dropin --include-cmd"
   157  RESULT=$($CL_PATH package list --dropin --include-cmd)
   158  
   159  echo "* should contain package version"
   160  echo "$RESULT" | grep -q "\- bonjour                                            1.0.0"
   161  if [ $? -eq 0 ]; then
   162    echo "OK"
   163  else
   164    echo "KO - should contain package version"
   165    exit 1
   166  fi
   167  
   168  echo "* should contain group"
   169  echo "$RESULT" | grep -q "* __no_group__                                      (group)"
   170  if [ $? -eq 0 ]; then
   171    echo "OK"
   172  else
   173    echo "KO - should contain __no_group__"
   174    exit 1
   175  fi
   176  
   177  echo "* should contain command"
   178  echo "$RESULT" | grep -q "\- bonjour                                         (cmd)"
   179  if [ $? -eq 0 ]; then
   180    echo "OK"
   181  else
   182    echo "KO - should contain command"
   183    exit 1
   184  fi
   185  
   186  ################
   187  echo "> test list remote"
   188  RESULT=$($CL_PATH package list --remote)
   189  
   190  echo "* should contain remote package and version"
   191  echo "$RESULT" | grep -q "\- command-launcher-demo                              1.0.0"
   192  if [ $? -eq 0 ]; then
   193    echo "OK"
   194  else
   195    echo "KO - should contain remote package and version"
   196    exit 1
   197  fi
   198  
   199  echo "* should contain remote section"
   200  echo "$RESULT" | grep -q "=== Remote Registry: Default ==="
   201  if [ $? -eq 0 ]; then
   202    echo "OK"
   203  else
   204    echo "KO - should contain remote section"
   205    exit 1
   206  fi
   207  
   208  ################
   209  echo "> test install git package"
   210  RESULT=$($CL_PATH package install --git https://github.com/criteo/command-launcher-package-example)
   211  RESULT=$($CL_PATH package list --dropin --include-cmd)
   212  
   213  echo "* should contain package from git repo"
   214  echo "$RESULT" | grep -q "\- command-launcher-example-package                   0.0.1"
   215  if [ $? -eq 0 ]; then
   216    echo "OK"
   217  else
   218    echo "KO - should contain package from git repo"
   219    exit 1
   220  fi
   221  
   222  echo "* should contain group command from git repo"
   223  echo "$RESULT" | grep -q "* cola-example                                      (group)"
   224  if [ $? -eq 0 ]; then
   225    echo "OK"
   226  else
   227    echo "KO - should contain group command from git repo"
   228    exit 1
   229  fi
   230  
   231  echo "* should contain greeting command from git repo"
   232  echo "$RESULT" | grep -q "\- greeting                                        (cmd)"
   233  if [ $? -eq 0 ]; then
   234    echo "OK"
   235  else
   236    echo "KO - should contain greeting command from git repo"
   237    exit 1
   238  fi
   239  
   240  ################
   241  echo "> test delete dropin package"
   242  RESULT=$($CL_PATH package delete command-launcher-example-package)
   243  if [ $? -eq 0 ]; then
   244    echo "OK"
   245  else
   246    echo "KO - delete should exit 0"
   247    exit 1
   248  fi
   249  
   250  echo "* should NOT contain package from git repo"
   251  RESULT=$($CL_PATH package list --dropin --include-cmd)
   252  echo "$RESULT" | grep -q "\- command-launcher-example-package                   0.0.1"
   253  if [ $? -ne 0 ]; then
   254    echo "OK"
   255  else
   256    echo "KO - should NOT contain package from git repo"
   257    exit 1
   258  fi
   259  
   260  ################
   261  echo "> test install file package"
   262  RESULT=$($CL_PATH package install --file https://github.com/criteo/command-launcher/raw/main/test/remote-repo/command-launcher-demo-2.0.0.pkg)
   263  
   264  echo "* should contain 2.0.0 demo package"
   265  RESULT=$($CL_PATH package list --dropin --include-cmd)
   266  echo "$RESULT" | grep -q "\- command-launcher-demo                              2.0.0"
   267  if [ $? -eq 0 ]; then
   268    echo "OK"
   269  else
   270    echo "KO - should contain 2.0.0 demo package"
   271    exit 1
   272  fi
   273  
   274  ###############
   275  echo "> test setup package"
   276  RESULT=$($CL_PATH package setup command-launcher-example-package)
   277  echo "$RESULT" | grep -q "no setup hook found"
   278  if [ $? -ne 0 ]; then
   279    echo "OK"
   280  else
   281    echo "KO - should prompt no setup hook found"
   282    exit 1
   283  fi