public async Task NextAvailablePublicIp_SubstituteTokensInString_ExistingBlock_Success() { var client = new FakeHttpClient(); client.AddResponse("/caas/2.0/" + OrgId + "/network/reservedPublicIpv4Address?networkDomainId=" + NetworkDomainId, "NextAvailablePublicIp_ReservedPublicIpv4Address_Get.json"); client.AddResponse("/caas/2.0/" + OrgId + "/network/publicIpBlock?networkDomainId=" + NetworkDomainId, "NextAvailablePublicIp_PublicIpBlock_Get.json"); var macro = new NextAvailablePublicIpMacro(); var input = "$nextAvailablePublicIP[$parameters['networkDomainId']]"; var output = await Macro.SubstituteTokensInString(_runtimeContext, _taskContext, input); Assert.AreEqual("168.128.52.11", output); }
public async Task ServerImage_SubstituteTokensInString_NotFound() { var client = new FakeHttpClient(); client.AddResponse("/oec/0.9/base/imageWithDiskSpeed?name=RedHat 6 64-bit 2 CPU", "Image_Get_NotFound.xml"); var macro = new ImageMacro(); var input = "$serverImage['NA9', 'RedHat 6 64-bit 2 CPU']"; await macro.SubstituteTokensInString(_runtimeContext, null, input); }
public async Task ParseAndExecuteDeploymentTasks_Failed() { var client = new FakeHttpClient(); client.AddResponse("/network/networkDomain/d5791a6d-2b69-47e2-be06-f26a2ec4bff8", "NetworkDomain_Get.json"); client.AddResponse("/network/vlan?networkDomainId=d5791a6d-2b69-47e2-be06-f26a2ec4bff8&name=Unit Test VLAN", "GenericNotFound.json"); client.AddResponse("/network/deployVlan", "GenericError.json", HttpStatusCode.BadRequest); var templateFile = Path.Combine(_resourceFolder, "StandardTemplate.json"); var parametersFile = Path.Combine(_resourceFolder, "StandardTemplateParams.json"); var taskBuilder = new TaskBuilder(); var taskExecutor = taskBuilder.BuildTasksFromDeploymentTemplate(templateFile, parametersFile); var log = await taskExecutor.Execute(_runtimeContext); Assert.AreEqual(DeploymentLogStatus.Failed, log.Status); Assert.AreEqual(1, log.Resources.Count); Assert.AreEqual(ResourceLogStatus.Failed, log.Resources[0].DeploymentStatus); Assert.AreEqual("UNEXPECTED_ERROR", log.Resources[0].Error.ResponseCode); }
public async Task ParseAndExecuteDeletionTasks_Failed() { var client = new FakeHttpClient(); client.AddResponse("/network/deleteNatRule", "NatRule_Delete.json"); client.AddResponse("/network/natRule/a6b2e743-e330-4deb-a76e-0d9cb0b1d1bb", "NatRule_Get_NotFound.json", HttpStatusCode.BadRequest); client.AddResponse("/network/removePublicIpBlock", "GenericError.json", HttpStatusCode.BadRequest); var logFile = Path.Combine(_resourceFolder, "StandardTemplateLog.json"); var taskBuilder = new TaskBuilder(); var taskExecutor = taskBuilder.BuildTasksFromDeploymentLog(logFile); var log = await taskExecutor.Execute(_runtimeContext); Assert.AreEqual(DeploymentLogStatus.Failed, log.Status); Assert.AreEqual(2, log.Resources.Count); Assert.AreEqual(ResourceLogStatus.Deleted, log.Resources[0].DeploymentStatus); Assert.AreEqual(ResourceLogStatus.Failed, log.Resources[1].DeploymentStatus); Assert.AreEqual("UNEXPECTED_ERROR", log.Resources[1].Error.ResponseCode); }
public async Task CustomerImage_SubstituteTokensInString_Success() { var client = new FakeHttpClient(); client.AddResponse("/oec/0.9/" + OrgId + "/imageWithDiskSpeed?name=RedHat 6 64-bit 2 CPU", "Image_Get.xml"); var macro = new ImageMacro(); var input = "$customerImage[$parameters['dataCenterId'], $parameters['imageName']]"; var output = await Macro.SubstituteTokensInString(_runtimeContext, _taskContext, input); Assert.AreEqual("0bf731a8-29c5-4b8b-a460-2a60ab4019cf", output); }
public async Task ParseAndExecuteDeletionTasks_Success() { var client = new FakeHttpClient(); client.AddResponse("/network/deleteNatRule", "NatRule_Delete.json"); client.AddResponse("/network/natRule/a6b2e743-e330-4deb-a76e-0d9cb0b1d1bb", "NatRule_Get_NotFound.json", HttpStatusCode.BadRequest); client.AddResponse("/network/removePublicIpBlock", "PublicIpBlock_Delete.json"); client.AddResponse("/network/publicIpBlock/996b066e-bdce-11e4-8c14-b8ca3a5d9ef8", "PublicIpBlock_Get_NotFound.json", HttpStatusCode.BadRequest); client.AddResponse("/server/deleteServer", "Server_Delete.json"); client.AddResponse("/server/server/b42b40e1-351a-4df9-b726-2ccff01f2767", "Server_Get_NotFound.json", HttpStatusCode.BadRequest); client.AddResponse("/network/deleteVlan", "Vlan_Delete.json"); client.AddResponse("/network/vlan/997e2084-00b1-4d1d-96ce-099946679c6f", "Vlan_Get_NotFound.json", HttpStatusCode.BadRequest); var logFile = Path.Combine(_resourceFolder, "StandardTemplateLog.json"); var taskBuilder = new TaskBuilder(); var taskExecutor = taskBuilder.BuildTasksFromDeploymentLog(logFile); var log = await taskExecutor.Execute(_runtimeContext); Assert.AreEqual(DeploymentLogStatus.Success, log.Status); }
public async Task ParseAndExecuteDeploymentTasks_Success() { var client = new FakeHttpClient(); client.AddResponse("/network/networkDomain/d5791a6d-2b69-47e2-be06-f26a2ec4bff8", "NetworkDomain_Get.json"); client.AddResponse("/network/vlan?networkDomainId=d5791a6d-2b69-47e2-be06-f26a2ec4bff8&name=Unit Test VLAN", "GenericNotFound.json"); client.AddResponse("/network/deployVlan", "Vlan_Delpoy.json"); client.AddResponse("/network/vlan/997e2084-00b1-4d1d-96ce-099946679c6f", "Vlan_Get.json"); client.AddResponse("/imageWithDiskSpeed?name=RedHat 6 64-bit 2 CPU", "Image_Get.xml"); client.AddResponse("/server/server?networkDomainId=d5791a6d-2b69-47e2-be06-f26a2ec4bff8&name=Unit Test Server", "GenericNotFound.json"); client.AddResponse("/server/deployServer", "Server_Deploy.json"); client.AddResponse("/server/server/b42b40e1-351a-4df9-b726-2ccff01f2767", "Server_Get.json"); client.AddResponse("/network/addPublicIpBlock", "PublicIpBlock_Add.json"); client.AddResponse("/network/publicIpBlock/996b066e-bdce-11e4-8c14-b8ca3a5d9ef8", "PublicIpBlock_Get.json"); client.AddResponse("/network/natRule?networkDomainId=d5791a6d-2b69-47e2-be06-f26a2ec4bff8&internalIp=10.0.0.8", "GenericNotFound.json"); client.AddResponse("/network/createNatRule", "NatRule_Create.json"); client.AddResponse("/network/natRule/a6b2e743-e330-4deb-a76e-0d9cb0b1d1bb", "NatRule_Get.json"); var templateFile = Path.Combine(_resourceFolder, "StandardTemplate.json"); var parametersFile = Path.Combine(_resourceFolder, "StandardTemplateParams.json"); var taskBuilder = new TaskBuilder(); var taskExecutor = taskBuilder.BuildTasksFromDeploymentTemplate(templateFile, parametersFile); var log = await taskExecutor.Execute(_runtimeContext); Assert.AreEqual(DeploymentLogStatus.Success, log.Status); Assert.AreEqual("http://168.128.5.106/index.html", taskExecutor.Context.OutputParameters["ServerPublicUrl"]); }