Esempio n. 1
0
        public void Create(out string codePath, out string configPath, out string infrastructureManifestPath)
        {
            codePath   = string.Empty;
            configPath = string.Empty;
            infrastructureManifestPath = string.Empty;

            Directory.CreateDirectory(this.fullInfrastructureManifestFolderName);

            if (this.ClusterManifest != null)
            {
                configPath = Path.Combine(FabricLayoutInfo.RelativePath, ClusterManifestFileName);
                this.ImageStoreWrapper.SetToStore <ClusterManifestType>(configPath, this.ClusterManifest, TestUtility.ImageStoreDefaultTimeout);
            }

            if (this.InfrastructureManifest != null)
            {
                infrastructureManifestPath = Path.Combine(this.fullInfrastructureManifestFolderName, InfrastructureManifestFileName);
                TestUtility.WriteXml <InfrastructureInformationType>(infrastructureManifestPath, this.InfrastructureManifest);
            }

            if (!string.IsNullOrEmpty(this.PatchVersion))
            {
                if (this.UseMSI)
                {
                    codePath = Path.Combine(FabricLayoutInfo.RelativePath, string.Format(WindowsFabricMSIFileName, this.PatchVersion));
                    this.ImageStore.DeleteContent(codePath, TestUtility.ImageStoreDefaultTimeout);
                    this.ImageStore.UploadContent(
                        codePath,
                        Path.Combine(TestDirectory, "System.Fabric.Management.Test.dll.cfg"),
                        TestUtility.ImageStoreDefaultTimeout,
                        CopyFlag.AtomicCopy,
                        false);
                }
                else
                {
                    // Create a dummy xcopy package and copy fabric.exe into it.
                    var fabricCodePackageFolderName = string.Format(FabricLayoutInfo.WindowsFabricCodePackageFolderNamePattern, this.PatchVersion);

                    string tempDirectory = Path.Combine(TestDirectory, Guid.NewGuid().ToString());
                    var    tempFabricCodePackageFolderPath = Path.Combine(tempDirectory, fabricCodePackageFolderName);
                    try
                    {
                        foreach (string childFolder in WindowsFabricCodePackageChildrenFolders)
                        {
                            string childFolderPath = Path.Combine(tempFabricCodePackageFolderPath, childFolder);
                            if (!Directory.Exists(childFolderPath))
                            {
                                Directory.CreateDirectory(childFolderPath);
                                File.Copy(
                                    Path.Combine(FabricLayoutInfo.TestDirectory, "Fabric.exe"),
                                    Path.Combine(childFolderPath, "Fabric.exe"),
                                    true);
                            }
                        }

                        codePath = Path.Combine(RelativePath, fabricCodePackageFolderName);
                        this.ImageStore.DeleteContent(codePath, TestUtility.ImageStoreDefaultTimeout);
                        this.ImageStore.UploadContent(
                            codePath,
                            tempFabricCodePackageFolderPath,
                            TestUtility.ImageStoreDefaultTimeout,
                            CopyFlag.AtomicCopy,
                            false);
                    }
                    finally
                    {
                        if (Directory.Exists(tempDirectory))
                        {
                            Directory.Delete(tempDirectory, true);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public string CreateDiffBuildLayout(string[] includedComponentVersions)
        {
            string tempDirectory = Path.Combine(TestDirectory, "FabricUnitTests", Guid.NewGuid().ToString());

            try
            {
                Directory.CreateDirectory(tempDirectory);

                BuildLayoutSpecification tempBuildLayoutSpec = BuildLayoutSpecification.Create();
                tempBuildLayoutSpec.SetRoot(tempDirectory);

                foreach (var serviceManifestType in this.ServiceManifestTypes)
                {
                    if (!ShouldIncludeVersion(includedComponentVersions, serviceManifestType.Name, serviceManifestType.Version))
                    {
                        continue;
                    }

                    if (serviceManifestType.CodePackage != null)
                    {
                        foreach (CodePackageType codePackage in serviceManifestType.CodePackage)
                        {
                            if (!ShouldIncludeVersion(includedComponentVersions, codePackage.Name, codePackage.Version))
                            {
                                continue;
                            }

                            string codeFolderName = tempBuildLayoutSpec.GetCodePackageFolder(
                                serviceManifestType.Name,
                                codePackage.Name);
                            string pathInCodeFolder = Path.Combine(codeFolderName, "Test Path");

                            Directory.CreateDirectory(codeFolderName);
                            Directory.CreateDirectory(pathInCodeFolder);

                            File.Copy(
                                Path.Combine(TestDirectory, "System.Fabric.Management.dll"),
                                Path.Combine(codeFolderName, string.Format("System.Fabric.Management.{0}.dll", serviceManifestType.Name)),
                                true);

                            File.Copy(
                                Path.Combine(TestDirectory, "System.Fabric.Management.dll"),
                                Path.Combine(codeFolderName, "Setup.exe"),
                                true);

                            File.Copy(
                                Path.Combine(TestDirectory, "System.Fabric.Management.dll"),
                                Path.Combine(pathInCodeFolder, "TestLib.exe"),
                                true);
                        }
                    }

                    if (serviceManifestType.ConfigPackage != null)
                    {
                        foreach (ConfigPackageType configPackage in serviceManifestType.ConfigPackage)
                        {
                            if (!ShouldIncludeVersion(includedComponentVersions, configPackage.Name, configPackage.Version))
                            {
                                continue;
                            }

                            string configFolderName = tempBuildLayoutSpec.GetConfigPackageFolder(
                                serviceManifestType.Name,
                                configPackage.Name);

                            Directory.CreateDirectory(configFolderName);

                            if (this.SettingsType != null)
                            {
                                string settingsFileName = tempBuildLayoutSpec.GetSettingsFile(configFolderName);
                                TestUtility.WriteXml <SettingsType>(settingsFileName, this.SettingsType);
                            }
                            else
                            {
                                File.Copy(
                                    Path.Combine(TestDirectory, "System.Fabric.Management.dll"),
                                    Path.Combine(configFolderName, "MyConfig.xml"),
                                    true);
                            }
                        }
                    }

                    if (serviceManifestType.DataPackage != null)
                    {
                        foreach (DataPackageType dataPackage in serviceManifestType.DataPackage)
                        {
                            if (!ShouldIncludeVersion(includedComponentVersions, dataPackage.Name, dataPackage.Version))
                            {
                                continue;
                            }

                            string dataFolderName = tempBuildLayoutSpec.GetDataPackageFolder(
                                serviceManifestType.Name,
                                dataPackage.Name);

                            Directory.CreateDirectory(dataFolderName);

                            File.Copy(
                                Path.Combine(TestDirectory, "System.Fabric.Management.dll"),
                                Path.Combine(dataFolderName, "MyData.exe"),
                                true);
                        }
                    }

                    string serviceManifestFilePath  = tempBuildLayoutSpec.GetServiceManifestFile(serviceManifestType.Name);
                    string serviceManifestDirectory = Path.GetDirectoryName(serviceManifestFilePath);
                    if (!Directory.Exists(serviceManifestDirectory))
                    {
                        Directory.CreateDirectory(serviceManifestDirectory);
                    }

                    TestUtility.WriteXml <ServiceManifestType>(
                        tempBuildLayoutSpec.GetServiceManifestFile(serviceManifestType.Name),
                        serviceManifestType);
                }

                string appManifestFilePath  = tempBuildLayoutSpec.GetApplicationManifestFile();
                string appManifestDirectory = Path.GetDirectoryName(appManifestFilePath);
                if (!Directory.Exists(appManifestDirectory))
                {
                    Directory.CreateDirectory(appManifestDirectory);
                }

                TestUtility.WriteXml <ApplicationManifestType>(
                    tempBuildLayoutSpec.GetApplicationManifestFile(),
                    this.ApplicationManifestType);

                this.ImageStore.DeleteContent(this.ApplicationFolderName, TimeSpan.MaxValue);
                this.ImageStore.UploadContent(this.ApplicationFolderName, tempDirectory, TimeSpan.MaxValue, CopyFlag.AtomicCopy, false);
            }
            finally
            {
                if (Directory.Exists(tempDirectory))
                {
                    Directory.Delete(tempDirectory, true);
                }
            }

            return(this.ApplicationFolderName);
        }