github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/functional/tests/shell.exp (about)

     1  #!/usr/bin/expect
     2  
     3  spawn $env(SHELL)
     4  
     5  Feature: "Shell"
     6  
     7  Scenario: "Open a shell on a service container" {
     8    set shell1 [prefixed_project shell1]
     9    create_project $shell1
    10    create_service $shell1 hosting1
    11  
    12    sleep 5
    13    send "$::bin shell\r"
    14    expect {
    15      timeout { handle_timeout; break }
    16      "Please*select*a service from the list below"
    17    }
    18    expect {
    19      timeout { handle_timeout; break }
    20      "Type service ID or #"
    21    }
    22    send "1\r"
    23    set instances [get_container_ids $shell1 hosting1]
    24    set instance_1 [string range [lindex $instances 0] 0 11]
    25    expect {
    26      timeout { exit_shell; handle_timeout; break }
    27      "You are now accessing instance *$instance_1"
    28    }
    29    expect {
    30      timeout { exit_shell; handle_timeout; break }
    31      "Warning: don't use this shell to make changes on your services."
    32    }
    33    expect {
    34      timeout { exit_shell; handle_timeout; break }
    35      "/wedeploy-container"
    36    }
    37    send "ls\r"
    38    expect {
    39      timeout { exit_shell; handle_timeout; break }
    40      "index.html"
    41    }
    42    expect {
    43      timeout { exit_shell; handle_timeout; break }
    44      "/wedeploy-container"
    45    }
    46    send "exit\r"
    47    expect {
    48      timeout { handle_timeout; break }
    49      "/$::_root_dir"
    50    }
    51  } { delete_project $shell1 }
    52  
    53  Scenario: "Open a shell on a specific instance" {
    54    set shell2 [prefixed_project shell2]
    55    create_project $shell2
    56    create_service $shell2 hosting1
    57  
    58    send "$::bin scale -p $shell2 -s hosting1\r"
    59    expect {
    60    timeout { handle_timeout; break }
    61    "Number of instances"
    62    }
    63    send "3\r"
    64    expect {
    65    timeout { handle_timeout; break }
    66    -gl "Scaling service \"*hosting1*\" on project \"*$shell2*\" on * to *3* instances."
    67    }
    68    sleep 15
    69    send "$::bin shell -p $shell2 -s hosting1\r"
    70    expect {
    71    timeout { handle_timeout; break }
    72    "Please *select* an instance from the list below"
    73    }
    74    send "2\r"
    75    set instances [get_container_ids $shell2 hosting1]
    76    set instance_2 [string range [lindex $instances 1] 0 11]
    77    expect {
    78    timeout { exit_shell; handle_timeout; break }
    79    "You are now accessing instance *$instance_2"
    80    }
    81    expect {
    82    timeout { exit_shell; handle_timeout; break }
    83    "/wedeploy-container"
    84    }
    85    send "exit\r"
    86    expect {
    87    timeout { handle_timeout; break }
    88    "/$::_root_dir"
    89    }
    90  } { delete_project $shell2 }
    91  
    92  Scenario: "Open a shell using --instance flag" {
    93    set shell3 [prefixed_project shell3]
    94    create_project $shell3
    95    create_service $shell3 hosting1
    96  
    97    send "$::bin scale -p $shell3 -s hosting1\r"
    98    expect {
    99      timeout { handle_timeout; break }
   100      "Number of instances"
   101    }
   102    send "3\r"
   103    expect {
   104      timeout { handle_timeout; break }
   105      -gl "Scaling service \"*hosting1*\" on project \"*$shell3*\" on * to *3* instances."
   106    }
   107    sleep 5
   108    set instances [get_container_ids $shell3 hosting1]
   109    set instance_1 [string range [lindex $instances 0] 0 11]
   110    send "$::bin shell -p $shell3 -s hosting1 --instance $instance_1\r"
   111    expect {
   112      timeout { exit_shell; handle_timeout; break }
   113      "You are now accessing instance *$instance_1"
   114    }
   115    expect {
   116      timeout { exit_shell; handle_timeout; break }
   117      "/wedeploy-container"
   118    }
   119    send "exit\r"
   120    expect {
   121      timeout { handle_timeout; break }
   122      "/$::_root_dir"
   123    }
   124  } { delete_project $shell3 }