Contents

rbld run

As a CLI user I want to be able to run existing environments with rbld run

Background:

  • Given existing environments:
    test-env:initial
    test-env:v001

Scenario: run help succeeds and usage is printed

  • Given I successfully request help for rbld run
  • Then help output should contain "rbld run [OPTIONS] [ENVIRONMENT[:TAG]]"
  • And help output should contain "Interactive mode: opens shell in the specified enviroment"
  • And help output should contain "rbld run [OPTIONS] [ENVIRONMENT[:TAG]] -- COMMANDS"
  • And help output should contain "Scripting mode: runs COMMANDS in the specified environment"
  • And help output should contain "Run command in a local environment"
  • And help output should match "-p, --privileged.*Run environment with superuser privileges"
  • And help output should match "-h, --help.*Print usage"

Scenario Outline: error printed for non-existing environments

  • When I run `rbld run <non-existing environment name>`
  • Then it should fail with:
    ERROR: Unknown environment <full environment name>

Examples:

non-existing environment namefull environment name
nonexistingnonexisting:initial
nonexisting:sometagnonexisting:sometag

Scenario Outline: non-interactive running of environments

  • When I successfully run `rbld run <environment name> -- echo Hello world!`
  • Then it should pass with exactly:
    >>> rebuild env <environment host name>
    >>> echo Hello world!
    Hello world!
    <<< rebuild env <environment host name>

Examples:

environment nameenvironment host name
test-env:v001test-env-v001
test-envtest-env-initial

Scenario: non-interactive run without command line options separator

  • When I successfully run `rbld run test-env:v001 echo Hello world!`
  • Then it should pass with exactly:
    >>> rebuild env test-env-v001
    >>> echo Hello world!
    Hello world!
    <<< rebuild env test-env-v001

Scenario Outline: interactive running of environment

  • When I run `rbld run <environment name>` interactively
  • And I type "echo Hello interactive world!"
  • And I close the stdin stream
  • Then it should pass with exactly:
    ruby
    >>> rebuild env <environment host name> interactive
    >>> Press CTRL-D do leave
    Hello interactive world!
    
    <<< rebuild env <environment host name>

Examples:

environment nameenvironment host name
test-env:v001test-env-v001
test-envtest-env-initial

Scenario: warning printed when running modified environment

  • Given environment test-env:v001 is modified
  • When I run `rbld run test-env:v001 -- echo Hello world!`
  • Then the output should contain "WARNING: Environment is modified, running original version"
  • And the output should contain ">>> rebuild env test-env-v001"
  • And the output should contain ">>> echo Hello world!"
  • And the output should contain "Hello world!"
  • And the output should contain "<<< rebuild env test-env-v001"

Scenario: hostname of environment set to the environment name

  • When I run `rbld run test-env:v001 -- hostname`
  • Then it should pass with exactly:
    >>> rebuild env test-env-v001
    >>> hostname
    test-env-v001
    <<< rebuild env test-env-v001

Scenario Outline: rbld run propagates exit code

  • When I run `rbld run test-env:v001 -- exit <status>`
  • Then the exit status should be <status>

Examples:

status
0
5

Scenario: bootstrap tracing is disabled by default

  • When I run `rbld run test-env:v001 -- echo Hi`
  • Then the output should not contain "Bootstrap tracing enabled"

Scenario: bootstrap tracing is enabled by RBLD_BOOTSTRAP_TRACE environment variable

  • Given I set the environment variables to:
    variablevalue
    RBLD_BOOTSTRAP_TRACE1
  • When I run `rbld run test-env:v001 -- echo Hi`
  • Then the output should contain "Bootstrap tracing enabled"

Scenario: environments do not have superuser privileges by default

  • Given a file named "test.ko" with "DUMMY"
  • When I run `rbld run test-env -- sudo insmod test.ko`
  • Then it should fail with "Operation not permitted"

Scenario Outline: environments may be run with superuser priviledges

  • Given a file named "test.ko" with "DUMMY"
  • When I run `rbld run <privileged flag> test-env -- sudo insmod test.ko`
  • Then it should fail with "invalid module format"

Examples:

privileged flag
--privileged
-p

Source: features/cli/rbld_run.feature at commit 44889ff6, Rebuild (Apache-2.0 license).