New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`test/integration/core/core-commands.bats` failed because it's old #4149

Closed
otiai10 opened this Issue Jun 23, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@otiai10
Contributor

otiai10 commented Jun 23, 2017

tl;dr

Problem

When I issue test command described here, I got errors like this.

bash-4.4$ DRIVER=virtualbox make test-integration test/integration/core/core-commands.bats
test/integration/run-bats.sh test/integration/core/core-commands.bats
INFO: Run the tests with B2D_CACHE=1 to avoid downloading the boot2docker iso each time.
=> test/integration/core/core-commands.bats
 ✓ virtualbox: machine should not exist
 ✓ virtualbox: appears with ls
 ✓ virtualbox: has status 'started' appearing in ls
 ✓ virtualbox: create with same name again fails
 ✓ virtualbox: run busybox container
 ✓ virtualbox: url
 ✓ virtualbox: ip
 ✓ virtualbox: ssh
 ✓ virtualbox: version
 ✓ virtualbox: docker commands with the socket should work
 ✓ virtualbox: stop
 ✓ virtualbox: machine should show stopped after stop
 ✓ virtualbox: url should show an error when machine is stopped
 ✓ virtualbox: env should show an error when machine is stopped
 ✓ virtualbox: version should show an error when machine is stopped
 ✗ virtualbox: machine should not allow upgrade when stopped
   (in test file test/integration/core/core-commands.bats, line 109)
     `[[ "$status" -eq 1 ]]' failed
   Starting machine so machine can be upgraded... Starting "bats-virtualbox-test-shared-1498205447"... (bats-virtualbox-test-shared-1498205447) Check network to re-create if needed... (bats-virtualbox-test-shared-1498205447) Waiting for an IP... Machine "bats-virtualbox-test-shared-1498205447" was started. Waiting for SSH to be available... Detecting the provisioner... Waiting for SSH to be available... Detecting the provisioner... Upgrading docker... Stopping machine to do the upgrade... Upgrading machine "bats-virtualbox-test-shared-1498205447"... Copying /tmp/machine-bats-test-virtualbox/cache/boot2docker.iso to /tmp/machine-bats-test-virtualbox/machines/bats-virtualbox-test-shared-1498205447/boot2docker.iso... Starting machine back up... (bats-virtualbox-test-shared-1498205447) Check network to re-create if needed... (bats-virtualbox-test-shared-1498205447) Waiting for an IP... Restarting docker...
 ✗ virtualbox: start
   (in test file test/integration/core/core-commands.bats, line 115)
     `[ "$status" -eq 0  ]' failed
   Starting "bats-virtualbox-test-shared-1498205447"... Machine "bats-virtualbox-test-shared-1498205447" is already running.
 ✓ virtualbox: machine should show running after start
 ✓ virtualbox: kill
 ✓ virtualbox: machine should show stopped after kill
 ✓ virtualbox: restart
 ✓ virtualbox: machine should show running after restart
 ✓ virtualbox: status

23 tests, 2 failures

make: *** [test-integration] Error 1

Causes

The test expects the command to return error status 1 when the machine is stopped.

https://github.com/docker/machine/blob/9.28/test/integration/core/core-commands.bats#L106-L110

@test "$DRIVER: machine should not allow upgrade when stopped" {
  run machine upgrade $NAME
  echo ${output}
  [[ "$status" -eq 1 ]]
}

But the code of host.Upgrade kindly restarts the machine if it's not running.

https://github.com/docker/machine/blob/master/libmachine/host/host.go#L185-L196

func (h *Host) Upgrade() error {
	machineState, err := h.Driver.GetState()
	if err != nil {
		return err
	}

	if machineState != state.Running {
		log.Info("Starting machine so machine can be upgraded...")
		if err := h.Start(); err != nil {
			return err
		}
	}

For verification

When I deleted this block, core-commands.bats finished successfully.

func (h *Host) Upgrade() error {
-  machineState, err := h.Driver.GetState()
-  if err != nil {
-      return err
-  }
-
-  if machineState != state.Running {
-      log.Info("Starting machine so machine can be upgraded...")
-      if err := h.Start(); err != nil {
-          return err
-      }
-  }

Solution and Suggestion

  1. drop (revert?) "Starting machine so machine can be upgraded..."
  2. Fix test scenario adjusting latest behaviors

I guess (2) is better, and am willing to send pull-request about it.

Small question

  • How can I make sure that the all tests passes by one-line command?

Environment

bash

bash-4.4$ bash --version
GNU bash, バージョン 4.4.12(1)-release (x86_64-apple-darwin16.3.0)

bats

bash-4.4$ bats --version
Bats 0.4.0

virtualbox

bash-4.4$ vboxmanage --version
5.1.22r115126

docker

bash-4.4$ docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:00:50 2017
 OS/Arch:      linux/amd64
 Experimental: true
bash-4.4$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 60
Server Version: 17.03.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.27-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952 GiB
Name: moby
ID: EMCV:T42J:M3V2:MCPX:WTXD:N24V:XPBT:LIZU:YAAO:D5EW:ZQ6B:2HEI
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 16
 Goroutines: 26
 System Time: 2017-06-23T08:08:16.570366619Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

docker-machine

bash-4.4$ docker-machine version
docker-machine version 0.10.0, build 76ed2a6

Thank you

CC: @nathanleclaire

otiai10 added a commit to otiai10/machine that referenced this issue Jun 23, 2017

otiai10 added a commit to otiai10/machine that referenced this issue Jun 23, 2017

Fix test scenario to adjust to latest spec
Fix #4149

Signed-off-by: Hiromu OCHIAI <otiai10@gmail.com>

@shin- shin- closed this in #4150 Jul 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment