From 97cd23f2e55840db87b7f2727b8147a7593c81e6 Mon Sep 17 00:00:00 2001 From: Tom Barlow Date: Wed, 25 Mar 2015 23:08:46 +0000 Subject: [PATCH 1/7] Added VIRTUALBOX_MEMORY_SIZE and VIRTUALBOX_DISK_SIZE env vars Signed-off-by: Tom Barlow --- drivers/virtualbox/virtualbox.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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", From 0e1db738292c8e41787b9992c206f22aa00e5376 Mon Sep 17 00:00:00 2001 From: Tom Barlow Date: Thu, 26 Mar 2015 08:08:53 +0000 Subject: [PATCH 2/7] Added bats integration test for virtualbox customisation via env vars Signed-off-by: Tom Barlow --- test/integration/driver-virtualbox.bats | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/integration/driver-virtualbox.bats b/test/integration/driver-virtualbox.bats index 25a94fbf7f..800c3ab7dc 100644 --- a/test/integration/driver-virtualbox.bats +++ b/test/integration/driver-virtualbox.bats @@ -288,3 +288,31 @@ findCPUCount() { run rm -rf $MACHINE_STORAGE_PATH [ "$status" -eq 0 ] } + +@test "$DRIVER: can create custom machine using disk size and memory size via env vars" { + run VIRTUALBOX_DISK_SIZE=${CUSTOM_DISKSIZE} VIRTUALBOX_MEMORY_SIZE=${CUSTOM_MEMSIZE} 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: 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 ] +} + + From c221a0a42f7c0be30978c6263eb9a159914a56ec Mon Sep 17 00:00:00 2001 From: Tom Barlow Date: Thu, 26 Mar 2015 19:55:53 +0000 Subject: [PATCH 3/7] Moved cleanup of machine store to end of virtualbox integration test Signed-off-by: Tom Barlow --- test/integration/driver-virtualbox.bats | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/integration/driver-virtualbox.bats b/test/integration/driver-virtualbox.bats index 800c3ab7dc..bd98ad8d77 100644 --- a/test/integration/driver-virtualbox.bats +++ b/test/integration/driver-virtualbox.bats @@ -284,11 +284,6 @@ findCPUCount() { [ "$status" -eq 0 ] } -@test "$DRIVER: cleanup" { - run rm -rf $MACHINE_STORAGE_PATH - [ "$status" -eq 0 ] -} - @test "$DRIVER: can create custom machine using disk size and memory size via env vars" { run VIRTUALBOX_DISK_SIZE=${CUSTOM_DISKSIZE} VIRTUALBOX_MEMORY_SIZE=${CUSTOM_MEMSIZE} machine create -d $DRIVER $NAME [ "$status" -eq 0 ] @@ -315,4 +310,9 @@ findCPUCount() { [ "$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 ] +} From f01b9ce800a7310235ab38472be44a36fa569479 Mon Sep 17 00:00:00 2001 From: Tom Barlow Date: Thu, 26 Mar 2015 21:33:18 +0000 Subject: [PATCH 4/7] Specifying env vars inline on BATS doesn't seem to work, switched to export Signed-off-by: Tom Barlow --- test/integration/driver-virtualbox.bats | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/integration/driver-virtualbox.bats b/test/integration/driver-virtualbox.bats index bd98ad8d77..cdd7ffba43 100644 --- a/test/integration/driver-virtualbox.bats +++ b/test/integration/driver-virtualbox.bats @@ -285,7 +285,11 @@ findCPUCount() { } @test "$DRIVER: can create custom machine using disk size and memory size via env vars" { - run VIRTUALBOX_DISK_SIZE=${CUSTOM_DISKSIZE} VIRTUALBOX_MEMORY_SIZE=${CUSTOM_MEMSIZE} machine create -d $DRIVER $NAME + export VIRTUALBOX_DISK_SIZE=$CUSTOM_DISKSIZE + export VIRTUALBOX_MEMORY_SIZE=$CUSTOM_MEMSIZE + run machine create -d $DRIVER $NAME + export VIRTUALBOX_DISK_SIZE= + export VIRTUALBOX_MEMORY_SIZE= [ "$status" -eq 0 ] } From 6e71cd3917b9211f55f7a64d8c2f4ef8faacbd82 Mon Sep 17 00:00:00 2001 From: Tom Barlow Date: Fri, 27 Mar 2015 08:26:07 +0000 Subject: [PATCH 5/7] Replaced export statements in virtualbox integration tests with inline variables Signed-off-by: Tom Barlow --- test/integration/driver-virtualbox.bats | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/integration/driver-virtualbox.bats b/test/integration/driver-virtualbox.bats index cdd7ffba43..bb79953eb6 100644 --- a/test/integration/driver-virtualbox.bats +++ b/test/integration/driver-virtualbox.bats @@ -285,17 +285,13 @@ findCPUCount() { } @test "$DRIVER: can create custom machine using disk size and memory size via env vars" { - export VIRTUALBOX_DISK_SIZE=$CUSTOM_DISKSIZE - export VIRTUALBOX_MEMORY_SIZE=$CUSTOM_MEMSIZE - run machine create -d $DRIVER $NAME - export VIRTUALBOX_DISK_SIZE= - export VIRTUALBOX_MEMORY_SIZE= + VIRTUALBOX_DISK_SIZE=$CUSTOM_DISKSIZE 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}" ]] + [[ ${output} == "$CUSTOM_MEMSIZE" ]] } @test "$DRIVER: check machine's disk size was set correctly by env var" { From ddf633a9e46f39d048c596c456a41f4de7b3b61b Mon Sep 17 00:00:00 2001 From: Tom Barlow Date: Fri, 27 Mar 2015 17:07:56 +0000 Subject: [PATCH 6/7] Rebased, added env var test for virtualbox CPU count Signed-off-by: Tom Barlow --- test/integration/driver-virtualbox.bats | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/integration/driver-virtualbox.bats b/test/integration/driver-virtualbox.bats index bb79953eb6..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,8 +284,8 @@ findCPUCount() { [ "$status" -eq 0 ] } -@test "$DRIVER: can create custom machine using disk size and memory size via env vars" { - VIRTUALBOX_DISK_SIZE=$CUSTOM_DISKSIZE VIRTUALBOX_MEMORY_SIZE=$CUSTOM_MEMSIZE run machine create -d $DRIVER $NAME +@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 ] } @@ -299,6 +299,12 @@ findCPUCount() { [[ ${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 ] From f17e397d784943c2825ef3f320c1bb4d3498316c Mon Sep 17 00:00:00 2001 From: Tom Barlow Date: Sat, 28 Mar 2015 23:08:46 +0000 Subject: [PATCH 7/7] Updated docs with environment variables for virtualbox driver Signed-off-by: Tom Barlow --- docs/index.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/index.md b/docs/index.md index d24e67e42a..fd95da7b9e 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.