github.com/vmware/govmomi@v0.37.2/govc/test/tasks.bats (about)

     1  #!/usr/bin/env bats
     2  
     3  load test_helper
     4  
     5  @test "tasks" {
     6    vcsim_env
     7  
     8    run govc tasks
     9    assert_success
    10  
    11    run govc tasks vm/DC0_H0_VM0
    12    assert_success
    13    assert_matches PowerOn
    14  
    15    run govc tasks vm/DC0_H0_VM0 vm/DC0_H0_VM1
    16    assert_failure # > 1 arg
    17  
    18    run govc tasks 'host/*'
    19    assert_failure # matches 2 objects
    20  
    21    run govc tasks -b 1h
    22    assert_success
    23    [ ${#lines[@]} -gt 10 ]
    24  
    25    run govc tasks -r /DC0/vm
    26    assert_success
    27    assert_matches CreateVm
    28    assert_matches PowerOn
    29  }
    30  
    31  @test "tasks esx" {
    32    vcsim_env -esx
    33  
    34    run govc tasks
    35    assert_success
    36  
    37    run govc tasks -b 1h
    38    assert_failure # TaskHistoryCollector not supported on ESX
    39  
    40    run govc tasks -r
    41    assert_failure # TaskHistoryCollector not supported on ESX
    42  }
    43  
    44  @test "task.create" {
    45    vcsim_env
    46  
    47    export GOVC_SHOW_UNRELEASED=true
    48  
    49    run govc task.create enoent
    50    assert_failure
    51  
    52    id=$(govc extension.info -json | jq -r '.extensions[].taskList | select(. != null) | .[].taskID' | head -1)
    53    assert_equal com.vmware.govmomi.simulator.test "$id"
    54  
    55    run govc task.create "$id"
    56    assert_success
    57    task="$output"
    58  
    59    run govc task.set -s running "$task"
    60    assert_success
    61  
    62    govc tasks | grep "$id"
    63  
    64    run govc task.set -d "$id.init" -m "task init" "$task"
    65    assert_success
    66  
    67    run govc task.set -p 42 "$task"
    68    assert_success
    69  
    70    run govc task.set -s success "$task"
    71    assert_success
    72  
    73    run govc task.set -s running "$task"
    74    assert_failure
    75  }