Esempio n. 1
0
        public void Execute()
        {
            var t = new LocalMsmqGrantReadWriteTask(_address, @"TEST\ReynoldsR");
            DeploymentResult r = t.Execute();

            Assert.IsFalse(r.ContainsError(), "Errors occured during permission setting.");
        }
Esempio n. 2
0
            public override void Because()
            {
                VerificationResult = Task.VerifyCanRun();
                System.Diagnostics.Debug.WriteLine(VerificationResult);
                if (VerificationResult.ContainsError()) return;

                ExecutionResult = Task.Execute();
                System.Diagnostics.Debug.WriteLine(ExecutionResult);
            }
Esempio n. 3
0
        public void TestRoundhousE()
        {
            var task = new RoundhousETask(".", "SQL2005", "TestRoundhousE", true,
                                          @"E:\external projects\kaithos\roundhouse\db\SQLServer\TestRoundhousE", "TEST",
                                          true);
            DeploymentResult results = task.Execute();

            Assert.IsFalse(results.ContainsError());
        }
Esempio n. 4
0
      public override DeploymentResult VerifyCanRun() {
         var result = new DeploymentResult();
         result.AddNote(_reason);

         if(_filesShouldExist.Count > 0) {
            var tmpDR = new DeploymentResult();
            foreach(var filePath in _filesShouldExist) {
               string actualPath = _path.GetFullPath(filePath);
               if(!File.Exists(actualPath)) { tmpDR.AddError("  File '{0}' should exist!.".FormatWith(actualPath)); }
            }
            result.MergedWith(tmpDR);
            //errors show up anyway, give some feedback if everything OK.
            if(!tmpDR.ContainsError()) { result.AddNote("  All {0} files found!".FormatWith(_filesShouldExist.Count)); }
         } else {
            result.AddNote("  No Files that should exist.");
         }

         if(_directoriesShouldExist.Count > 0) {
            var tmpDR = new DeploymentResult();
            foreach(var dirPath in _directoriesShouldExist) {
               string actualPath = _path.GetFullPath(dirPath);
               if(!Directory.Exists(actualPath)) { tmpDR.AddError("  Directory '{0}' should exist".FormatWith(actualPath)); }
            }
            result.MergedWith(tmpDR);
            //errors show up anyway, give some feedback if everything OK.
            if(!tmpDR.ContainsError()) { result.AddNote("  All {0} directories found!".FormatWith(_directoriesShouldExist.Count)); }
         } else {
            result.AddNote("  No Directories that should exist.");
         }

         if(_filesShould_NOT_Exist.Count > 0) {
            var tmpDR = new DeploymentResult();
            foreach(var filePath in _filesShould_NOT_Exist) {
               string actualPath = _path.GetFullPath(filePath);
               if(File.Exists(actualPath)) { tmpDR.AddError("  File '{0}' should NOT exist!.".FormatWith(actualPath)); }
            }
            result.MergedWith(tmpDR);
            if(!tmpDR.ContainsError()) { result.AddNote("  None of the {0} files exist!".FormatWith(_filesShould_NOT_Exist.Count)); }
         } else {
            result.AddNote("  No Files that should NOT exist.");
         }

         if(_directoriesShould_NOT_Exist.Count > 0) {
            var tmpDR = new DeploymentResult();
            foreach(var dirPath in _directoriesShould_NOT_Exist) {
               string actualPath = _path.GetFullPath(dirPath);
               if(Directory.Exists(actualPath)) { tmpDR.AddError("  Directory '{0}' should NOT exist".FormatWith(actualPath)); }
            }
            result.MergedWith(tmpDR);
            if(!tmpDR.ContainsError()) { result.AddNote("  None of the {0} directories exist!".FormatWith(_directoriesShould_NOT_Exist.Count)); }
         } else {
            result.AddNote("  No Directories that should NOT exist.");
         }

         if(_shouldAbortOnError && result.ContainsError()) { result.AddAbort(_reason); }
         return result;
      }
Esempio n. 5
0
        public void TestRoundhousE()
        {
            var connection = new DbConnectionInfo {
                Server       = "(local)",
                DatabaseName = "TestRoundhouse"
            };
            var task = new RoundhousETask(connection,
                                          @"C:\Solutions\roundhouse\code_drop\sample\db\SQLServer\TestRoundhousE", "TEST",
                                          RoundhousEMode.DropCreate, DatabaseRecoveryMode.Simple, string.Empty, 0, string.Empty, "git://somehwere", "", "", 0, 0, "", "", "", "", "", "", "", null, null);
            DeploymentResult results = task.Execute();

            System.Console.WriteLine(results);
            Assert.IsFalse(results.ContainsError());
        }
Esempio n. 6
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            _from = _path.GetFullPath(_from);
            _to = _path.GetFullPath(_to);

            ValidatePaths(result);
            if(!result.ContainsError()) {
                //don't report back 'good' on errors
                result.AddGood(Name);
            }

            return result;
        }
Esempio n. 7
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            _from = _path.GetFullPath(_from);
            _to = _path.GetFullPath(_to);

            ValidatePaths(result);
            if(!result.ContainsError()) {
                //don't continue on errors
                CopyFile(result, _newFileName, _from, _to);

                result.AddGood(Name);
            }
            return result;
        }
Esempio n. 8
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            _from = _path.GetFullPath(_from);
            _to   = _path.GetFullPath(_to);

            ValidatePaths(result);
            if (!result.ContainsError())
            {
                //don't report back 'good' on errors
                result.AddGood(Name);
            }

            return(result);
        }
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    Logging.Coarse("[svc] Stopping service '{0}'", ServiceName);
                    if (c.CanStop)
                    {
                        int pid = GetProcessId(ServiceName);

                        try
                        {
                            c.Stop();
                            c.WaitForStatus(ServiceControllerStatus.Stopped, _timeout);
                            LogCoarseGrain("[svc] Service stopped, waiting for process to exit...");
                            WaitForProcessToDie(result, pid);
                        }
                        catch (TimeoutException)
                        {
                            var error = string.Format("Service '{0}' did not finish stopping during the specified timeframe.", ServiceName);
                            result.AddError(error);
                            LogCoarseGrain(error);
                        }
                    }
                }

                if (!result.ContainsError())
                {
                    result.AddGood("Stopped Service '{0}'", ServiceName);
                    Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
                }
            }
            else
            {
                if (ErrorOnFailure)
                    result.AddError(string.Format("Service '{0}' does not exist and could not be stopped", ServiceName));
                else
                    result.AddAlert("Service '{0}' does not exist and could not be stopped", ServiceName);

                Logging.Coarse("[svc] Service '{0}' does not exist.", ServiceName);
            }

            return result;
        }
Esempio n. 10
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            _from = _path.GetFullPath(_from);
            _to   = _path.GetFullPath(_to);

            ValidatePaths(result);
            if (!result.ContainsError())
            {
                //don't continue on errors
                CopyFile(result, _newFileName, _from, _to);

                result.AddGood(Name);
            }
            return(result);
        }
Esempio n. 11
0
        public DeploymentResult Execute()
        {
            var deploymentResult = new DeploymentResult();

            try
            {
                Ex(detail =>
                {
                    if (!deploymentResult.ShouldAbort)
                    {
                        var verifyResult = detail.Verify();
                        deploymentResult.MergedWith(verifyResult);

                        if (verifyResult.ContainsError())
                        {
                            DisplayResults(verifyResult);
                        }
                        else
                        {
                            Logging.Coarse(LogLevel.Info, "[Run  ] {0}", detail.Name);
                            var executeResult = detail.Execute();
                            DisplayResults(executeResult);
                            deploymentResult.MergedWith(executeResult);
                        }

                        if (deploymentResult.ContainsError() && AbortOnError)
                        {
                            var message = "[Abort] Aborting due to previous error (since --abortOnError switch was specified).";
                            deploymentResult.AddAbort(message);
                            Logging.Coarse(LogLevel.Error, message);
                            throw new DeploymentAbortedException();
                        }
                    }
                    else
                    {
                        Logging.Coarse(LogLevel.Error, "[Skip ] {0}", detail.Name);
                    }
                });
            }
            catch (DeploymentAbortedException) { }

            return deploymentResult;
        }
Esempio n. 12
0
        private void UpdateXmlFile(DeploymentResult result, string filePath, IDictionary<string, string> replacementItems,IDictionary<string, string> insertItems, IEnumerable<string> removeItems, IDictionary<string, string> namespacePrefixes)
        {
            LogFileChange("[xmlpoke] Starting changes to '{0}'.", filePath);

            var document = new XmlDocument();
            document.Load(filePath);
            var nsManager = new XmlNamespaceManager(document.NameTable);

            foreach (var prefix in namespacePrefixes)
                nsManager.AddNamespace(prefix.Key, prefix.Value);

            XPathNavigator xpathNavigator = document.CreateNavigator();

            foreach (string item in removeItems.OrEmptyListIfNull())
                RemoveNodeInFile(result, xpathNavigator, item, nsManager);

            foreach (KeyValuePair<string, string> item in replacementItems.OrEmptyListIfNull())
                UpdateValueInFile(result, xpathNavigator, item.Key, item.Value, nsManager);

            foreach(KeyValuePair<string, string> item in insertItems.OrEmptyListIfNull())
               UpdateOrInsertValueInFile(result,document, xpathNavigator, item.Key, item.Value, nsManager);

            LogFileChange("[xmlpoke] Completed changes to '{0}'.",filePath);

            if (!result.ContainsError())
                document.Save(filePath);
        }
Esempio n. 13
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            _filePath = _path.GetFullPath(_filePath);
            ValidateIsFile(result, _filePath);

            UpdateXmlFile(result, _filePath, _replacementItems, _replaceOrInsertItems, _removeItems, _namespacePrefixes);

            if (result.ContainsError())
                result.AddError("Failed to " + Name);
            else
                result.AddGood(Name);

            return result;
        }
Esempio n. 14
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            result.AddNote(_reason);

            if (_filesShouldExist.Count > 0)
            {
                var tmpDR = new DeploymentResult();
                foreach (var filePath in _filesShouldExist)
                {
                    string actualPath = _path.GetFullPath(filePath);
                    if (!File.Exists(actualPath))
                    {
                        tmpDR.AddError("  File '{0}' should exist!.".FormatWith(actualPath));
                    }
                }
                result.MergedWith(tmpDR);
                //errors show up anyway, give some feedback if everything OK.
                if (!tmpDR.ContainsError())
                {
                    result.AddNote("  All {0} files found!".FormatWith(_filesShouldExist.Count));
                }
            }
            else
            {
                result.AddNote("  No Files that should exist.");
            }

            if (_directoriesShouldExist.Count > 0)
            {
                var tmpDR = new DeploymentResult();
                foreach (var dirPath in _directoriesShouldExist)
                {
                    string actualPath = _path.GetFullPath(dirPath);
                    if (!Directory.Exists(actualPath))
                    {
                        tmpDR.AddError("  Directory '{0}' should exist".FormatWith(actualPath));
                    }
                }
                result.MergedWith(tmpDR);
                //errors show up anyway, give some feedback if everything OK.
                if (!tmpDR.ContainsError())
                {
                    result.AddNote("  All {0} directories found!".FormatWith(_directoriesShouldExist.Count));
                }
            }
            else
            {
                result.AddNote("  No Directories that should exist.");
            }

            if (_filesShould_NOT_Exist.Count > 0)
            {
                var tmpDR = new DeploymentResult();
                foreach (var filePath in _filesShould_NOT_Exist)
                {
                    string actualPath = _path.GetFullPath(filePath);
                    if (File.Exists(actualPath))
                    {
                        tmpDR.AddError("  File '{0}' should NOT exist!.".FormatWith(actualPath));
                    }
                }
                result.MergedWith(tmpDR);
                if (!tmpDR.ContainsError())
                {
                    result.AddNote("  None of the {0} files exist!".FormatWith(_filesShould_NOT_Exist.Count));
                }
            }
            else
            {
                result.AddNote("  No Files that should NOT exist.");
            }

            if (_directoriesShould_NOT_Exist.Count > 0)
            {
                var tmpDR = new DeploymentResult();
                foreach (var dirPath in _directoriesShould_NOT_Exist)
                {
                    string actualPath = _path.GetFullPath(dirPath);
                    if (Directory.Exists(actualPath))
                    {
                        tmpDR.AddError("  Directory '{0}' should NOT exist".FormatWith(actualPath));
                    }
                }
                result.MergedWith(tmpDR);
                if (!tmpDR.ContainsError())
                {
                    result.AddNote("  None of the {0} directories exist!".FormatWith(_directoriesShould_NOT_Exist.Count));
                }
            }
            else
            {
                result.AddNote("  No Directories that should NOT exist.");
            }

            if (_shouldAbortOnError && result.ContainsError())
            {
                result.AddAbort(_reason);
            }
            return(result);
        }