public void TestBuildApplicationWithMissingParameterFail() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, 0); string applicationId = Guid.NewGuid().ToString(); string nameUri = string.Format(CultureInfo.InvariantCulture, "fabric:/{0}", buildLayoutInfo.ApplicationManifestType.ApplicationTypeName); Dictionary <string, string> userParameters = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); // "InstanceCountParam" is used to generate the digested manifest - we validate this against being null/empty string outputFolder = "CMOutputFolder"; exitCode = exeWrapper.BuildApplication( buildLayoutInfo.ApplicationManifestType.ApplicationTypeName, buildLayoutInfo.ApplicationManifestType.ApplicationTypeVersion, applicationId, nameUri, userParameters, outputFolder); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); Verify.IsTrue(!Directory.Exists(outputFolder)); if (Directory.Exists(outputFolder)) { Directory.Delete(outputFolder, true); } }
public void AllOptions_test() { string currentExecutingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string yamlFilePath = Path.Combine(currentExecutingDirectory, "all_supported_options.yml"); string tempOutputFile = Path.GetTempFileName(); string tempPath = Path.Combine(TestUtility.TestDirectory, Guid.NewGuid().ToString()); this.imageBuilder.BuildComposeDeploymentPackage( yamlFilePath, null, TimeSpan.MaxValue, "fabric:/TestApps/TestApp1", "TestApplicationType", "v1", "TestUser", "TestPassword", false, true, tempOutputFile, tempPath, // output pkg build path false); BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore, tempPath); TestUtility.VerifyStoreLayout(buildLayoutInfo); }
public static ApplicationInstanceType GetApplicationInstance(BuildLayoutInfo buildLayoutInfo, string applicationId, int applicationInstanceVersion, RolloutVersion rolloutVersion = null) { string applicationDigestPath = Path.Combine("Store", buildLayoutInfo.ApplicationManifestType.ApplicationTypeName, "apps", applicationId); string applicationInstanceFile = Path.Combine(applicationDigestPath, string.Format("ApplicationInstance.{0}.xml", applicationInstanceVersion)); return(buildLayoutInfo.ImageStoreWrapper.GetFromStore <ApplicationInstanceType>(applicationInstanceFile, TestUtility.ImageStoreDefaultTimeout)); }
public void TestServiceManifestWithInvalidCodePackageEntryPoints() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); { var entryPoint = new DllHostEntryPointType(); entryPoint.Items = new object[] { new UnmanagedDllType { Value = "C:\\temp\\InvalidDll.dll" } }; buildLayoutInfo.ServiceManifestTypes[0].CodePackage[0].EntryPoint.Item = entryPoint; string buildPath = buildLayoutInfo.CreateBuildLayout(); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); } { var entryPoint = new DllHostEntryPointType(); entryPoint.Items = new object[] { new UnmanagedDllType { Value = "\"MyLib.dll" } }; buildLayoutInfo.ServiceManifestTypes[0].CodePackage[0].EntryPoint.Item = entryPoint; string buildPath = buildLayoutInfo.CreateBuildLayout(); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); } { var entryPoint = new DllHostEntryPointType(); entryPoint.Items = new object[] { new UnmanagedDllType { Value = "\"\"" } }; buildLayoutInfo.ServiceManifestTypes[0].CodePackage[0].EntryPoint.Item = entryPoint; string buildPath = buildLayoutInfo.CreateBuildLayout(); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); } }
public void TestBuildApplicationType() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, 0); }
public void TestServiceManifestWithInvalidCodePackageName() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); buildLayoutInfo.ServiceManifestTypes[0].CodePackage[0].Name = "InvalidCodePackageName"; string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); }
public void TestBuildApplicationTypeWithInvalidConfigOverride() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); buildLayoutInfo.SettingsType.Section = null; string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); }
public void TestApplicationManifestTypeWithPlacementConstraint(string placementConstraint, bool expectSuccess) { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); buildLayoutInfo.ApplicationManifestType.ServiceTemplates.First().PlacementConstraints = placementConstraint; string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, expectSuccess ? 0 : ImageBuilderExeTestWrapper.ImageBuilderErrorCode); }
public void TestApplicationManifestTypeWithNoServiceImport() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); buildLayoutInfo.ApplicationManifestType.ServiceManifestImport = null; string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); }
private void TestServiceManifestPlacementConstraints(string expression, bool expectSuccess) { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); ServiceTypeType sericeType = buildLayoutInfo.ServiceManifestTypes[0].ServiceTypes.First() as ServiceTypeType; Verify.IsNotNull(sericeType); sericeType.PlacementConstraints = expression; string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, expectSuccess ? 0 : ImageBuilderExeTestWrapper.ImageBuilderErrorCode); }
public void TestBuildApplicationTypeWithConflictingCodePackage_IgnoreConflict() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); string applicationTypeName = buildLayoutInfo.CreateBuildLayout(); this.imageBuilder.BuildApplicationType(applicationTypeName, TimeSpan.MaxValue); buildLayoutInfo.ApplicationManifestType.ApplicationTypeVersion = "2.0"; applicationTypeName = buildLayoutInfo.CreateBuildLayout(); ServiceManifestType serviceManifestType = buildLayoutInfo.ServiceManifestTypes[0]; TestUtility.ModifyCodePackage(serviceManifestType.CodePackage[0].Name, serviceManifestType, buildLayoutInfo); this.imageBuilder.BuildApplicationType(applicationTypeName, TimeSpan.MaxValue, null, null, true); }
public void TestGetApplicationTypeInfo() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); string applicationTypeName = null, applicationTypeVersion = null; int exitCode = exeWrapper.GetApplicationTypeInfo( buildPath, out applicationTypeName, out applicationTypeVersion); Verify.AreEqual(exitCode, 0); Verify.AreEqual(buildLayoutInfo.ApplicationManifestType.ApplicationTypeName, applicationTypeName); Verify.AreEqual(buildLayoutInfo.ApplicationManifestType.ApplicationTypeVersion, applicationTypeVersion); }
public static void VerifyApplicationDigestLayout(BuildLayoutInfo buildLayoutInfo, string applicationId, int applicationInstanceVersion, RolloutVersion rolloutVersion) { string applicationDigestPath = Path.Combine("Store", buildLayoutInfo.ApplicationManifestType.ApplicationTypeName, "apps", applicationId); string applicationInstanceFile = Path.Combine(applicationDigestPath, string.Format("ApplicationInstance.{0}.xml", applicationInstanceVersion)); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(applicationInstanceFile, TimeSpan.MaxValue)); string applicationPackageFile = Path.Combine(applicationDigestPath, string.Format("ApplicationPackage.{0}.xml", rolloutVersion)); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(applicationPackageFile, TimeSpan.MaxValue)); foreach (var serviceManifestType in buildLayoutInfo.ServiceManifestTypes) { string servicePackageFile = Path.Combine(applicationDigestPath, string.Format("{0}.Package.{1}.xml", serviceManifestType.Name, rolloutVersion)); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(servicePackageFile, TimeSpan.MaxValue)); } }
public void TestBuildApplication() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, 0); string applicationId = Guid.NewGuid().ToString(); string nameUri = string.Format(CultureInfo.InvariantCulture, "fabric:/{0}", buildLayoutInfo.ApplicationManifestType.ApplicationTypeName); Dictionary <string, string> userParameters = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); userParameters.Add("portvalue", "500"); userParameters.Add("DomainGroup", "DomainGroup"); userParameters.Add("MyUserParam", "Foo"); userParameters.Add("InstanceCountParam", "100"); string outputFolder = "CMOutputFolder"; exitCode = exeWrapper.BuildApplication( buildLayoutInfo.ApplicationManifestType.ApplicationTypeName, buildLayoutInfo.ApplicationManifestType.ApplicationTypeVersion, applicationId, nameUri, userParameters, outputFolder); Verify.AreEqual(exitCode, 0); Verify.IsTrue(Directory.Exists(outputFolder)); if (Directory.Exists(outputFolder)) { Directory.Delete(outputFolder, true); } }
public void TestUnexpectedError() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); string buildPath = buildLayoutInfo.CreateBuildLayout(); string errorDetailsFile = "ErrorDetails.txt"; ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); try { string applicationTypeName = null, applicationTypeVersion = null; int exitCode = exeWrapper.GetApplicationTypeInfo( buildPath, errorDetailsFile, out applicationTypeName, out applicationTypeVersion); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); Verify.IsTrue(File.Exists(errorDetailsFile)); using (StreamReader reader = new StreamReader(errorDetailsFile)) { var tokens = reader.ReadLine().Split(new char[] { ',' }); Verify.AreEqual(tokens.Length, 2); int fileErrorCode = int.Parse(tokens[0]); Verify.AreEqual(fileErrorCode, (int)ImageBuilderExeTestWrapper.ImageBuilderErrorCode); Verify.AreEqual(tokens[1], System.Fabric.ImageBuilderExe.StringConstants.TestErrorDetails); } } finally { if (File.Exists(errorDetailsFile)) { File.Delete(errorDetailsFile); } } }
public void TestServiceManifestWithValidCodePackageEntryPoints2() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); { var entryPoint = new EntryPointDescriptionTypeExeHost { Program = "\"Test Path\\TestLib.exe\"", Arguments = "/name:\"Test Name\" /opt", WorkingFolder = ExeHostEntryPointTypeWorkingFolder.Work }; buildLayoutInfo.ServiceManifestTypes[0].CodePackage[0].EntryPoint = new EntryPointDescriptionType { Item = entryPoint }; string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, 0); } }
public static void VerifyStoreLayout(BuildLayoutInfo buildLayoutInfo) { string applicationPathStoreLayout = Path.Combine("Store", buildLayoutInfo.ApplicationManifestType.ApplicationTypeName); var fileList = buildLayoutInfo.ImageStore.ListContent(applicationPathStoreLayout, TimeSpan.MaxValue); bool containsFabricAssembly = fileList.Any(file => file.EndsWith("FabricCommon.dll")); Assert.IsFalse(containsFabricAssembly, "StoreLayout should not contain fabric assembly"); string applicationManifestFile = Path.Combine(applicationPathStoreLayout, string.Format("ApplicationManifest.{0}.xml", buildLayoutInfo.ApplicationManifestType.ApplicationTypeVersion)); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(applicationManifestFile, TimeSpan.MaxValue), applicationManifestFile); foreach (ServiceManifestType serviceManifestType in buildLayoutInfo.ServiceManifestTypes) { string serviceManifestFile = Path.Combine(applicationPathStoreLayout, string.Format("{0}.Manifest.{1}.xml", serviceManifestType.Name, serviceManifestType.Version)); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(serviceManifestFile, TimeSpan.MaxValue), applicationPathStoreLayout); string serviceManifestChecksumPath = string.Format("{0}.{1}", serviceManifestFile, "checksum"); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(serviceManifestChecksumPath, TimeSpan.MaxValue), serviceManifestChecksumPath); if (serviceManifestType.CodePackage != null) { foreach (var codePackage in serviceManifestType.CodePackage) { if (codePackage.EntryPoint.Item is ContainerHostEntryPointType) { continue; } string codePackagePath = Path.Combine(applicationPathStoreLayout, string.Format("{0}.{1}.{2}", serviceManifestType.Name, codePackage.Name, codePackage.Version)); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(codePackagePath, TimeSpan.MaxValue), codePackagePath); string checksumPath = string.Format("{0}.{1}", codePackagePath, "checksum"); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(checksumPath, TimeSpan.MaxValue), checksumPath); } } if (serviceManifestType.DataPackage != null) { foreach (var dataPackage in serviceManifestType.DataPackage) { string dataPackagePath = Path.Combine(applicationPathStoreLayout, string.Format("{0}.{1}.{2}", serviceManifestType.Name, dataPackage.Name, dataPackage.Version)); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(dataPackagePath, TimeSpan.MaxValue), dataPackagePath); string checksumPath = string.Format("{0}.{1}", dataPackagePath, "checksum"); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(checksumPath, TimeSpan.MaxValue), checksumPath); } } if (serviceManifestType.ConfigPackage != null) { foreach (var configPackage in serviceManifestType.ConfigPackage) { string configPackagePath = Path.Combine(applicationPathStoreLayout, string.Format("{0}.{1}.{2}", serviceManifestType.Name, configPackage.Name, configPackage.Version)); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(configPackagePath, TimeSpan.MaxValue), configPackagePath); string settingPath = Path.Combine(configPackagePath, "Settings.xml"); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(settingPath, TimeSpan.MaxValue), settingPath); string checksumPath = string.Format("{0}.{1}", configPackagePath, "checksum"); Assert.IsTrue(buildLayoutInfo.ImageStore.DoesContentExist(checksumPath, TimeSpan.MaxValue), checksumPath); } } } }
public static void ModifyCodePackage(string codePackageName, ServiceManifestType serviceManifestType, BuildLayoutInfo buildLayoutInfo) { string codeFolderName = buildLayoutInfo.BuildLayoutSpecification.GetCodePackageFolder( serviceManifestType.Name, codePackageName); buildLayoutInfo.ImageStore.UploadContent( Path.Combine(codeFolderName, string.Format("AdditionalAssembly.dll", serviceManifestType.Name)), Path.Combine(TestDirectory, "System.Fabric.Management.dll"), TimeSpan.MaxValue, CopyFlag.AtomicCopy, false); }
public void TestUpgradeApplication() { BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore); string buildPath = buildLayoutInfo.CreateBuildLayout(); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, 0); string applicationId = Guid.NewGuid().ToString(); string nameUri = string.Format(CultureInfo.InvariantCulture, "fabric:/{0}", buildLayoutInfo.ApplicationManifestType.ApplicationTypeName); Dictionary <string, string> userParameters = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); userParameters.Add("portvalue", "500"); userParameters.Add("DomainGroup", "DomainGroup"); userParameters.Add("MyUserParam", "Foo"); userParameters.Add("InstanceCountParam", "100"); exitCode = exeWrapper.BuildApplication( buildLayoutInfo.ApplicationManifestType.ApplicationTypeName, buildLayoutInfo.ApplicationManifestType.ApplicationTypeVersion, applicationId, nameUri, userParameters, null); Verify.AreEqual(exitCode, 0); buildLayoutInfo.DeleteBuildLayout(); // Upgrade Application Collection <object> updatedServiceTypes = new Collection <object>(buildLayoutInfo.ServiceManifestTypes[0].ServiceTypes.ToList()); updatedServiceTypes.Add(new StatelessServiceTypeType() { ServiceTypeName = "UpdatedServiceType" }); buildLayoutInfo.ServiceManifestTypes[0].ServiceTypes = updatedServiceTypes.ToArray(); buildLayoutInfo.ServiceManifestTypes[0].Version = "1.1"; buildLayoutInfo.ApplicationManifestType.ServiceManifestImport[0].ServiceManifestRef.ServiceManifestVersion = "1.1"; buildLayoutInfo.ApplicationManifestType.ServiceTemplates = null; buildLayoutInfo.ApplicationManifestType.DefaultServices = null; buildLayoutInfo.ApplicationManifestType.ApplicationTypeVersion = "2.0"; string updatedBuildPath = buildLayoutInfo.CreateBuildLayout(); exitCode = exeWrapper.GetApplicationType(buildPath); Verify.AreEqual(exitCode, 0); string outputFolder = "CMUpdatedOutput"; exitCode = exeWrapper.UpgradeApplication( buildLayoutInfo.ApplicationManifestType.ApplicationTypeName, "1", buildLayoutInfo.ApplicationManifestType.ApplicationTypeVersion, applicationId, new Dictionary <string, string>(), outputFolder); Verify.AreEqual(exitCode, 0); Verify.IsTrue(Directory.Exists(outputFolder)); if (Directory.Exists(outputFolder)) { Directory.Delete(outputFolder, true); } }
public void UpgradeWithSetting() { string currentExecutingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string jsonFilePath = Path.Combine(currentExecutingDirectory, "Application_No_Setting.json"); string descriptionJson = File.ReadAllText(jsonFilePath); SingleInstance.Application application = JsonConvert.DeserializeObject <SingleInstance.Application>(descriptionJson); string applicationTypeName = "MeshApplicationType"; string applicationTypeVersion = "v1"; Uri applicationName = new Uri("fabric:/myapp"); string tempBuildPath = Path.Combine(TestUtility.TestDirectory, Guid.NewGuid().ToString()); string outputPath = Path.Combine(TestUtility.TestDirectory, Guid.NewGuid().ToString()); string applicationId = Guid.NewGuid().ToString(); this.imageBuilder.BuildSingleInstanceApplication( application, applicationTypeName, applicationTypeVersion, applicationId, applicationName, true, //generateDNS TimeSpan.MaxValue, tempBuildPath, outputPath, // output pkg build path false, //use open network false, //use local nat network "C:\\", new SingleInstance.GenerationConfig()); BuildLayoutInfo buildLayoutInfo = new BuildLayoutInfo(this.imageStore, tempBuildPath); ApplicationInstanceType applicationInstance = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 1); TestUtility.VerifyStoreLayout(buildLayoutInfo); StoreLayoutSpecification storeLayoutSpec = StoreLayoutSpecification.Create(); storeLayoutSpec.SetRoot(outputPath); string servicePackageFile = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance.ServicePackageRef[0].RolloutVersion); var servicepackage = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile, TestUtility.ImageStoreDefaultTimeout); string rolloutVersion1 = servicepackage.RolloutVersion; // Test Case 1: Instance Count change string jsonFilePath2 = Path.Combine(currentExecutingDirectory, "Application_No_Setting2.json"); string descriptionJson2 = File.ReadAllText(jsonFilePath2); SingleInstance.Application application2 = JsonConvert.DeserializeObject <SingleInstance.Application>(descriptionJson2); string applicationTypeVersion2 = "v2"; this.imageBuilder.BuildSingleInstanceApplicationForUpgrade( application2, applicationTypeName, applicationTypeVersion, applicationTypeVersion2, applicationId, applicationInstance.Version, applicationName, true, //generateDNS TimeSpan.MaxValue, tempBuildPath, outputPath, false, //use open network false, //use local nat network "C:\\", new SingleInstance.GenerationConfig()); ApplicationInstanceType applicationInstance2 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 2); string servicePackageFile2 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance2.ServicePackageRef[0].RolloutVersion); var servicepackage2 = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile2, TestUtility.ImageStoreDefaultTimeout); Verify.AreEqual(servicepackage2.ManifestVersion, "v1"); string rolloutVersion2 = servicepackage2.RolloutVersion; Verify.AreEqual(rolloutVersion1, rolloutVersion2); TestUtility.VerifyStoreLayout(buildLayoutInfo); // Test Case 2: Adding settings string jsonSettingFilePath1 = Path.Combine(currentExecutingDirectory, "Application_Setting1.json"); string settingDescriptionJson1 = File.ReadAllText(jsonSettingFilePath1); SingleInstance.Application applicationWithSetting1 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson1); string applicationTypeVersion3 = "v3"; this.imageBuilder.BuildSingleInstanceApplicationForUpgrade( applicationWithSetting1, applicationTypeName, applicationTypeVersion2, applicationTypeVersion3, applicationId, applicationInstance2.Version, applicationName, true, //generateDNS TimeSpan.MaxValue, tempBuildPath, outputPath, false, //use open network false, //use localnat network "C:\\", new SingleInstance.GenerationConfig()); ApplicationInstanceType applicationInstance3 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 3); string servicePackageFile3 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance3.ServicePackageRef[0].RolloutVersion); var servicepackage3 = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile3, TestUtility.ImageStoreDefaultTimeout); Verify.AreEqual(servicepackage3.ManifestVersion, applicationTypeVersion3); string rolloutVersion3 = servicepackage3.RolloutVersion; Verify.AreNotEqual(rolloutVersion2, rolloutVersion3); TestUtility.VerifyStoreLayout(buildLayoutInfo); // Test Case 3: Changing settings only string jsonSettingFilePath2 = Path.Combine(currentExecutingDirectory, "Application_Setting2.json"); string settingDescriptionJson2 = File.ReadAllText(jsonSettingFilePath2); SingleInstance.Application applicationWithSetting2 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson2); string applicationTypeVersion4 = "v4"; this.imageBuilder.BuildSingleInstanceApplicationForUpgrade( applicationWithSetting2, applicationTypeName, applicationTypeVersion3, applicationTypeVersion4, applicationId, applicationInstance3.Version, applicationName, true, //generateDNS TimeSpan.MaxValue, tempBuildPath, outputPath, false, //use open network false, //use localnat network "C:\\", new SingleInstance.GenerationConfig()); ApplicationInstanceType applicationInstance4 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 4); string servicePackageFile4 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance4.ServicePackageRef[0].RolloutVersion); var servicepackage4 = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile4, TestUtility.ImageStoreDefaultTimeout); Verify.AreEqual(servicepackage4.ManifestVersion, applicationTypeVersion4); // Code package version remains the same for settings upgrade foreach (var codePackage in servicepackage4.DigestedCodePackage) { Verify.AreEqual(applicationTypeVersion3, codePackage.CodePackage.Version); } // Config package version is set to target version for settings upgrade foreach (var configPackage in servicepackage4.DigestedConfigPackage) { Verify.AreEqual(applicationTypeVersion4, configPackage.ConfigPackage.Version); } string rolloutVersion4 = servicepackage4.RolloutVersion; Verify.AreNotEqual(rolloutVersion3, rolloutVersion4); TestUtility.VerifyStoreLayout(buildLayoutInfo); // Test Case 4: Keep settings string jsonSettingFilePath3 = Path.Combine(currentExecutingDirectory, "Application_Setting2InstanceCount.json"); string settingDescriptionJson3 = File.ReadAllText(jsonSettingFilePath3); SingleInstance.Application applicationWithSetting3 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson3); string applicationTypeVersion5 = "v5"; this.imageBuilder.BuildSingleInstanceApplicationForUpgrade( applicationWithSetting3, applicationTypeName, applicationTypeVersion4, applicationTypeVersion5, applicationId, applicationInstance4.Version, applicationName, true, //generateDNS TimeSpan.MaxValue, tempBuildPath, outputPath, false, //use open network false, //use localnat network "C:\\", new SingleInstance.GenerationConfig()); ApplicationInstanceType applicationInstance5 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 5); string servicePackageFile5 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance5.ServicePackageRef[0].RolloutVersion); var servicepackage5 = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile5, TestUtility.ImageStoreDefaultTimeout); // SP manifest version remains the same Verify.AreEqual(servicepackage5.ManifestVersion, applicationTypeVersion4); // SP rollout version remains the same string rolloutVersion5 = servicepackage5.RolloutVersion; Verify.AreEqual(rolloutVersion4, rolloutVersion5); TestUtility.VerifyStoreLayout(buildLayoutInfo); // Test Case 5: Autoscaling - Instance Count change string jsonSettingFilePath4 = Path.Combine(currentExecutingDirectory, "Application_Setting3Autoscaling.json"); string settingDescriptionJson4 = File.ReadAllText(jsonSettingFilePath4); SingleInstance.Application applicationWithSetting4 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson4); string applicationTypeVersion6 = "v6"; this.imageBuilder.BuildSingleInstanceApplicationForUpgrade( applicationWithSetting4, applicationTypeName, applicationTypeVersion5, applicationTypeVersion6, applicationId, applicationInstance5.Version, applicationName, true, //generateDNS TimeSpan.MaxValue, tempBuildPath, outputPath, false, //use open network false, //use localnat network "C:\\", new SingleInstance.GenerationConfig()); ApplicationInstanceType applicationInstance6 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 6); string servicePackageFile6 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance6.ServicePackageRef[0].RolloutVersion); var servicepackage6 = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile6, TestUtility.ImageStoreDefaultTimeout); Verify.AreEqual(servicepackage6.ManifestVersion, "v4"); string rolloutVersion6 = servicepackage6.RolloutVersion; Verify.AreEqual(rolloutVersion5, rolloutVersion6); TestUtility.VerifyStoreLayout(buildLayoutInfo); // Test Case 6: Changing settings and image at the same time string jsonSettingFilePath5 = Path.Combine(currentExecutingDirectory, "Application_Setting3.json"); string settingDescriptionJson5 = File.ReadAllText(jsonSettingFilePath5); SingleInstance.Application applicationWithSetting5 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson5); string applicationTypeVersion7 = "v7"; this.imageBuilder.BuildSingleInstanceApplicationForUpgrade( applicationWithSetting5, applicationTypeName, applicationTypeVersion6, applicationTypeVersion7, applicationId, applicationInstance6.Version, applicationName, true, //generateDNS TimeSpan.MaxValue, tempBuildPath, outputPath, false, //use open network false, //use localnat network "C:\\", new SingleInstance.GenerationConfig()); ApplicationInstanceType applicationInstance7 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 7); string servicePackageFile7 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance7.ServicePackageRef[0].RolloutVersion); var servicepackage7 = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile7, TestUtility.ImageStoreDefaultTimeout); Verify.AreEqual(servicepackage7.ManifestVersion, applicationTypeVersion7); // Code package version and config package version are set to target version applicationTypeVersion7 foreach (var codePackage in servicepackage7.DigestedCodePackage) { Verify.AreEqual(applicationTypeVersion7, codePackage.CodePackage.Version); } foreach (var configPackage in servicepackage7.DigestedConfigPackage) { Verify.AreEqual(applicationTypeVersion7, configPackage.ConfigPackage.Version); } string rolloutVersion7 = servicepackage7.RolloutVersion; Verify.AreNotEqual(rolloutVersion6, rolloutVersion7); TestUtility.VerifyStoreLayout(buildLayoutInfo); }