Esempio n. 1
0
        protected override void ProcessRecord()
        {
            try
            {
                TraceConfig.SetDefaultLevel(TraceSinkType.Console, EventLevel.Error);
                var newClusterManifest = this.ReadXml <ClusterManifestType>(this.GetAbsolutePath(this.ClusterManifestPath), this.GetFabricFilePath(Constants.ServiceModelSchemaFileName));
                if (newClusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureWindowsServer)
                {
                    if (string.IsNullOrEmpty(this.OldClusterManifestPath))
                    {
                        var parameters = new Dictionary <string, dynamic>
                        {
                            { DeploymentParameters.ClusterManifestString, this.GetAbsolutePath(this.ClusterManifestPath) }
                        };

                        var deploymentParameters = new DeploymentParameters();
                        deploymentParameters.SetParameters(parameters, DeploymentOperations.ValidateClusterManifest);
                        DeploymentOperation.ExecuteOperation(deploymentParameters);
                        this.WriteObject(true);
                    }
                    else
                    {
                        var upgradeValidationParameters = new Dictionary <string, dynamic>
                        {
                            { DeploymentParameters.OldClusterManifestString, this.GetAbsolutePath(this.OldClusterManifestPath) },
                            { DeploymentParameters.ClusterManifestString, this.GetAbsolutePath(this.ClusterManifestPath) }
                        };

                        var upgradeDeploymentParameters = new DeploymentParameters();
                        upgradeDeploymentParameters.SetParameters(upgradeValidationParameters, DeploymentOperations.Validate);
                        try
                        {
                            DeploymentOperation.ExecuteOperation(upgradeDeploymentParameters);
                        }
                        catch (Exception exception)
                        {
                            if (exception is FabricHostRestartRequiredException || exception is FabricHostRestartNotRequiredException)
                            {
                                this.WriteObject(true);
                                return;
                            }

                            throw;
                        }
                    }
                }
                else
                {
                    throw new InvalidOperationException(StringResources.Error_NonServerClusterManifestValidationNotSupport);
                }
            }
            catch (Exception exception)
            {
                this.WriteObject(false);
                this.ThrowTerminatingError(
                    exception,
                    Constants.TestClusterManifestErrorId,
                    null);
            }
        }
Esempio n. 2
0
        static DeployerTrace()
        {
#if DotNetCoreClrLinux
            // TODO - Following code will be removed once fully transitioned to structured traces in Linux
            // this is used to read the configuration which tells whether to use structured traces in Linux.
            TraceConfig.InitializeFromConfigStore();
#endif
            traceSource = FabricEvents.ExtensionsEvents.GetEventSource(FabricEvents.Tasks.FabricDeployer);
            TraceConfig.SetDefaultLevel(TraceSinkType.Console, EventLevel.Error);
            TraceConfig.SetDefaultLevel(TraceSinkType.ETW, EventLevel.Informational);
        }
Esempio n. 3
0
        public static void UpdateFileLocation(string traceFolder)
        {
            string drive = Path.GetPathRoot(traceFolder);

#if DotNetCoreClrLinux
            string traceFileName = string.Format(CultureInfo.InvariantCulture, "FabricDeployer-{0}.trace", DateTime.UtcNow.Ticks);
            if (!FabricDirectory.Exists(traceFolder))
            {
                WriteInfo("Trace folder doesn't exist. Creating trace folder: {0}", traceFolder);
                FabricDirectory.CreateDirectory(traceFolder);
            }
#else
            if (!Directory.Exists(drive))
            {
                string newTraceFolder = Path.Combine(Path.GetTempPath(), "FabricDeployerTraces");
                WriteInfo("Default trace destination does not exist: {0}. Using directory instead: {1}.", traceFolder, newTraceFolder);
                traceFolder = newTraceFolder;
            }

            string traceFileName = string.Format(CultureInfo.InvariantCulture, "FabricDeployer-{0}.trace", DateTime.Now.Ticks);
            if (!Directory.Exists(traceFolder))
            {
                WriteInfo("Trace folder doesn't exist. Creating trace folder: {0}", traceFolder);
                Directory.CreateDirectory(traceFolder);
            }
#endif
            else
            {
                WriteInfo("Trace folder already exists. Traces will be written to existing trace folder: {0}", traceFolder);
            }


            string traceFileFullPath = Path.Combine(traceFolder, traceFileName);

#if DotNetCoreClr
            /* TBD: Fix following code.
             * if (deployerFileTraces != null)
             * {
             *  deployerFileTraces.Dispose();
             * }
             * deployerFileTraces = new FileEventListener(traceFileFullPath);
             * deployerFileTraces.EnableEvents(FabricEvents.Events, EventLevel.Informational);
             */
#else
            TraceTextFileSink.SetPath(traceFileFullPath);
            TraceConfig.SetDefaultLevel(TraceSinkType.TextFile, EventLevel.Informational);
#endif
        }
Esempio n. 4
0
        private static void EvaluateWriteMethodTest(WriteMethodTestCase testCase)
        {
            var traceSource = new FabricEvents.ExtensionsEvents(TestTask);

            TraceConfig.SetDefaultLevel(TraceSinkType.TextFile, EventLevel.Verbose);
            Directory.CreateDirectory(TraceFolder);
            var traceFile = Path.Combine(TraceFolder, testCase.Description + ".trace");

            TraceTextFileSink.SetPath(string.Empty);
            TraceTextFileSink.SetPath(traceFile);

            testCase.TraceAction(traceSource);
            TraceTextFileSink.SetPath(string.Empty);
            var output = File.ReadAllText(traceFile);

            Assert.IsTrue(!string.IsNullOrWhiteSpace(testCase.Predicate), "Predicate must be set.");
            Assert.IsTrue(
                Regex.IsMatch(output, testCase.Predicate),
                string.Format("Actual text \"{0}\" should match predicate {1}", output, testCase.Predicate));
        }
Esempio n. 5
0
        public static void UpdateFileLocation(string traceFolder)
        {
            string traceFileName = string.Format(CultureInfo.InvariantCulture, "{0}-{1}.trace", SFDeployerTrace.TraceType, DateTime.Now.Ticks);

            if (!Directory.Exists(traceFolder))
            {
                WriteInfo("Trace folder doesn't exist. Creating trace folder: {0}", traceFolder);
                Directory.CreateDirectory(traceFolder);
            }
            else
            {
                WriteInfo("Trace folder already exists. Traces will be written to existing trace folder: {0}", traceFolder);
            }

            string traceFileFullPath = Path.Combine(traceFolder, traceFileName);

            TraceTextFileSink.SetPath(traceFileFullPath);
            TraceConfig.SetDefaultLevel(TraceSinkType.TextFile, EventLevel.Verbose);
            LastTraceDirectory = traceFolder;
        }
Esempio n. 6
0
 public static void UpdateConsoleLevel(EventLevel level)
 {
     TraceConfig.SetDefaultLevel(TraceSinkType.Console, level);
 }
Esempio n. 7
0
 public void TestInitialize()
 {
     TraceConfig.InitializeFromConfigStore(testReader);
     TraceConfig.SetDefaultLevel(TraceSinkType.ETW, EventLevel.Informational);
 }
Esempio n. 8
0
 static SFDeployerTrace()
 {
     SFDeployerTrace.TraceSource = FabricEvents.ExtensionsEvents.GetEventSource(FabricEvents.Tasks.SystemFabricDeployer);
     TraceConfig.SetDefaultLevel(TraceSinkType.Console, EventLevel.Error);
     TraceConfig.AddFilter(TraceSinkType.Console, "SystemFabricDeployer:4");
 }