-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(google) Add support for subnetwork config default and gce_subnetwork…
… extended attribute. (#170)
- Loading branch information
Matt Duftler
authored
Jan 28, 2017
1 parent
c69d724
commit 3f24c2b
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -404,13 +404,18 @@ class GCEBakeHandlerSpec extends Specification implements TestDefaults{ | |
package_name: PACKAGES_NAME, | ||
base_os: "precise", | ||
cloud_provider_type: BakeRequest.CloudProviderType.gce, | ||
extended_attributes: [gce_zone: "europe-west1-b", gce_network: "other-network"]) | ||
extended_attributes: [ | ||
gce_zone: "europe-west1-b", | ||
gce_network: "other-network", | ||
gce_subnetwork: "custom-subnetwork" | ||
]) | ||
def targetImageName = "kato-x8664-timestamp-precise" | ||
def osPackages = parseDebOsPackageNames(bakeRequest.package_name) | ||
def parameterMap = [ | ||
gce_project_id: googleConfigurationProperties.accounts.get(0).project, | ||
gce_zone: "europe-west1-b", | ||
gce_network: "other-network", | ||
gce_subnetwork: "custom-subnetwork", | ||
gce_source_image: SOURCE_PRECISE_IMAGE_NAME, | ||
gce_target_image: targetImageName, | ||
repository: DEBIAN_REPOSITORY, | ||
|
@@ -437,6 +442,49 @@ class GCEBakeHandlerSpec extends Specification implements TestDefaults{ | |
1 * packerCommandFactoryMock.buildPackerCommand("", parameterMap, null, "$configDir/$gceBakeryDefaults.templateFile") | ||
} | ||
|
||
void 'produces packer command with all required parameters for precise, and respects optional subnetwork config default'() { | ||
setup: | ||
def imageNameFactoryMock = Mock(ImageNameFactory) | ||
def packerCommandFactoryMock = Mock(PackerCommandFactory) | ||
def bakeRequest = new BakeRequest(user: "[email protected]", | ||
package_name: PACKAGES_NAME, | ||
base_os: "precise", | ||
cloud_provider_type: BakeRequest.CloudProviderType.gce) | ||
def targetImageName = "kato-x8664-timestamp-precise" | ||
def osPackages = parseDebOsPackageNames(bakeRequest.package_name) | ||
def parameterMap = [ | ||
gce_project_id: googleConfigurationProperties.accounts.get(0).project, | ||
gce_zone: gceBakeryDefaults.zone, | ||
gce_network: gceBakeryDefaults.network, | ||
gce_subnetwork: "custom-subnetwork", | ||
gce_source_image: SOURCE_PRECISE_IMAGE_NAME, | ||
gce_target_image: targetImageName, | ||
repository: DEBIAN_REPOSITORY, | ||
package_type: DEB_PACKAGE_TYPE.packageType, | ||
packages: PACKAGES_NAME, | ||
configDir: configDir | ||
] | ||
def gceBakeryDefaultsAugmented = gceBakeryDefaults.clone() | ||
gceBakeryDefaultsAugmented.subnetwork = "custom-subnetwork" | ||
|
||
@Subject | ||
GCEBakeHandler gceBakeHandler = new GCEBakeHandler(configDir: configDir, | ||
gceBakeryDefaults: gceBakeryDefaultsAugmented, | ||
googleConfigurationProperties: googleConfigurationProperties, | ||
imageNameFactory: imageNameFactoryMock, | ||
packerCommandFactory: packerCommandFactoryMock, | ||
debianRepository: DEBIAN_REPOSITORY) | ||
|
||
when: | ||
gceBakeHandler.producePackerCommand(REGION, bakeRequest) | ||
|
||
then: | ||
1 * imageNameFactoryMock.buildImageName(bakeRequest, osPackages) >> targetImageName | ||
1 * imageNameFactoryMock.buildAppVersionStr(bakeRequest, osPackages) >> null | ||
1 * imageNameFactoryMock.buildPackagesParameter(DEB_PACKAGE_TYPE, osPackages) >> PACKAGES_NAME | ||
1 * packerCommandFactoryMock.buildPackerCommand("", parameterMap, null, "$configDir/$gceBakeryDefaults.templateFile") | ||
} | ||
|
||
void 'produces packer command with all required parameters for trusty'() { | ||
setup: | ||
def imageNameFactoryMock = Mock(ImageNameFactory) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters