public int BuildApplication( string applicationTypeName, string applicationTypeVersion, string applicationId, string nameUri, IDictionary <string, string> applicationParameters, string output) { string argumentsList = this.GetDefaultArgument(); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.Operation, StringConstants.OperationBuildApplication); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.AppTypeName, applicationTypeName); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.AppTypeVersion, applicationTypeVersion); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.AppId, applicationId); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.NameUri, nameUri); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.Output, output); string tempFile = null; if (applicationParameters.Count != 0) { tempFile = Path.GetTempFileName(); WriteApplicationParametersFile(tempFile, applicationParameters); argumentsList = AddArgument(argumentsList, StringConstants.AppParam, tempFile); } var retval = ImageBuilderExeTestWrapper.RunImageBuilder(argumentsList); if (File.Exists(tempFile)) { File.Delete(tempFile); } return(retval); }
public int UpgradeApplication( string applicationTypeName, string currentAppInstanceVersion, string targetApplicationTypeVersion, string applicationId, IDictionary <string, string> applicationParameters, string output) { string argumentsList = this.GetDefaultArgument(); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.Operation, StringConstants.OperationUpgradeApplication); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.AppTypeName, applicationTypeName); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.CurrentAppInstanceVersion, currentAppInstanceVersion); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.AppTypeVersion, targetApplicationTypeVersion); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.AppId, applicationId); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.Output, output); foreach (KeyValuePair <string, string> applicationParameter in applicationParameters) { string formatedParameter = string.Format(CultureInfo.InvariantCulture, "{0};{1}", applicationParameter.Key, applicationParameter.Value); argumentsList = ImageBuilderExeTestWrapper.AddArgument(argumentsList, StringConstants.AppParam, formatedParameter); } return(ImageBuilderExeTestWrapper.RunImageBuilder(argumentsList)); }
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 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 int ProvisionFabric(string codePath, string configPath, string infrastructureManifestFilePath) { string argumentsList = this.GetDefaultArgument(); argumentsList = AddArgument(argumentsList, StringConstants.Operation, StringConstants.OperationProvisionFabric); argumentsList = AddArgument(argumentsList, StringConstants.CodePath, codePath); argumentsList = AddArgument(argumentsList, StringConstants.ConfigPath, configPath); argumentsList = AddArgument(argumentsList, StringConstants.InfrastructureManifestFile, infrastructureManifestFilePath); return(ImageBuilderExeTestWrapper.RunImageBuilder(argumentsList)); }
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 TestInvalidBuildPath() { string buildPath = "InvalidBuildLayout"; string applicationTypeName, applicationTypeVersion; ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.GetApplicationTypeInfo(buildPath, out applicationTypeName, out applicationTypeVersion); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); }
public int GetApplicationTypeInfo(string buildPath, string errorDetailsFile, out string applicationTypeName, out string applicationTypeVersion) { int exitCode = -1; applicationTypeName = applicationTypeVersion = null; string applicationTypeInfoFile = "ApplicationTypeInfo.txt"; string argumentsList = this.GetDefaultArgument(); argumentsList = AddArgument(argumentsList, StringConstants.BuildPath, buildPath); argumentsList = AddArgument(argumentsList, StringConstants.Output, applicationTypeInfoFile); if (errorDetailsFile == null) { argumentsList = AddArgument(argumentsList, StringConstants.Operation, StringConstants.OperationBuildApplicationTypeInfo); } else { argumentsList = AddArgument(argumentsList, StringConstants.Operation, StringConstants.TestErrorDetails); argumentsList = AddArgument(argumentsList, StringConstants.ErrorDetails, errorDetailsFile); } try { exitCode = ImageBuilderExeTestWrapper.RunImageBuilder(argumentsList); if (exitCode == 0) { using (StreamReader reader = new StreamReader(applicationTypeInfoFile)) { string outputString = reader.ReadLine(); int delimiterIndex = outputString.IndexOf(":", StringComparison.OrdinalIgnoreCase); if (delimiterIndex != -1) { applicationTypeName = outputString.Substring(0, delimiterIndex); applicationTypeVersion = outputString.Substring(delimiterIndex + 1); } } } } finally { if (File.Exists(applicationTypeInfoFile)) { File.Delete(applicationTypeInfoFile); } } return(exitCode); }
public int GetApplicationType(string buildPath) { int exitCode = -1; string argumentsList = this.GetDefaultArgument(); argumentsList = AddArgument(argumentsList, StringConstants.Operation, StringConstants.OperationBuildApplicationType); argumentsList = AddArgument(argumentsList, StringConstants.BuildPath, buildPath); exitCode = ImageBuilderExeTestWrapper.RunImageBuilder(argumentsList); return(exitCode); }
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); }
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 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 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); }
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 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 void TestProvisionFabricWithMSI() { using (FabricLayoutInfo fabricLayoutInfo = new FabricLayoutInfo(this.imageStore)) { string codePath, configPath, infrastructureManifestFilePath; fabricLayoutInfo.Create(out codePath, out configPath, out infrastructureManifestFilePath); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.ProvisionFabric( codePath, configPath, infrastructureManifestFilePath); Verify.AreEqual(exitCode, 0); TestUtility.VerifyWinFabLayout(fabricLayoutInfo); } }
public int GetFabricVersion(string codePath, string configPath, out string codeVersion, out string configVersion) { int exitCode = -1; codeVersion = configVersion = null; string tempOutputFile = Path.GetTempFileName(); string argumentsList = this.GetDefaultArgument(); argumentsList = AddArgument(argumentsList, StringConstants.Operation, StringConstants.OperationGetFabricVersion); argumentsList = AddArgument(argumentsList, StringConstants.CodePath, codePath); argumentsList = AddArgument(argumentsList, StringConstants.ConfigPath, configPath); argumentsList = AddArgument(argumentsList, StringConstants.Output, tempOutputFile); try { exitCode = ImageBuilderExeTestWrapper.RunImageBuilder(argumentsList); if (exitCode == 0) { using (StreamReader reader = new StreamReader(tempOutputFile)) { string outputString = reader.ReadLine(); int delimiterIndex = outputString.IndexOf(":", StringComparison.OrdinalIgnoreCase); if (delimiterIndex != -1) { codeVersion = outputString.Substring(0, delimiterIndex); configVersion = outputString.Substring(delimiterIndex + 1); } } } } finally { if (File.Exists(tempOutputFile)) { File.Delete(tempOutputFile); } } return(exitCode); }
public void TestInvalidUpgradeApplication() { string appTypeName = "InvalidAppTypeName"; string currentInstanceVersion = "1"; string targetTypeVersion = "InvalidAppTypeVersion"; string appId = "AppId_App0"; Dictionary <string, string> parameters = new Dictionary <string, string>(); string output = ".\\"; ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.UpgradeApplication( appTypeName, currentInstanceVersion, targetTypeVersion, appId, parameters, output); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); }
public void TestGetFabricVersion() { using (FabricLayoutInfo fabricLayoutInfo = new FabricLayoutInfo(this.imageStore)) { string codePath, configPath, infrastructureManifestFilePath; fabricLayoutInfo.Create(out codePath, out configPath, out infrastructureManifestFilePath); ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); string codeVersion, configVersion; int exitCode = exeWrapper.GetFabricVersion( codePath, configPath, out codeVersion, out configVersion); Verify.AreEqual(exitCode, 0); Verify.AreEqual(codeVersion, fabricLayoutInfo.PatchVersion); Verify.AreEqual(configVersion, fabricLayoutInfo.ClusterManifest.Version); } }
public void TestInvalidBuildApplication() { string appTypeName = "InvalidAppTypeName"; string appTypeVersion = "InvalidAppTypeVersion"; string appId = "AppId_App0"; string nameUri = "fabric:/app"; Dictionary <string, string> parameters = new Dictionary <string, string>(); string output = ".\\"; ImageBuilderExeTestWrapper exeWrapper = new ImageBuilderExeTestWrapper(this.imageStore); int exitCode = exeWrapper.BuildApplication( appTypeName, appTypeVersion, appId, nameUri, parameters, output); Verify.AreEqual(exitCode, ImageBuilderExeTestWrapper.ImageBuilderErrorCode); }
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 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); } }