github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/test_files/force_stop.bats (about)

     1  load "$LIB_BATS_ASSERT/load.bash"
     2  load "$LIB_BATS_SUPPORT/load.bash"
     3  
     4  # This set of tests should always be the last acceptance tests
     5  
     6  @test "start errors nicely after state file deletion" {
     7    run steampipe service start
     8  
     9    # Delete the state file
    10    rm -f $STEAMPIPE_INSTALL_DIR/internal/steampipe.json
    11  
    12    # Trying to start the service should fail, check the error message
    13    run steampipe service start
    14    echo $output
    15    assert_output --partial 'service is running in an unknown state'
    16  
    17    # Trying to stop the service should fail, check the error message
    18    run steampipe service stop
    19    echo $output
    20    assert_output --partial 'service is running in an unknown state'
    21  }
    22  
    23  @test "force stop works after state file deletion" {
    24    run steampipe service start
    25  
    26    # Delete the state file
    27    rm -f $STEAMPIPE_INSTALL_DIR/internal/steampipe.json
    28  
    29    # Trying to start the service should fail
    30    run steampipe service start
    31    assert_failure
    32  
    33    # Trying to stop the service should fail
    34    run steampipe service stop
    35    assert_failure
    36  
    37    # Force stopping the service should work
    38    run steampipe service stop --force
    39    assert_success
    40  }
    41  
    42  function teardown_file() {
    43    # list running processes
    44    ps -ef | grep steampipe
    45  
    46    # check if any processes are running
    47    num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ')
    48    assert_equal $num 0
    49  }