kitchen-google 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +110 -70
- data/README.md +57 -21
- data/kitchen-google.gemspec +3 -2
- data/lib/kitchen/driver/gce.rb +168 -24
- data/lib/kitchen/driver/gce_version.rb +1 -1
- data/spec/kitchen/driver/gce_spec.rb +197 -32
- metadata +20 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4e19b3e4c95bfbeedf09b290ba0cc45536c523bc8791ecb345642181ab2e607d
|
|
4
|
+
data.tar.gz: 7913bc02ccdc1d606ba87df8b7960f4556674b13f1469d68611bb882e59a5889
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cbbd3baa2e01527513f4deb906d5312551e90f82ac38a259f7baaf733d03267b885c5d4941da98cd456f553d2713ef7f4518c5e51aa6a7866dd2fb4b79399fb3
|
|
7
|
+
data.tar.gz: dbac982910773161e264b04b5df4e2a4367eb838bfda77819ecd57c0c31f59f9660e1825520dbe9beb8d6824b104a5438eee0db5a12060a9481537d29096f1b0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,113 +1,153 @@
|
|
|
1
|
-
|
|
1
|
+
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## [v1.5.0](https://github.com/test-kitchen/kitchen-google/tree/v1.5.0)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v1.4.0...v1.5.0)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* #52: update user agent string, doc update to replace deprecated gcloud switches
|
|
9
|
-
* #53: Rubocop and Travis updates
|
|
10
|
-
* #54: option to set a custom instance name
|
|
11
|
-
* #55: doc update on how to inject ssh keys with custom metadata
|
|
7
|
+
**Closed issues:**
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
- Driver waits forever after creating instance [\#49](https://github.com/test-kitchen/kitchen-google/issues/49)
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
**Merged pull requests:**
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
- Added support for additional disks; Windows Server 2008R2 support; Ad… [\#62](https://github.com/test-kitchen/kitchen-google/pull/62) ([stiller-leser](https://github.com/stiller-leser))
|
|
14
|
+
- Updated README [\#60](https://github.com/test-kitchen/kitchen-google/pull/60) ([jjasghar](https://github.com/jjasghar))
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* #34: Support for using subnetworks
|
|
22
|
-
* #35: Support for gcloud-style image aliases (i.e. "centos-7" will get you the latest CentOS image)
|
|
16
|
+
## [v1.4.0](https://github.com/test-kitchen/kitchen-google/tree/v1.4.0) (2017-09-28)
|
|
17
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v1.3.0...v1.4.0)
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
**Merged pull requests:**
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
- release 1.4.0 [\#56](https://github.com/test-kitchen/kitchen-google/pull/56) ([robbkidd](https://github.com/robbkidd))
|
|
22
|
+
- Add support for Google Shared VPC Networks \(XPN\) [\#47](https://github.com/test-kitchen/kitchen-google/pull/47) ([zbikmarc](https://github.com/zbikmarc))
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* #30: support for automated public project searching for well-known disk images
|
|
24
|
+
## [v1.3.0](https://github.com/test-kitchen/kitchen-google/tree/v1.3.0) (2017-09-15)
|
|
25
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v1.2.0...v1.3.0)
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
**Closed issues:**
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
- Driver not in load path in latest chefdk [\#50](https://github.com/test-kitchen/kitchen-google/issues/50)
|
|
30
|
+
- Disable instance\_name suffix generation [\#46](https://github.com/test-kitchen/kitchen-google/issues/46)
|
|
31
|
+
- 'Preparing modules for first use' Causing Tests to Fail [\#45](https://github.com/test-kitchen/kitchen-google/issues/45)
|
|
32
|
+
- Allow instance\_name prefix to be customizable [\#40](https://github.com/test-kitchen/kitchen-google/issues/40)
|
|
33
|
+
- Allow default instance\_name prefix to be customizable [\#39](https://github.com/test-kitchen/kitchen-google/issues/39)
|
|
34
|
+
- Sort out ruby-1.9 support [\#25](https://github.com/test-kitchen/kitchen-google/issues/25)
|
|
35
|
+
- Unsupported parameters are silently ignored [\#23](https://github.com/test-kitchen/kitchen-google/issues/23)
|
|
36
|
+
- setting scope on service accounts [\#20](https://github.com/test-kitchen/kitchen-google/issues/20)
|
|
37
|
+
- I can not get your sample .kitchen.yml to work. [\#15](https://github.com/test-kitchen/kitchen-google/issues/15)
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
**Merged pull requests:**
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
- add example for injecting ssh key to instance\(s\) [\#55](https://github.com/test-kitchen/kitchen-google/pull/55) ([robbkidd](https://github.com/robbkidd))
|
|
42
|
+
- Option to override instance names [\#54](https://github.com/test-kitchen/kitchen-google/pull/54) ([robbkidd](https://github.com/robbkidd))
|
|
43
|
+
- update Ruby versions to test for in Travis [\#53](https://github.com/test-kitchen/kitchen-google/pull/53) ([robbkidd](https://github.com/robbkidd))
|
|
44
|
+
- Changing SSH Command [\#52](https://github.com/test-kitchen/kitchen-google/pull/52) ([rambleraptor](https://github.com/rambleraptor))
|
|
45
|
+
- Support configured custom metadata [\#43](https://github.com/test-kitchen/kitchen-google/pull/43) ([dldinternet](https://github.com/dldinternet))
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
## [v1.2.0](https://github.com/test-kitchen/kitchen-google/tree/v1.2.0) (2017-02-03)
|
|
48
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v1.1.0...v1.2.0)
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
**Closed issues:**
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
- Ability to support image-family [\#41](https://github.com/test-kitchen/kitchen-google/issues/41)
|
|
53
|
+
- Transition to fog-google [\#24](https://github.com/test-kitchen/kitchen-google/issues/24)
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
**Merged pull requests:**
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
- Support image\_family [\#44](https://github.com/test-kitchen/kitchen-google/pull/44) ([whiteley](https://github.com/whiteley))
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* #12: Generate instance names that are valid for GCE
|
|
59
|
+
## [v1.1.0](https://github.com/test-kitchen/kitchen-google/tree/v1.1.0) (2016-03-17)
|
|
60
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v1.0.0...v1.1.0)
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
**Merged pull requests:**
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
- Adding support for image aliases [\#35](https://github.com/test-kitchen/kitchen-google/pull/35) ([adamleff](https://github.com/adamleff))
|
|
65
|
+
- Add support for using subnetworks [\#34](https://github.com/test-kitchen/kitchen-google/pull/34) ([adamleff](https://github.com/adamleff))
|
|
66
|
+
- Automatically disable auto-restart and auto-migrate for preemptible instance [\#33](https://github.com/test-kitchen/kitchen-google/pull/33) ([adamleff](https://github.com/adamleff))
|
|
67
|
+
- Rake and rubocop fixes [\#32](https://github.com/test-kitchen/kitchen-google/pull/32) ([adamleff](https://github.com/adamleff))
|
|
61
68
|
|
|
62
|
-
|
|
69
|
+
## [v1.0.0](https://github.com/test-kitchen/kitchen-google/tree/v1.0.0) (2016-03-10)
|
|
70
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v0.3.0...v1.0.0)
|
|
63
71
|
|
|
64
|
-
|
|
72
|
+
**Closed issues:**
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
ridley gem.
|
|
74
|
+
- Add @erjohnso and @adamleff to kitchen-google repo and gem [\#31](https://github.com/test-kitchen/kitchen-google/issues/31)
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
**Merged pull requests:**
|
|
70
77
|
|
|
71
|
-
|
|
78
|
+
- Rewrite of kitchen-google to use google-api-client [\#30](https://github.com/test-kitchen/kitchen-google/pull/30) ([adamleff](https://github.com/adamleff))
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* Support GCE v1 API, including persistent disks.
|
|
80
|
+
## [v0.3.0](https://github.com/test-kitchen/kitchen-google/tree/v0.3.0) (2016-01-24)
|
|
81
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v0.2.0...v0.3.0)
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
**Closed issues:**
|
|
78
84
|
|
|
79
|
-
|
|
85
|
+
- Add auto\_restart to tests [\#27](https://github.com/test-kitchen/kitchen-google/issues/27)
|
|
86
|
+
- Add docs for Preemptible instances [\#26](https://github.com/test-kitchen/kitchen-google/issues/26)
|
|
87
|
+
- GCE Instance created without scoping the service account [\#21](https://github.com/test-kitchen/kitchen-google/issues/21)
|
|
88
|
+
- Investigate moving project to test-kitchen organization [\#16](https://github.com/test-kitchen/kitchen-google/issues/16)
|
|
89
|
+
- server timeout on custom images. [\#13](https://github.com/test-kitchen/kitchen-google/issues/13)
|
|
80
90
|
|
|
81
|
-
|
|
91
|
+
**Merged pull requests:**
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
- Preemptible documentation [\#28](https://github.com/test-kitchen/kitchen-google/pull/28) ([Temikus](https://github.com/Temikus))
|
|
94
|
+
- Add JSON credential file and Preemptible VM support [\#22](https://github.com/test-kitchen/kitchen-google/pull/22) ([marcy-terui](https://github.com/marcy-terui))
|
|
95
|
+
- Add code formatting and relative links. [\#18](https://github.com/test-kitchen/kitchen-google/pull/18) ([mbrukman](https://github.com/mbrukman))
|
|
96
|
+
- Update badge URLs now that repo moved. [\#17](https://github.com/test-kitchen/kitchen-google/pull/17) ([mbrukman](https://github.com/mbrukman))
|
|
97
|
+
- Support service\_accounts option in Fog [\#14](https://github.com/test-kitchen/kitchen-google/pull/14) ([jgoldschrafe](https://github.com/jgoldschrafe))
|
|
84
98
|
|
|
85
|
-
|
|
99
|
+
## [v0.2.0](https://github.com/test-kitchen/kitchen-google/tree/v0.2.0) (2014-09-20)
|
|
100
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v0.1.2...v0.2.0)
|
|
86
101
|
|
|
87
|
-
|
|
102
|
+
**Closed issues:**
|
|
88
103
|
|
|
89
|
-
|
|
104
|
+
- generate\_inst\_name should only produce names that meet Google's requirements [\#12](https://github.com/test-kitchen/kitchen-google/issues/12)
|
|
105
|
+
- Add "region" support, deprecate "area" [\#10](https://github.com/test-kitchen/kitchen-google/issues/10)
|
|
90
106
|
|
|
91
|
-
|
|
92
|
-
* Require Faraday Gem version to be ~> 0.8.9; 0.9.0 breaks test-kitchen.
|
|
107
|
+
**Merged pull requests:**
|
|
93
108
|
|
|
94
|
-
|
|
109
|
+
- Fix name length. [\#11](https://github.com/test-kitchen/kitchen-google/pull/11) ([pdunnavant](https://github.com/pdunnavant))
|
|
95
110
|
|
|
96
|
-
|
|
111
|
+
## [v0.1.2](https://github.com/test-kitchen/kitchen-google/tree/v0.1.2) (2014-04-16)
|
|
112
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v0.1.0...v0.1.2)
|
|
97
113
|
|
|
98
|
-
|
|
99
|
-
`<suite>-<platform>` and a UUID.
|
|
100
|
-
* Fix bug where running `kitchen create` multiple times would create
|
|
101
|
-
duplicate instances.
|
|
102
|
-
* Require version of Fog with exponential backoff in GCE API queries.
|
|
114
|
+
**Closed issues:**
|
|
103
115
|
|
|
104
|
-
|
|
116
|
+
- Support Faraday 1.9 via ridley \>= 3.0.0 [\#9](https://github.com/test-kitchen/kitchen-google/issues/9)
|
|
105
117
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
an availability zone from those that are up within the requested
|
|
109
|
-
area for each instance.
|
|
118
|
+
## [v0.1.0](https://github.com/test-kitchen/kitchen-google/tree/v0.1.0) (2014-03-29)
|
|
119
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/v0.6.0...v0.1.0)
|
|
110
120
|
|
|
111
|
-
|
|
121
|
+
**Closed issues:**
|
|
112
122
|
|
|
113
|
-
|
|
123
|
+
- Update Copyright [\#8](https://github.com/test-kitchen/kitchen-google/issues/8)
|
|
124
|
+
- Support Fog 1.20.0 [\#6](https://github.com/test-kitchen/kitchen-google/issues/6)
|
|
125
|
+
|
|
126
|
+
**Merged pull requests:**
|
|
127
|
+
|
|
128
|
+
- adding support for using authorized\_keys from a service account [\#7](https://github.com/test-kitchen/kitchen-google/pull/7) ([someara](https://github.com/someara))
|
|
129
|
+
|
|
130
|
+
## [v0.6.0](https://github.com/test-kitchen/kitchen-google/tree/v0.6.0) (2014-02-23)
|
|
131
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/0.0.4...v0.6.0)
|
|
132
|
+
|
|
133
|
+
**Closed issues:**
|
|
134
|
+
|
|
135
|
+
- Network and Tag Support [\#5](https://github.com/test-kitchen/kitchen-google/issues/5)
|
|
136
|
+
|
|
137
|
+
## [0.0.4](https://github.com/test-kitchen/kitchen-google/tree/0.0.4) (2013-12-28)
|
|
138
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-google/compare/0.0.1...0.0.4)
|
|
139
|
+
|
|
140
|
+
**Fixed bugs:**
|
|
141
|
+
|
|
142
|
+
- test-kitchen 1.0.0.rc.1 breaks auto name generation [\#2](https://github.com/test-kitchen/kitchen-google/issues/2)
|
|
143
|
+
- Provisioning fails with "Class: Kitchen::ActionFailed" [\#1](https://github.com/test-kitchen/kitchen-google/issues/1)
|
|
144
|
+
|
|
145
|
+
**Closed issues:**
|
|
146
|
+
|
|
147
|
+
- "kitchen create" duplicates instances [\#4](https://github.com/test-kitchen/kitchen-google/issues/4)
|
|
148
|
+
- Intermittent Kitchen::ActionFailed - eventually consistent GCE API? [\#3](https://github.com/test-kitchen/kitchen-google/issues/3)
|
|
149
|
+
|
|
150
|
+
## [0.0.1](https://github.com/test-kitchen/kitchen-google/tree/0.0.1) (2013-10-20)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Google Cloud API. The auth library expects that there is a JSON credentials file
|
|
|
31
31
|
`~/.config/gcloud/application_default_credentials.json`
|
|
32
32
|
|
|
33
33
|
The easiest way to create this is to download and install the [Google Cloud SDK](https://cloud.google.com/sdk/) and run the
|
|
34
|
-
`gcloud auth login` command which will create the credentials file for you.
|
|
34
|
+
`gcloud auth application-default login` command which will create the credentials file for you.
|
|
35
35
|
|
|
36
36
|
If you already have a file you'd like to use that is in a different location, set the
|
|
37
37
|
`GOOGLE_APPLICATION_CREDENTIALS` environment variable with the full path to that file.
|
|
@@ -190,31 +190,11 @@ must be unique. By default, a unique name will be auto-generated; note that
|
|
|
190
190
|
auto-generated names must be used if there is more than one test suite. Default:
|
|
191
191
|
`tk-<suite>-<platform>-<UUID>`
|
|
192
192
|
|
|
193
|
-
### `autodelete_disk`
|
|
194
|
-
|
|
195
|
-
Boolean specifying whether or not to automatically delete boot disk
|
|
196
|
-
for test instance. Default: `true`
|
|
197
|
-
|
|
198
|
-
NOTE: If you set this to false, once Test Kitchen destroys your instance,
|
|
199
|
-
the boot disk used will remain in your project. You will need to manually delete it to
|
|
200
|
-
avoid consuming unused resources by either using the `gcloud compute disks delete`
|
|
201
|
-
command in the GCP SDK or by using `knife google disk delete` from
|
|
202
|
-
[knife-google](https://github.com/chef/knife-google).
|
|
203
|
-
|
|
204
193
|
### `auto_migrate`
|
|
205
194
|
|
|
206
195
|
Boolean specifying whether or not to automatically migrate the instance
|
|
207
196
|
to a host in the event of host maintenance. Default: `false`
|
|
208
197
|
|
|
209
|
-
### `disk_size`
|
|
210
|
-
|
|
211
|
-
Size, in gigabytes, of boot disk. Default: `10`.
|
|
212
|
-
|
|
213
|
-
Some images, such as windows images, have a larger source image size
|
|
214
|
-
and require the disk_size to be the same size or larger than the source.
|
|
215
|
-
An error message will be displayed to you indicating this requirement
|
|
216
|
-
if necessary.
|
|
217
|
-
|
|
218
198
|
### `email`
|
|
219
199
|
|
|
220
200
|
**Required for Windows instances.** The email address of the
|
|
@@ -300,6 +280,62 @@ Default:
|
|
|
300
280
|
"test-kitchen-instance" => <instance.name>,
|
|
301
281
|
"test-kitchen-user" => <env_user>,
|
|
302
282
|
|
|
283
|
+
### Disk configuration
|
|
284
|
+
|
|
285
|
+
NOTE: In order to support multiple disks in this driver, the disk configuration has been reworked. However, old .kitchen-files will keep working and simply be adapted automatically.
|
|
286
|
+
|
|
287
|
+
```yaml
|
|
288
|
+
driver:
|
|
289
|
+
disks:
|
|
290
|
+
disk0:
|
|
291
|
+
autodelete_disk: false
|
|
292
|
+
disk1:
|
|
293
|
+
disk_size: 30
|
|
294
|
+
disk2:
|
|
295
|
+
disk_size: 50
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
In the above example the `disk0` would be automatically be used as the bootdisk (/dev/sda), `disk1` would be mounted as /dev/sdb and be 30 gigabytes in size. `disk2` would be mounted as /dev/sdc and 50 gigabytes in size. Any of these disks could be the bootdisk (see below), but since none is specified, disk0 is automatically elected. Note that if `disk1` would be set as bootdisk using `boot: true` it will be mounted as /dev/sda.
|
|
299
|
+
|
|
300
|
+
#### `boot`
|
|
301
|
+
|
|
302
|
+
Specifies wether or not a disk should be used as the boot disk for the instance. By default the first disk will be used as boot disk.
|
|
303
|
+
|
|
304
|
+
#### `autodelete_disk` - deprecated as standalone option
|
|
305
|
+
|
|
306
|
+
Boolean specifying whether or not to automatically delete boot disk
|
|
307
|
+
for test instance. Default: `true`
|
|
308
|
+
|
|
309
|
+
*This option is deprecated as a standlone configuration, but can be applied on a per disk level.*
|
|
310
|
+
|
|
311
|
+
NOTE: If you set this to false, once Test Kitchen destroys your instance,
|
|
312
|
+
the boot disk used will remain in your project. You will need to manually delete it to
|
|
313
|
+
avoid consuming unused resources by either using the `gcloud compute disks delete`
|
|
314
|
+
command in the GCP SDK or by using `knife google disk delete` from
|
|
315
|
+
[knife-google](https://github.com/chef/knife-google).
|
|
316
|
+
|
|
317
|
+
#### `disk_size` - deprecated as standalone option
|
|
318
|
+
|
|
319
|
+
Size, in gigabytes, of boot disk. Default: `10`.
|
|
320
|
+
|
|
321
|
+
*This option is deprecated as a standlone configuration, but can be applied on a per disk level.*
|
|
322
|
+
|
|
323
|
+
Some images, such as windows images, have a larger source image size
|
|
324
|
+
and require the disk_size to be the same size or larger than the source.
|
|
325
|
+
An error message will be displayed to you indicating this requirement
|
|
326
|
+
if necessary.
|
|
327
|
+
|
|
328
|
+
#### `disk_type` - deprecated as standalone option
|
|
329
|
+
|
|
330
|
+
Type of the disk. Default: `pd-standard`.
|
|
331
|
+
|
|
332
|
+
*This option is deprecated as a standlone configuration, but can be applied on a per disk level.*
|
|
333
|
+
|
|
334
|
+
Valid disk types:
|
|
335
|
+
|
|
336
|
+
- `pd-standard`: Attached magnetic hard drive
|
|
337
|
+
- `pd-ssd`: Attached SSD
|
|
338
|
+
- `local-ssd`: [Local scratch SSD](https://cloud.google.com/compute/docs/disks/#localssds). NOTE: You cannot specify their size. They always are 375 GB!
|
|
303
339
|
|
|
304
340
|
### Transport Settings
|
|
305
341
|
|
data/kitchen-google.gemspec
CHANGED
|
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
|
|
|
14
14
|
s.homepage = "https://github.com/test-kitchen/kitchen-google"
|
|
15
15
|
s.license = "Apache 2.0"
|
|
16
16
|
|
|
17
|
-
s.add_dependency "gcewinpass", "~> 1.
|
|
18
|
-
s.add_dependency "google-api-client", "~> 0.
|
|
17
|
+
s.add_dependency "gcewinpass", "~> 1.1"
|
|
18
|
+
s.add_dependency "google-api-client", "~> 0.19"
|
|
19
19
|
s.add_dependency "test-kitchen"
|
|
20
20
|
|
|
21
21
|
s.add_development_dependency "bundler"
|
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
s.add_development_dependency "rake", "~> 10.5"
|
|
24
24
|
s.add_development_dependency "rspec"
|
|
25
25
|
s.add_development_dependency "rubocop"
|
|
26
|
+
s.add_development_dependency "byebug"
|
|
26
27
|
|
|
27
28
|
s.required_ruby_version = ">= 2.0"
|
|
28
29
|
end
|
data/lib/kitchen/driver/gce.rb
CHANGED
|
@@ -61,9 +61,6 @@ module Kitchen
|
|
|
61
61
|
default_config :region, nil
|
|
62
62
|
default_config :zone, nil
|
|
63
63
|
|
|
64
|
-
default_config :autodelete_disk, true
|
|
65
|
-
default_config :disk_size, 10
|
|
66
|
-
default_config :disk_type, "pd-standard"
|
|
67
64
|
default_config :machine_type, "n1-standard-1"
|
|
68
65
|
default_config :network, "default"
|
|
69
66
|
default_config :network_project, nil
|
|
@@ -85,6 +82,8 @@ module Kitchen
|
|
|
85
82
|
default_config :refresh_rate, 2
|
|
86
83
|
default_config :metadata, {}
|
|
87
84
|
|
|
85
|
+
DISK_NAME_REGEX = /(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)/
|
|
86
|
+
|
|
88
87
|
def name
|
|
89
88
|
"Google Compute (GCE)"
|
|
90
89
|
end
|
|
@@ -97,10 +96,11 @@ module Kitchen
|
|
|
97
96
|
|
|
98
97
|
server_name = generate_server_name
|
|
99
98
|
|
|
99
|
+
create_disks_config
|
|
100
|
+
|
|
100
101
|
info("Creating GCE instance <#{server_name}> in project #{project}, zone #{zone}...")
|
|
101
102
|
operation = connection.insert_instance(project, zone, create_instance_object(server_name))
|
|
102
103
|
|
|
103
|
-
info("Zone operation #{operation.name} created. Waiting for it to complete...")
|
|
104
104
|
wait_for_operation(operation)
|
|
105
105
|
|
|
106
106
|
server = server_instance(server_name)
|
|
@@ -141,6 +141,77 @@ module Kitchen
|
|
|
141
141
|
state.delete(:zone)
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
+
def old_disk_configuration_present?
|
|
145
|
+
!config[:autodelete_disk].nil? || !config[:disk_size].nil? || !config[:disk_type].nil?
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def new_disk_configuration_present?
|
|
149
|
+
!config[:disks].nil?
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def create_disks_config
|
|
153
|
+
# This can't be present in default_config because we couldn't
|
|
154
|
+
# determine which disk configuration the user used otherwise
|
|
155
|
+
disk_default_config = {
|
|
156
|
+
autodelete_disk: true,
|
|
157
|
+
disk_size: 10,
|
|
158
|
+
disk_type: "pd-standard",
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if old_disk_configuration_present?
|
|
162
|
+
# If the old disk configuration is used,
|
|
163
|
+
# we'll convert it to the new one
|
|
164
|
+
config[:disks] = {
|
|
165
|
+
disk1: {
|
|
166
|
+
boot: true,
|
|
167
|
+
autodelete_disk: config.fetch(:autodelete_disk, disk_default_config[:autodelete_disk]),
|
|
168
|
+
disk_size: config.fetch(:disk_size, disk_default_config[:disk_size]),
|
|
169
|
+
disk_type: config.fetch(:disk_type, disk_default_config[:disk_type]),
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
raise "Disk type #{config[:disks][:disk1][:disk_type]} is not valid" unless valid_disk_type?(config[:disks][:disk1][:disk_type])
|
|
173
|
+
elsif new_disk_configuration_present?
|
|
174
|
+
# If the new disk configuration is present, ensure that for
|
|
175
|
+
# every disk the needed configuration is set
|
|
176
|
+
boot_disk_counter = 0
|
|
177
|
+
config[:disks].each do |disk_name, disk_config|
|
|
178
|
+
# te&/ => te
|
|
179
|
+
raise "Disk name invalid. Must match #{DISK_NAME_REGEX}." unless valid_disk_name?(disk_name)
|
|
180
|
+
|
|
181
|
+
# Update the config for the disk with the fixed config
|
|
182
|
+
config[:disks][disk_name.to_sym] = disk_default_config.merge(disk_config)
|
|
183
|
+
|
|
184
|
+
# Since the config was altered, we can't use disk_config (as it will be different or keys will not be present)
|
|
185
|
+
raise "Disk type #{config[:disks][disk_name.to_sym][:disk_type]} for disk #{disk_name} is not valid" unless valid_disk_type?(config[:disks][disk_name.to_sym][:disk_type])
|
|
186
|
+
|
|
187
|
+
unless disk_config[:boot].nil?
|
|
188
|
+
boot_disk_counter += 1
|
|
189
|
+
raise "Boot disk cannot be local SSD." if disk_config[:disk_type] == "local-ssd"
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
if disk_config[:disk_type] == "local-ssd"
|
|
193
|
+
raise "#{disk_name}: Cannot use 'disk_size' with local SSD. They always have 375 GB (https://cloud.google.com/compute/docs/disks/#localssds)." unless disk_config[:disk_size].nil?
|
|
194
|
+
# Since disk_size is set to 10 in default_config, it needs to be adjusted for local SSDs
|
|
195
|
+
config[:disks][disk_name.to_sym][:disk_size] = nil
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
if boot_disk_counter == 0
|
|
199
|
+
first_disk = config[:disks].first[0]
|
|
200
|
+
first_config = config[:disks].first[1]
|
|
201
|
+
config[:disks][first_disk] = first_config.merge({ boot: true })
|
|
202
|
+
warn("No bootdisk found - Assuming first disk will be boot disk")
|
|
203
|
+
elsif boot_disk_counter > 1
|
|
204
|
+
raise "More than one boot disk specified"
|
|
205
|
+
end
|
|
206
|
+
elsif !new_disk_configuration_present?
|
|
207
|
+
# If no new disk configuration is present,
|
|
208
|
+
# we'll set up the default configuration for the new style
|
|
209
|
+
config[:disks] = {
|
|
210
|
+
"disk1": disk_default_config.merge({ boot: true }),
|
|
211
|
+
}
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
144
215
|
def validate!
|
|
145
216
|
raise "Project #{config[:project]} is not a valid project" unless valid_project?
|
|
146
217
|
raise "Either zone or region must be specified" unless config[:zone] || config[:region]
|
|
@@ -148,12 +219,12 @@ module Kitchen
|
|
|
148
219
|
raise "Zone #{config[:zone]} is not a valid zone" if config[:zone] && !valid_zone?
|
|
149
220
|
raise "Region #{config[:region]} is not a valid region" if config[:region] && !valid_region?
|
|
150
221
|
raise "Machine type #{config[:machine_type]} is not valid" unless valid_machine_type?
|
|
151
|
-
raise "Disk type #{config[:disk_type]} is not valid" unless valid_disk_type?
|
|
152
222
|
raise "Either image family or name must be specified" unless config[:image_family] || config[:image_name]
|
|
153
|
-
raise "Disk image #{config[:image_name]} is not valid - check your image name and image project" if boot_disk_source_image.nil?
|
|
154
223
|
raise "Network #{config[:network]} is not valid" unless valid_network?
|
|
155
224
|
raise "Subnet #{config[:subnet]} is not valid" if config[:subnet] && !valid_subnet?
|
|
156
225
|
raise "Email address of GCE user is not set" if winrm_transport? && config[:email].nil?
|
|
226
|
+
raise "You cannot use autodelete_disk, disk_size or disk_type with the new disks configuration" if old_disk_configuration_present? && new_disk_configuration_present?
|
|
227
|
+
raise "Disk image #{config[:image_name]} is not valid - check your image name and image project" if boot_disk_source_image.nil?
|
|
157
228
|
|
|
158
229
|
warn("Both zone and region specified - region will be ignored.") if config[:zone] && config[:region]
|
|
159
230
|
warn("Both image family and name specified - image family will be ignored") if config[:image_family] && config[:image_name]
|
|
@@ -161,6 +232,7 @@ module Kitchen
|
|
|
161
232
|
warn("Subnet project not specified - searching current project only") if config[:subnet] && !config[:subnet_project]
|
|
162
233
|
warn("Auto-migrate disabled for preemptible instance") if preemptible? && config[:auto_migrate]
|
|
163
234
|
warn("Auto-restart disabled for preemptible instance") if preemptible? && config[:auto_restart]
|
|
235
|
+
warn("These configs are deprecated - consider using new disks configuration") if old_disk_configuration_present?
|
|
164
236
|
end
|
|
165
237
|
|
|
166
238
|
def connection
|
|
@@ -245,9 +317,13 @@ module Kitchen
|
|
|
245
317
|
check_api_call { connection.get_region(project, config[:region]) }
|
|
246
318
|
end
|
|
247
319
|
|
|
248
|
-
def valid_disk_type?
|
|
249
|
-
return false if
|
|
250
|
-
check_api_call { connection.get_disk_type(project, zone,
|
|
320
|
+
def valid_disk_type?(disk_type)
|
|
321
|
+
return false if disk_type.nil?
|
|
322
|
+
check_api_call { connection.get_disk_type(project, zone, disk_type) }
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
def valid_disk_name?(disk_name)
|
|
326
|
+
disk_name.to_s.match(DISK_NAME_REGEX).to_s.length == disk_name.length
|
|
251
327
|
end
|
|
252
328
|
|
|
253
329
|
def image_exist?
|
|
@@ -327,7 +403,7 @@ module Kitchen
|
|
|
327
403
|
def create_instance_object(server_name)
|
|
328
404
|
inst_obj = Google::Apis::ComputeV1::Instance.new
|
|
329
405
|
inst_obj.name = server_name
|
|
330
|
-
inst_obj.disks =
|
|
406
|
+
inst_obj.disks = create_disks(server_name)
|
|
331
407
|
inst_obj.machine_type = machine_type_url
|
|
332
408
|
inst_obj.metadata = instance_metadata
|
|
333
409
|
inst_obj.network_interfaces = instance_network_interfaces
|
|
@@ -353,25 +429,84 @@ module Kitchen
|
|
|
353
429
|
name.gsub(/([^-a-z0-9])/, "-")
|
|
354
430
|
end
|
|
355
431
|
|
|
356
|
-
def
|
|
432
|
+
def create_disks(server_name)
|
|
433
|
+
disks = []
|
|
434
|
+
|
|
435
|
+
config[:disks].each do |disk_name, disk_config|
|
|
436
|
+
unique_disk_name = "#{server_name}-#{disk_name}"
|
|
437
|
+
if disk_config[:boot]
|
|
438
|
+
disk = create_local_disk(unique_disk_name, disk_config)
|
|
439
|
+
disks.unshift(disk)
|
|
440
|
+
elsif disk_config[:disk_type] == "local-ssd"
|
|
441
|
+
disk = create_local_disk(unique_disk_name, disk_config)
|
|
442
|
+
disks.push(disk)
|
|
443
|
+
else
|
|
444
|
+
disk = create_attached_disk(unique_disk_name, disk_config)
|
|
445
|
+
disks.push(disk)
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
disks
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
def create_local_disk(unique_disk_name, disk_config)
|
|
357
452
|
disk = Google::Apis::ComputeV1::AttachedDisk.new
|
|
453
|
+
# Specifies the parameters for a new disk that will be created alongside the new instance.
|
|
358
454
|
params = Google::Apis::ComputeV1::AttachedDiskInitializeParams.new
|
|
359
|
-
|
|
360
|
-
disk.
|
|
361
|
-
|
|
362
|
-
params.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
455
|
+
disk.boot = true if !disk_config[:boot].nil? && disk_config[:boot].to_s == "true"
|
|
456
|
+
disk.auto_delete = disk_config[:autodelete_disk]
|
|
457
|
+
params.disk_size_gb = disk_config[:disk_size]
|
|
458
|
+
params.disk_type = disk_type_url_for(disk_config[:disk_type])
|
|
459
|
+
|
|
460
|
+
if disk_config[:disk_type] == "local-ssd"
|
|
461
|
+
info("Creating a 375 GB local ssd as scratch disk (https://cloud.google.com/compute/docs/disks/#localssds).")
|
|
462
|
+
disk.type = "SCRATCH"
|
|
463
|
+
else
|
|
464
|
+
info("Creating a #{disk_config[:disk_size]} GB boot disk named #{unique_disk_name}...")
|
|
465
|
+
params.source_image = boot_disk_source_image unless disk_config[:disk_type] == "local-ssd"
|
|
466
|
+
params.disk_name = unique_disk_name unless disk_config[:disk_type] == "local-ssd"
|
|
467
|
+
end
|
|
367
468
|
disk.initialize_params = params
|
|
368
469
|
disk
|
|
369
470
|
end
|
|
370
471
|
|
|
472
|
+
def create_attached_disk(unique_disk_name, disk_config)
|
|
473
|
+
disk = Google::Apis::ComputeV1::Disk.new
|
|
474
|
+
disk.name = unique_disk_name
|
|
475
|
+
disk.size_gb = disk_config[:disk_size]
|
|
476
|
+
disk.type = disk_type_url_for(disk_config[:disk_type])
|
|
477
|
+
|
|
478
|
+
info("Creating a #{disk_config[:disk_size]} GB disk named #{unique_disk_name}...")
|
|
479
|
+
wait_for_operation(connection.insert_disk(project, zone, disk))
|
|
480
|
+
info("Waiting for disk to be ready...")
|
|
481
|
+
wait_for_status("READY") { connection.get_disk(project, zone, unique_disk_name) }
|
|
482
|
+
info("Disk created successfully.")
|
|
483
|
+
attached_disk = Google::Apis::ComputeV1::AttachedDisk.new
|
|
484
|
+
attached_disk.source = disk_self_link(unique_disk_name)
|
|
485
|
+
attached_disk.auto_delete = disk_config[:autodelete_disk]
|
|
486
|
+
attached_disk
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
def delete_disk(unique_disk_name)
|
|
490
|
+
begin
|
|
491
|
+
connection.get_disk(project, zone, unique_disk_name)
|
|
492
|
+
rescue Google::Apis::ClientError
|
|
493
|
+
info("Unable to locate disk #{unique_disk_name} in project #{project}, zone #{zone}")
|
|
494
|
+
return
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
info("Waiting for disk #{unique_disk_name} to be deleted...")
|
|
498
|
+
wait_for_operation(connection.delete_disk(project, zone, unique_disk_name))
|
|
499
|
+
info("Disk #{unique_disk_name} deleted successfully.")
|
|
500
|
+
end
|
|
501
|
+
|
|
371
502
|
def disk_type_url_for(type)
|
|
372
503
|
"zones/#{zone}/diskTypes/#{type}"
|
|
373
504
|
end
|
|
374
505
|
|
|
506
|
+
def disk_self_link(unique_disk_name)
|
|
507
|
+
"projects/#{project}/zones/#{zone}/disks/#{unique_disk_name}"
|
|
508
|
+
end
|
|
509
|
+
|
|
375
510
|
def boot_disk_source_image
|
|
376
511
|
@boot_disk_source ||= image_url
|
|
377
512
|
end
|
|
@@ -390,11 +525,20 @@ module Kitchen
|
|
|
390
525
|
end
|
|
391
526
|
|
|
392
527
|
def metadata
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
528
|
+
default_metadata = {
|
|
529
|
+
"created-by" => "test-kitchen",
|
|
530
|
+
"test-kitchen-instance" => instance.name,
|
|
531
|
+
"test-kitchen-user" => env_user,
|
|
532
|
+
}
|
|
533
|
+
if winrm_transport?
|
|
534
|
+
image_identifier = config[:image_family] || config[:image_name]
|
|
535
|
+
default_metadata["windows-startup-script-ps1"] = 'netsh advfirewall firewall add rule name="winrm" dir=in action=allow protocol=TCP localport=5985;'
|
|
536
|
+
if !image_identifier.nil? && image_identifier.include?("2008")
|
|
537
|
+
default_metadata["windows-startup-script-ps1"] += "winrm quickconfig -q"
|
|
538
|
+
end
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
config[:metadata].merge(default_metadata)
|
|
398
542
|
end
|
|
399
543
|
|
|
400
544
|
def instance_metadata
|
|
@@ -302,16 +302,31 @@ describe Kitchen::Driver::Gce do
|
|
|
302
302
|
expect { driver.validate! }.to raise_error(RuntimeError, "Machine type test_machine_type is not valid")
|
|
303
303
|
end
|
|
304
304
|
|
|
305
|
-
it "raises an exception if the disk_type is invalid" do
|
|
306
|
-
expect(driver).to receive(:valid_disk_type?).and_return(false)
|
|
307
|
-
expect { driver.validate! }.to raise_error(RuntimeError, "Disk type test_disk_type is not valid")
|
|
308
|
-
end
|
|
309
|
-
|
|
310
305
|
it "raises an exception if the boot disk source image is invalid" do
|
|
311
306
|
expect(driver).to receive(:boot_disk_source_image).and_return(nil)
|
|
312
307
|
expect { driver.validate! }.to raise_error(RuntimeError, "Disk image test_image is not valid - check your image name and image project")
|
|
313
308
|
end
|
|
314
309
|
|
|
310
|
+
context "both disk configurations are active" do
|
|
311
|
+
let(:config) do
|
|
312
|
+
{
|
|
313
|
+
project: "test_project",
|
|
314
|
+
zone: "test_zone",
|
|
315
|
+
image_name: "test_image",
|
|
316
|
+
machine_type: "test_machine_type",
|
|
317
|
+
autodelete_disk: true,
|
|
318
|
+
disks: {
|
|
319
|
+
disk0: {
|
|
320
|
+
autodelete_disk: true,
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
}
|
|
324
|
+
end
|
|
325
|
+
it "raises an exception if parameters from both disk configurations are present" do
|
|
326
|
+
expect { driver.validate! }.to raise_error(RuntimeError, "You cannot use autodelete_disk, disk_size or disk_type with the new disks configuration")
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
315
330
|
it "raises an exception if the network is invalid" do
|
|
316
331
|
expect(driver).to receive(:valid_network?).and_return(false)
|
|
317
332
|
expect { driver.validate! }.to raise_error(RuntimeError, "Network test_network is not valid")
|
|
@@ -431,11 +446,6 @@ describe Kitchen::Driver::Gce do
|
|
|
431
446
|
it_behaves_like "a validity checker", :region, :get_region, "test_project"
|
|
432
447
|
end
|
|
433
448
|
|
|
434
|
-
describe "#valid_disk_type?" do
|
|
435
|
-
subject { driver.valid_disk_type? }
|
|
436
|
-
it_behaves_like "a validity checker", :disk_type, :get_disk_type, "test_project", "test_zone"
|
|
437
|
-
end
|
|
438
|
-
|
|
439
449
|
describe "#image_exist?" do
|
|
440
450
|
it "checks the outcome of the API call" do
|
|
441
451
|
connection = double("connection")
|
|
@@ -638,32 +648,187 @@ describe Kitchen::Driver::Gce do
|
|
|
638
648
|
end
|
|
639
649
|
end
|
|
640
650
|
|
|
641
|
-
describe "#
|
|
642
|
-
it "
|
|
643
|
-
|
|
644
|
-
|
|
651
|
+
describe "#create_disks_config" do
|
|
652
|
+
it "creates the new disk config from the old one" do
|
|
653
|
+
config = {
|
|
654
|
+
disk_size: 30,
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
allow(driver).to receive(:config).and_return(config)
|
|
658
|
+
allow(driver).to receive(:valid_disk_type?).and_return(true)
|
|
659
|
+
driver.create_disks_config
|
|
660
|
+
expect(config[:disks][:disk1][:autodelete_disk]).to eq(true)
|
|
661
|
+
expect(config[:disks][:disk1][:disk_type]).to eq("pd-standard")
|
|
662
|
+
expect(config[:disks][:disk1][:disk_size]).to eq(30)
|
|
663
|
+
end
|
|
664
|
+
|
|
665
|
+
it "creates the default disk config, with an incomplete new configuration" do
|
|
666
|
+
config = {
|
|
667
|
+
disks: {
|
|
668
|
+
disk1: {
|
|
669
|
+
boot: true,
|
|
670
|
+
},
|
|
671
|
+
},
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
allow(driver).to receive(:config).and_return(config)
|
|
675
|
+
allow(driver).to receive(:valid_disk_type?).and_return(true)
|
|
676
|
+
driver.create_disks_config
|
|
677
|
+
expect(config[:disks][:disk1][:autodelete_disk]).to eq(true)
|
|
678
|
+
expect(config[:disks][:disk1][:disk_type]).to eq("pd-standard")
|
|
679
|
+
expect(config[:disks][:disk1][:disk_size]).to eq(10)
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
it "creates the default disk config with no config" do
|
|
683
|
+
config = {}
|
|
645
684
|
|
|
646
|
-
config
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
685
|
+
allow(driver).to receive(:config).and_return(config)
|
|
686
|
+
allow(driver).to receive(:valid_disk_type?).and_return(true)
|
|
687
|
+
driver.create_disks_config
|
|
688
|
+
expect(config[:disks][:disk1][:autodelete_disk]).to eq(true)
|
|
689
|
+
expect(config[:disks][:disk1][:disk_type]).to eq("pd-standard")
|
|
690
|
+
expect(config[:disks][:disk1][:disk_size]).to eq(10)
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
it "raises an error if disk_size is specified for a local ssd" do
|
|
694
|
+
config = {
|
|
695
|
+
disks: {
|
|
696
|
+
disk0: {
|
|
697
|
+
boot: true,
|
|
698
|
+
},
|
|
699
|
+
disk1: {
|
|
700
|
+
disk_type: "local-ssd",
|
|
701
|
+
disk_size: "15",
|
|
702
|
+
},
|
|
703
|
+
},
|
|
650
704
|
}
|
|
705
|
+
allow(driver).to receive(:config).and_return(config)
|
|
706
|
+
allow(driver).to receive(:valid_disk_type?).and_return(true)
|
|
707
|
+
expect { driver.create_disks_config }.to raise_error("disk1: Cannot use 'disk_size' with local SSD. They always have 375 GB (https://cloud.google.com/compute/docs/disks/#localssds).")
|
|
708
|
+
end
|
|
651
709
|
|
|
710
|
+
it "raises an error if the boot disk is specified as local ssd" do
|
|
711
|
+
config = {
|
|
712
|
+
disks: {
|
|
713
|
+
disk0: {
|
|
714
|
+
boot: true,
|
|
715
|
+
disk_type: "local-ssd",
|
|
716
|
+
},
|
|
717
|
+
},
|
|
718
|
+
}
|
|
719
|
+
allow(driver).to receive(:config).and_return(config)
|
|
720
|
+
allow(driver).to receive(:valid_disk_type?).and_return(true)
|
|
721
|
+
expect { driver.create_disks_config }.to raise_error("Boot disk cannot be local SSD.")
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
it "raises an error if the disk_name is not valid" do
|
|
725
|
+
config = {
|
|
726
|
+
disks: {
|
|
727
|
+
'my-invalid&disk/name': {
|
|
728
|
+
boot: true,
|
|
729
|
+
},
|
|
730
|
+
},
|
|
731
|
+
}
|
|
732
|
+
allow(driver).to receive(:config).and_return(config)
|
|
733
|
+
allow(driver).to receive(:valid_disk_type?).and_return(true)
|
|
734
|
+
expect { driver.create_disks_config }.to raise_error("Disk name invalid. Must match (?-mix:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?).")
|
|
735
|
+
end
|
|
736
|
+
end
|
|
737
|
+
|
|
738
|
+
describe "#create_disks" do
|
|
739
|
+
it "sets up a boot disk if boot is present and returns it" do
|
|
740
|
+
|
|
741
|
+
config = {
|
|
742
|
+
disks: {
|
|
743
|
+
disk1: {
|
|
744
|
+
boot: true,
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
connection = double("connection")
|
|
750
|
+
image = double("image")
|
|
751
|
+
allow(image).to receive(:name).and_return("test_image")
|
|
752
|
+
allow(connection).to receive(:get_image_from_family).and_return(image)
|
|
753
|
+
allow(connection).to receive(:get_image).and_return(image)
|
|
754
|
+
allow(driver).to receive(:config).and_return(config)
|
|
755
|
+
allow(driver).to receive(:connection).and_return(connection)
|
|
756
|
+
disk = driver.create_disks("server_1")
|
|
757
|
+
expect(disk.first.initialize_params.disk_name).to eq("server_1-disk1")
|
|
758
|
+
expect(disk.first.initialize_params.source_image).to eq("projects/test_project/global/images/test_image")
|
|
759
|
+
expect(disk.first.is_a?(Google::Apis::ComputeV1::AttachedDisk)).to eq(true)
|
|
760
|
+
expect(disk.first.boot).to eq(true)
|
|
761
|
+
end
|
|
762
|
+
|
|
763
|
+
it "sets up an local ssd as scratch disk and returns it" do
|
|
764
|
+
config = {
|
|
765
|
+
disks: {
|
|
766
|
+
disk1: {
|
|
767
|
+
disk_type: "local-ssd",
|
|
768
|
+
},
|
|
769
|
+
},
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
connection = double("connection")
|
|
773
|
+
allow(driver).to receive(:config).and_return(config)
|
|
774
|
+
allow(driver).to receive(:connection).and_return(connection)
|
|
775
|
+
disk = driver.create_disks("server_1")
|
|
776
|
+
expect(disk.first.initialize_params.disk_name).to eq(nil)
|
|
777
|
+
expect(disk.first.initialize_params.source_image).to eq(nil)
|
|
778
|
+
expect(disk.first.initialize_params.disk_size_gb).to eq(nil)
|
|
779
|
+
expect(disk.first.initialize_params.disk_type).to eq("zones/test_zone/diskTypes/local-ssd")
|
|
780
|
+
expect(disk.first.type).to eq("SCRATCH")
|
|
781
|
+
expect(disk.first.is_a?(Google::Apis::ComputeV1::AttachedDisk)).to eq(true)
|
|
782
|
+
end
|
|
783
|
+
|
|
784
|
+
it "sets up an attached disk if boot is not present and returns it" do
|
|
785
|
+
config = {
|
|
786
|
+
disks: {
|
|
787
|
+
disk1: {
|
|
788
|
+
autodelete_disk: false,
|
|
789
|
+
},
|
|
790
|
+
},
|
|
791
|
+
}
|
|
792
|
+
connection = double("connection")
|
|
793
|
+
item = double("item")
|
|
794
|
+
allow(driver).to receive(:connection).and_return(connection)
|
|
795
|
+
allow(driver).to receive(:wait_for_operation).and_return(true)
|
|
796
|
+
allow(item).to receive(:status).and_return("READY")
|
|
797
|
+
allow(connection).to receive(:insert_disk).and_return("DONE")
|
|
798
|
+
allow(connection).to receive(:get_disk).with(project, zone, "server_1-disk1").and_return(item)
|
|
799
|
+
allow(driver).to receive(:config).and_return(config)
|
|
800
|
+
disk = driver.create_disks("server_1")
|
|
801
|
+
expect(disk.first.is_a?(Google::Apis::ComputeV1::AttachedDisk)).to eq(true)
|
|
802
|
+
expect(disk.first.source).to eq("projects/#{project}/zones/#{zone}/disks/server_1-disk1")
|
|
803
|
+
end
|
|
804
|
+
|
|
805
|
+
it "sets up a boot disk and an attached disk if two disks are defined" do
|
|
806
|
+
config = {
|
|
807
|
+
disks: {
|
|
808
|
+
disk1: {
|
|
809
|
+
autodelete_disk: false,
|
|
810
|
+
},
|
|
811
|
+
disk2: {
|
|
812
|
+
disk_size: 15,
|
|
813
|
+
},
|
|
814
|
+
},
|
|
815
|
+
}
|
|
816
|
+
connection = double("connection")
|
|
817
|
+
item = double("item")
|
|
818
|
+
allow(driver).to receive(:connection).and_return(connection)
|
|
819
|
+
allow(driver).to receive(:wait_for_operation).and_return(true)
|
|
820
|
+
allow(item).to receive(:status).and_return("READY")
|
|
821
|
+
allow(connection).to receive(:insert_disk).and_return("DONE")
|
|
822
|
+
allow(connection).to receive(:get_disk).with(project, zone, "server_1-disk2").and_return(item)
|
|
823
|
+
allow(connection).to receive(:get_disk).with(project, zone, "server_1-disk1").and_return(item)
|
|
652
824
|
allow(driver).to receive(:config).and_return(config)
|
|
653
|
-
|
|
654
|
-
expect(
|
|
655
|
-
|
|
656
|
-
expect(
|
|
657
|
-
expect(Google::Apis::ComputeV1::
|
|
658
|
-
expect(
|
|
659
|
-
expect(
|
|
660
|
-
expect(disk).to receive(:initialize_params=).with(params)
|
|
661
|
-
expect(params).to receive(:disk_name=).with("server_1")
|
|
662
|
-
expect(params).to receive(:disk_size_gb=).with("test_size")
|
|
663
|
-
expect(params).to receive(:disk_type=).with("disk_url")
|
|
664
|
-
expect(params).to receive(:source_image=).with("disk_image_url")
|
|
665
|
-
|
|
666
|
-
expect(driver.boot_disk("server_1")).to eq(disk)
|
|
825
|
+
disks = driver.create_disks("server_1")
|
|
826
|
+
expect(disks.first.is_a?(Google::Apis::ComputeV1::AttachedDisk)).to eq(true)
|
|
827
|
+
expect(disks.first.source).to eq("projects/#{project}/zones/#{zone}/disks/server_1-disk1")
|
|
828
|
+
expect(disks.first.auto_delete).to eq(false)
|
|
829
|
+
expect(disks.last.is_a?(Google::Apis::ComputeV1::AttachedDisk)).to eq(true)
|
|
830
|
+
expect(disks.last.auto_delete).to eq(nil)
|
|
831
|
+
expect(disks.last.source).to eq("projects/#{project}/zones/#{zone}/disks/server_1-disk2")
|
|
667
832
|
end
|
|
668
833
|
end
|
|
669
834
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-google
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Leonard
|
|
@@ -17,28 +17,28 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - "~>"
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '1.
|
|
20
|
+
version: '1.1'
|
|
21
21
|
type: :runtime
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
25
|
- - "~>"
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '1.
|
|
27
|
+
version: '1.1'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: google-api-client
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
32
|
- - "~>"
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: 0.
|
|
34
|
+
version: '0.19'
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
39
|
- - "~>"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: 0.
|
|
41
|
+
version: '0.19'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: test-kitchen
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -123,6 +123,20 @@ dependencies:
|
|
|
123
123
|
- - ">="
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
125
|
version: '0'
|
|
126
|
+
- !ruby/object:Gem::Dependency
|
|
127
|
+
name: byebug
|
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
|
129
|
+
requirements:
|
|
130
|
+
- - ">="
|
|
131
|
+
- !ruby/object:Gem::Version
|
|
132
|
+
version: '0'
|
|
133
|
+
type: :development
|
|
134
|
+
prerelease: false
|
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - ">="
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '0'
|
|
126
140
|
description: A Test-Kitchen driver for Google Compute Engine
|
|
127
141
|
email:
|
|
128
142
|
- andy@hurricane-ridge.com
|
|
@@ -165,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
179
|
version: '0'
|
|
166
180
|
requirements: []
|
|
167
181
|
rubyforge_project:
|
|
168
|
-
rubygems_version: 2.6
|
|
182
|
+
rubygems_version: 2.7.6
|
|
169
183
|
signing_key:
|
|
170
184
|
specification_version: 4
|
|
171
185
|
summary: Kitchen::Driver::Gce
|