diff --git a/docs/index.md b/docs/index.md index 506c7597c1..aef1dd1f6c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -828,6 +828,18 @@ Options: The VirtualBox driver uses the latest boot2docker image. +Environment variables: + +Here comes the list of the supported variables with the corresponding options. If both environment +variable and CLI option are provided the CLI option takes the precedence. + +| Environment variable | CLI option | +|-----------------------------------|-----------------------------------| +| `VIRTUALBOX_MEMORY_SIZE` | `--virtualbox-memory` | +| `VIRTUALBOX_CPU_COUNT` | `--virtualbox-cpu-count` | +| `VIRTUALBOX_DISK_SIZE` | `--virtualbox-disk-size` | +| `VIRTUALBOX_BOOT2DOCKER_URL` | `--virtualbox-boot2docker-url` | + #### VMware Fusion Creates machines locally on [VMware Fusion](http://www.vmware.com/products/fusion). Requires VMware Fusion to be installed. diff --git a/drivers/virtualbox/virtualbox.go b/drivers/virtualbox/virtualbox.go index d2bbb75a5f..11d00836d4 100644 --- a/drivers/virtualbox/virtualbox.go +++ b/drivers/virtualbox/virtualbox.go @@ -65,20 +65,22 @@ func init() { func GetCreateFlags() []cli.Flag { return []cli.Flag{ cli.IntFlag{ - Name: "virtualbox-memory", - Usage: "Size of memory for host in MB", - Value: 1024, + EnvVar: "VIRTUALBOX_MEMORY_SIZE", + Name: "virtualbox-memory", + Usage: "Size of memory for host in MB", + Value: 1024, }, cli.IntFlag{ + EnvVar: "VIRTUALBOX_CPU_COUNT", Name: "virtualbox-cpu-count", Usage: "number of CPUs for the machine (-1 to use the number of CPUs available)", - EnvVar: "VIRTUALBOX_CPU_COUNT", Value: -1, }, cli.IntFlag{ - Name: "virtualbox-disk-size", - Usage: "Size of disk for host in MB", - Value: 20000, + EnvVar: "VIRTUALBOX_DISK_SIZE", + Name: "virtualbox-disk-size", + Usage: "Size of disk for host in MB", + Value: 20000, }, cli.StringFlag{ EnvVar: "VIRTUALBOX_BOOT2DOCKER_URL", diff --git a/test/integration/driver-virtualbox.bats b/test/integration/driver-virtualbox.bats index 25a94fbf7f..9427c00710 100644 --- a/test/integration/driver-virtualbox.bats +++ b/test/integration/driver-virtualbox.bats @@ -260,7 +260,7 @@ findCPUCount() { @test "$DRIVER: check custom machine memory size" { findMemorySize - [[ ${output} == "${CUSTOM_MEMSIZE}" ]] + [[ ${output} == "$CUSTOM_MEMSIZE" ]] } @test "$DRIVER: check custom machine disksize" { @@ -270,7 +270,7 @@ findCPUCount() { @test "$DRIVER: check custom machine cpucount" { findCPUCount - [[ ${output} == "${CUSTOM_CPUCOUNT}" ]] + [[ ${output} == "$CUSTOM_CPUCOUNT" ]] } @test "$DRIVER: machine should show running after create" { @@ -284,7 +284,41 @@ findCPUCount() { [ "$status" -eq 0 ] } +@test "$DRIVER: can create custom machine using disk size, cpu count and memory size via env vars" { + VIRTUALBOX_DISK_SIZE=$CUSTOM_DISKSIZE VIRTUALBOX_CPU_COUNT=$CUSTOM_CPUCOUNT VIRTUALBOX_MEMORY_SIZE=$CUSTOM_MEMSIZE run machine create -d $DRIVER $NAME + [ "$status" -eq 0 ] +} + +@test "$DRIVER: check machine's memory size was set correctly by env var" { + findMemorySize + [[ ${output} == "$CUSTOM_MEMSIZE" ]] +} + +@test "$DRIVER: check machine's disk size was set correctly by env var" { + findDiskSize + [[ ${output} == *"$CUSTOM_DISKSIZE"* ]] +} + +@test "$DRIVER: check custom machine cpucount" { + findCPUCount + [[ ${output} == "$CUSTOM_CPUCOUNT" ]] +} + + +@test "$DRIVER: machine should show running after create with env" { + run machine ls + [ "$status" -eq 0 ] + [[ ${lines[1]} == *"Running"* ]] +} + +@test "$DRIVER: remove after custom env create" { + run machine rm -f $NAME + [ "$status" -eq 0 ] +} + +# Cleanup of machine store should always be the last 'test' @test "$DRIVER: cleanup" { run rm -rf $MACHINE_STORAGE_PATH [ "$status" -eq 0 ] } +