예제 #1
0
        private void GenerateCodeDeployment()
        {
            if (!this.nodeSettings.DeploymentFoldersInfo.IsCodeDeploymentNeeded)
            {
                return;
            }

            foreach (string service in this.servicesToBeDeployed)
            {
                string destinationFolder = this.nodeSettings.DeploymentFoldersInfo.GetCodeDeploymentDirectory(service);
                string sourceFolder      = this.nodeSettings.DeploymentFoldersInfo.GetInstalledBinaryDirectory(service);
                if (IsCodeDeploymentNeeded(service, sourceFolder, destinationFolder))
                {
                    try
                    {
                        FabricDirectory.Copy(sourceFolder, destinationFolder, true);
                    }
                    catch (Exception e)
                    {
                        DeployerTrace.WriteError("Code deployment failed because: {0}. Source folder: {1}. destinationFolder: {2}", e, sourceFolder, destinationFolder);
                        throw;
                    }
                }
            }
        }
예제 #2
0
 private Task <bool> OnFullBackupCallback(BackupInfo backupInfo, CancellationToken cancellationToken)
 {
     Assert.IsFalse(cancellationToken.IsCancellationRequested);
     FullBackupFolderPath = Path.Combine(ClassTestPath, BackupContainerFolderName, Guid.NewGuid().ToString("N"));
     FabricDirectory.Copy(backupInfo.Directory, FullBackupFolderPath, false);
     return(Task.FromResult(true));
 }
        internal Task <bool> ComplexDataBackupCallbackAsync(Data.BackupInfo backupInfo, CancellationToken cancellationToken)
        {
            Assert.IsFalse(cancellationToken.IsCancellationRequested);
            var complexDataBackupFolderPath = Path.Combine(logFolder, "BackupContainer", Guid.NewGuid().ToString("N"));

            FabricDirectory.Copy(backupInfo.Directory, complexDataBackupFolderPath, false);
            return(Task.FromResult(true));
        }
예제 #4
0
 public void FabricDirectory_CopyNegative()
 {
     try
     {
         var src = Environment.ExpandEnvironmentVariables(@"%_NTTREE%\FabricDrop");
         LogHelper.Log("FabricDirectory.Copy from {0} to {1}", src, BadPath);
         FabricDirectory.Copy(src, BadPath, true);
         Assert.Fail("should never reach here");
     }
     catch (Exception e)
     {
         LogHelper.Log("caught exception {0}", e);
         Assert.IsTrue(e is IOException);
     }
 }
예제 #5
0
        public void TestApplicationPackage(string connectionEndpoint, string applicationPackagePath, string applicationParameter, string imageStoreConnectionString, string certThumbprint)
        {
            string[] parameters = applicationParameter.Split(',');
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            for (int i = 0; i < parameters.Length / 2; i += 2)
            {
                dictionary.Add(parameters[i], parameters[i + 1]);
            }

            var testRootPath = Path.Combine(Path.GetTempPath(), string.Format(CultureInfo.InvariantCulture, "{0}_{1}", "TestApplicationPackage", DateTime.Now.Ticks));

            try
            {
                var applicationName         = new DirectoryInfo(applicationPackagePath).Name;
                var testRootApplicationPath = Path.Combine(testRootPath, applicationName);
                FabricDirectory.Copy(applicationPackagePath, testRootApplicationPath, true);
                ImageBuilderUtility.RemoveReadOnlyFlag(testRootApplicationPath);

                var fileImageStoreConnectionString = string.Format(CultureInfo.InvariantCulture, "{0}{1}", "file:", testRootPath.TrimEnd(Path.DirectorySeparatorChar));
                var sourceImageStore = ImageStoreFactoryProxy.CreateImageStore(fileImageStoreConnectionString);

                IImageStore destinationImageStore = null;
                if (string.IsNullOrEmpty(imageStoreConnectionString))
                {
                    destinationImageStore = sourceImageStore;
                }
                else
                {
                    destinationImageStore = this.CreateImageStore(connectionEndpoint, imageStoreConnectionString, testRootPath, certThumbprint);
                }

                var imagebuilder = new ImageBuilder(sourceImageStore, destinationImageStore, this.GetFabricFilePath("ServiceFabricServiceModel.xsd"), testRootPath);

                imagebuilder.ValidateApplicationPackage(
                    applicationName,
                    dictionary);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                FabricDirectory.Delete(testRootPath, true, true);
            }
        }
        private string CopyPackageIfNeeded(string sourcePath, UploadProgressHandler progressHandler)
        {
            if (!string.IsNullOrEmpty(this.ApplicationPackageCopyPath))
            {
                var destPath = this.GetAbsolutePath(this.ApplicationPackageCopyPath);

                if (progressHandler != null)
                {
                    progressHandler.SetStateCopying(destPath);
                }

                FabricDirectory.Copy(sourcePath, destPath, true);

                if (progressHandler != null)
                {
                    progressHandler.UpdateApplicationPackagePath(destPath);
                }

                sourcePath = destPath;
            }

            return(sourcePath);
        }
예제 #7
0
        protected void TestSFApplicationPackage(string applicationPackagePath, Hashtable applicationParameters, string imageStoreConnectionString)
        {
            var testRootPath = Path.Combine(Path.GetTempPath(), string.Format(CultureInfo.InvariantCulture, "{0}_{1}", Constants.BaseTestRootFolderName, Stopwatch.GetTimestamp()));

            try
            {
                var absolutePath            = this.GetAbsolutePath(applicationPackagePath);
                var applicationName         = this.GetPackageName(absolutePath);
                var testRootApplicationPath = Path.Combine(testRootPath, applicationName);
                FabricDirectory.Copy(absolutePath, testRootApplicationPath, true);
                ImageBuilderUtility.RemoveReadOnlyFlag(testRootApplicationPath);

                var fileImageStoreConnectionString =
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "{0}{1}",
                        Constants.ImageStoreConnectionFileType,
                        testRootPath.TrimEnd(Path.DirectorySeparatorChar));
                var sourceImageStore = ImageStoreFactoryProxy.CreateImageStore(fileImageStoreConnectionString);

                IImageStore destinationImageStore = null;
                if (string.IsNullOrEmpty(imageStoreConnectionString))
                {
                    destinationImageStore = sourceImageStore;
                }
                else
                {
                    destinationImageStore = this.CreateImageStore(imageStoreConnectionString, testRootPath);
                }

                var imagebuilder = new ImageBuilder(
                    sourceImageStore,
                    destinationImageStore,
                    this.GetFabricFilePath(Constants.ServiceModelSchemaFileName),
                    testRootPath);

                // Set SFVolumeDiskServiceEnabled to true so that client side validation does the right thing
                // if corresponding UseServiceFabricReplicatedStore attribute is set.
                //
                // We always have a final validation at runtime to catch any issues.
                imagebuilder.IsSFVolumeDiskServiceEnabled = true;

                imagebuilder.ValidateApplicationPackage(
                    applicationName,
                    this.GetDictionary(applicationParameters));

                this.WriteObject(true);
            }
            catch (AggregateException exception)
            {
                exception.Handle((ae) =>
                {
                    this.WriteObject(false);
                    this.ThrowTerminatingError(
                        ae,
                        Constants.TestApplicationPackageErrorId,
                        null);
                    return(true);
                });
            }
            catch (Exception exception)
            {
                this.WriteObject(false);
                this.ThrowTerminatingError(
                    exception,
                    Constants.TestApplicationPackageErrorId,
                    null);
            }
            finally
            {
                FabricDirectory.Delete(testRootPath, true, true);
            }
        }