core-commands.bats 3.25 KB
Newer Older
1 2
#!/usr/bin/env bats

nathanleclaire's avatar
nathanleclaire committed
3
load ${BASE_TEST_DIR}/helpers.bash
4

5
use_shared_machine
6

7
@test "$DRIVER: machine should not exist" {
8
  run machine inspect UNKNOWN
nathanleclaire's avatar
nathanleclaire committed
9
  echo ${output}
10
  [ "$status" -eq 1 ]
11
  [[ ${lines[0]} =~ "Docker machine \"UNKNOWN\" does not exist" ]]
12 13
}

14 15 16 17 18 19 20 21
@test "$DRIVER: appears with ls" {
  run machine ls -q
  echo ${output}
  [ "$status" -eq 0  ]
  [[ ${lines[0]} == "$NAME" ]]
}

@test "$DRIVER: has status 'started' appearing in ls" {
22
  run machine ls -q --filter state=Running
23
  echo ${output}
24
  [ "$status" -eq 0  ]
25 26 27 28 29 30
  [[ ${lines[0]} == "$NAME" ]]
}

@test "$DRIVER: create with same name again fails" {
  run machine create -d $DRIVER $NAME
  echo ${output}
31
  [ "$status" -eq 1  ]
32
  [[ ${lines[0]} == "Docker machine \"$NAME\" already exists" ]]
33 34 35
}

@test "$DRIVER: run busybox container" {
36
  run docker $(machine config $NAME) run busybox echo hello world
37
  echo ${output}
38 39 40 41
  [ "$status" -eq 0  ]
}

@test "$DRIVER: url" {
42
  run machine url $NAME
43
  echo ${output}
44 45 46 47
  [ "$status" -eq 0  ]
}

@test "$DRIVER: ip" {
48
  run machine ip $NAME
49
  echo ${output}
50 51 52 53
  [ "$status" -eq 0  ]
}

@test "$DRIVER: ssh" {
54
  run machine ssh $NAME -- ls -lah /
55
  echo ${output}
56 57 58 59
  [ "$status" -eq 0  ]
  [[ ${lines[0]} =~ "total"  ]]
}

David Gageot's avatar
David Gageot committed
60 61 62 63 64 65
@test "$DRIVER: version" {
  run machine version $NAME
  echo ${output}
  [ "$status" -eq 0  ]
}

nathanleclaire's avatar
nathanleclaire committed
66
@test "$DRIVER: docker commands with the socket should work" {
67
  run machine ssh $NAME -- sudo docker version
68
  echo ${output}
nathanleclaire's avatar
nathanleclaire committed
69 70
}

71
@test "$DRIVER: stop" {
72
  run machine stop $NAME
73
  echo ${output}
74 75 76
  [ "$status" -eq 0  ]
}

77 78
@test "$DRIVER: machine should show stopped after stop" {
  run machine ls
79
  echo ${output}
80 81 82 83
  [ "$status" -eq 0  ]
  [[ ${lines[1]} == *"Stopped"*  ]]
}

84 85
@test "$DRIVER: url should show an error when machine is stopped" {
  run machine url $NAME
86
  echo ${output}
87
  [ "$status" -eq 1 ]
88
  [[ ${output} == *"Host is not running"* ]]
89 90 91 92
}

@test "$DRIVER: env should show an error when machine is stopped" {
  run machine env $NAME
93
  echo ${output}
94
  [ "$status" -eq 1 ]
95
  [[ ${output} == *"Host is not running"* ]]
96 97
}

David Gageot's avatar
David Gageot committed
98 99 100 101
@test "$DRIVER: version should show an error when machine is stopped" {
  run machine version $NAME
  echo ${output}
  [ "$status" -eq 1 ]
102
  [[ ${output} == *"Host is not running"* ]]
David Gageot's avatar
David Gageot committed
103 104
}

105
@test "$DRIVER: machine should upgrade even when machine is stopped" {
nathanleclaire's avatar
nathanleclaire committed
106
  run machine upgrade $NAME
107
  echo ${output}
108
  [[ "$status" -eq 0 ]]
nathanleclaire's avatar
nathanleclaire committed
109 110
}

111
@test "$DRIVER: start should show an error after upgrade" {
112
  run machine start $NAME
113
  echo ${output}
114
  [ "$status" -eq 1  ]
115 116
}

117
@test "$DRIVER: machine should show running after start" {
118
  run machine ls --timeout 20
119
  echo ${output}
120 121 122 123 124
  [ "$status" -eq 0  ]
  [[ ${lines[1]} == *"Running"*  ]]
}

@test "$DRIVER: kill" {
125
  run machine kill $NAME
126
  echo ${output}
127 128 129
  [ "$status" -eq 0  ]
}

130 131
@test "$DRIVER: machine should show stopped after kill" {
  run machine ls
132
  echo ${output}
133 134 135 136 137
  [ "$status" -eq 0  ]
  [[ ${lines[1]} == *"Stopped"*  ]]
}

@test "$DRIVER: restart" {
138
  run machine restart $NAME
139
  echo ${output}
140 141 142
  [ "$status" -eq 0  ]
}

143
@test "$DRIVER: machine should show running after restart" {
144
  run machine ls --timeout 20
145
  echo ${output}
146 147 148
  [ "$status" -eq 0  ]
  [[ ${lines[1]} == *"Running"*  ]]
}
149 150 151

@test "$DRIVER: status" {
  run machine status $NAME
152
  echo ${output}
153 154 155
  [ "$status" -eq 0 ]
  [[ ${output} == *"Running"* ]]
}