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 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 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 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 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); } }