示例#1
0
        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);
            }
        }
示例#2
0
        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 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);
        }
示例#4
0
        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);
        }
示例#5
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);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
            }
        }
示例#12
0
        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);
                }
            }
        }
示例#13
0
        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);
            }
        }
示例#14
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);
            }
        }