github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/runc/tests/integration/delete.bats (about)

     1  #!/usr/bin/env bats
     2  
     3  load helpers
     4  
     5  function setup() {
     6    teardown_busybox
     7    setup_busybox
     8  }
     9  
    10  function teardown() {
    11    teardown_busybox
    12  }
    13  
    14  @test "runc delete" {
    15    # run busybox detached
    16    runc run -d --console /dev/pts/ptmx test_busybox
    17    [ "$status" -eq 0 ]
    18  
    19    # check state
    20    wait_for_container 15 1 test_busybox
    21  
    22    testcontainer test_busybox running
    23  
    24    runc kill test_busybox KILL
    25    # wait for busybox to be in the destroyed state
    26    retry 10 1 eval "__runc state test_busybox | grep -q 'stopped'"
    27  
    28    # delete test_busybox
    29    runc delete test_busybox
    30  
    31    runc state test_busybox
    32    [ "$status" -ne 0 ]
    33  }
    34  
    35  @test "runc delete --force" {
    36    # run busybox detached
    37    runc run -d --console /dev/pts/ptmx test_busybox
    38    [ "$status" -eq 0 ]
    39  
    40    # check state
    41    wait_for_container 15 1 test_busybox
    42  
    43    testcontainer test_busybox running
    44  
    45    # force delete test_busybox
    46    runc delete --force test_busybox
    47  
    48    runc state test_busybox
    49    [ "$status" -ne 0 ]
    50  }
    51  
    52  @test "run delete with multi-containers" {
    53    # create busybox1 detached
    54    runc create --console /dev/pts/ptmx test_busybox1
    55    [ "$status" -eq 0 ]
    56  
    57    testcontainer test_busybox1 created
    58  
    59    # run busybox2 detached
    60    runc run -d --console /dev/pts/ptmx test_busybox2
    61    [ "$status" -eq 0 ]
    62  
    63    wait_for_container 15 1 test_busybox2
    64    testcontainer test_busybox2 running
    65  
    66    # delete both test_busybox1 and test_busybox2 container
    67    runc delete test_busybox1 test_busybox2
    68  
    69    runc state test_busybox1
    70    [ "$status" -ne 0 ]
    71  
    72    runc state test_busybox2
    73    [ "$status" -eq 0 ]
    74  
    75    runc kill test_busybox2 KILL
    76    # wait for busybox2 to be in the destroyed state
    77    retry 10 1 eval "__runc state test_busybox2 | grep -q 'stopped'"
    78  
    79    # delete test_busybox2
    80    runc delete test_busybox2
    81  
    82    runc state test_busybox2
    83    [ "$status" -ne 0 ]
    84  }
    85  
    86  
    87  @test "run delete --force with multi-containers" {
    88    # create busybox1 detached
    89    runc create --console /dev/pts/ptmx test_busybox1
    90    [ "$status" -eq 0 ]
    91  
    92    testcontainer test_busybox1 created
    93  
    94    # run busybox2 detached
    95    runc run -d --console /dev/pts/ptmx test_busybox2
    96    [ "$status" -eq 0 ]
    97  
    98    wait_for_container 15 1 test_busybox2
    99    testcontainer test_busybox2 running
   100  
   101    # delete both test_busybox1 and test_busybox2 container
   102    runc delete --force  test_busybox1 test_busybox2
   103  
   104    runc state test_busybox1
   105    [ "$status" -ne 0 ]
   106  
   107    runc state test_busybox2
   108    [ "$status" -ne 0 ]
   109  }