use of com.walmartlabs.concord.plugins.OKHttpDownloadManager in project concord-plugins by walmartlabs.
the class PackerTaskTest method valiateDownloadingNonDefaultVersionOfPacker.
@Test
public void valiateDownloadingNonDefaultVersionOfPacker() throws Exception {
ToolInitializer toolInitializer = new ToolInitializer(new OKHttpDownloadManager("packer"));
Map<String, ToolCommand> commands = ImmutableMap.of("packer/version", new Version());
PackerTask task = new PackerTask(commands, toolInitializer);
Map<String, Object> args = Maps.newHashMap(mapBuilder().put("version", "1.5.2").put("command", "version").put("saveOutput", true).build());
Context context = context(args);
task.execute(context);
String expectedCommandLine = "packer version";
assertThat(normalizedCommandLineArguments(context)).isEqualTo(expectedCommandLine);
// Retrieve the logs from the context and assert we retrieved an alternate version
assertThat(varAsString(context, "logs")).contains("Packer v1.5.2");
}
use of com.walmartlabs.concord.plugins.OKHttpDownloadManager in project concord-plugins by walmartlabs.
the class PackerTaskTest method valiatePackerBuildCommandConstruction.
@Test
public void valiatePackerBuildCommandConstruction() throws Exception {
ToolInitializer toolInitializer = new ToolInitializer(new OKHttpDownloadManager("packer"));
Map<String, ToolCommand> commands = ImmutableMap.of("packer/build", new Build());
PackerTask task = new PackerTask(commands, toolInitializer);
Map<String, Object> args = Maps.newHashMap(mapBuilder().put("dryRun", true).put("command", "build").put("saveOutput", true).put("debug", true).put("force", true).put("except", ImmutableList.of("foo", "bar", "baz")).put("extraVars", mapBuilder().put("aws_access_key", "foo").put("aws_secret_key", "bar").build()).put("template", "packer.json").build());
Context context = context(args);
task.execute(context);
// the extraVars are going to get serialized to a packer variables json file
String expectedCommandLine = "packer build -debug -color=false -force -except=foo,bar,baz packer.json -var-file=.*\\.variables\\.json";
assertThat(normalizedCommandLineArguments(context)).matches(expectedCommandLine);
}
use of com.walmartlabs.concord.plugins.OKHttpDownloadManager in project concord-plugins by walmartlabs.
the class PackerTaskExecutionTest method validateExecutingPacker.
@Test
public void validateExecutingPacker() throws Exception {
ToolInitializer toolInitializer = new ToolInitializer(new OKHttpDownloadManager("packer"));
Map<String, ToolCommand> commands = ImmutableMap.of("packer/build", new Build());
PackerTask task = new PackerTask(commands, toolInitializer);
Map<String, Object> args = Maps.newHashMap(mapBuilder().put("command", "build").put("saveOutput", true).put("template", packerTestFile().toString()).build());
Context context = context(args);
task.execute(context);
/*
Debug mode enabled. Builds will not be parallelized.
==> amazon-ebs: Prevalidating any provided VPC information
==> amazon-ebs: Prevalidating AMI Name: packer-example 1585436207
amazon-ebs: Found Image ID: ami-04ac550b78324f651
==> amazon-ebs: Creating temporary keypair: packer_5e7fd62f-8128-badf-da32-4f8356ed603a
amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
==> amazon-ebs: Creating temporary security group for this instance: packer_5e7fd632-c20b-002b-ccb6-ea9e2adac21e
==> amazon-ebs: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
amazon-ebs: Adding tag: "Name": "Packer Builder"
amazon-ebs: Instance ID: i-0d5e29779b4f2406d
==> amazon-ebs: Waiting for instance (i-0d5e29779b4f2406d) to become ready...
amazon-ebs: Public DNS: ec2-34-238-135-221.compute-1.amazonaws.com
amazon-ebs: Public IP: 34.238.135.221
amazon-ebs: Private IP: 172.31.91.204
==> amazon-ebs: Using ssh communicator to connect: 34.238.135.221
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Stopping the source instance...
amazon-ebs: Stopping instance
==> amazon-ebs: Waiting for the instance to stop...
==> amazon-ebs: Creating AMI packer-example 1585436207 from instance i-0d5e29779b4f2406d
amazon-ebs: AMI: ami-083dfd9b6f66d45b5
==> amazon-ebs: Waiting for AMI to become ready...
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: No volumes to clean up, skipping
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' finished.
==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs: AMIs were created:
us-east-1: ami-083dfd9b6f66d45b5
*/
// Retrieve the logs from the context
String logs = varAsString(context, "logs");
assertThat(logs).contains("==> Builds finished. The artifacts of successful builds are:");
assertThat(logs).contains("--> amazon-ebs: AMIs were created:");
}
Aggregations