예제 #1
0
        static void CheckPluginsStatus(this IYodiiEngineStaticOnlyResult @this, SolvedConfigurationStatus status, string pluginOrServiceNames, bool expectedIsPartial)
        {
            string[] expected      = pluginOrServiceNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var      withTheStatus = @this.StaticSolvedConfiguration.Plugins.Where(p => p.FinalConfigSolvedStatus == status).Select(p => p.PluginInfo.PluginFullName);

            TestExtensions.CheckContainsWithAlternative(expected, withTheStatus, expectedIsPartial);
        }
예제 #2
0
 public static void Trace(this IYodiiEngineStaticOnlyResult @this, IActivityMonitor m)
 {
     if (@this.Success)
     {
         m.Trace().Send("Success!");
     }
     else
     {
         m.Trace().Send("Failed!");
         @this.StaticFailureResult.Trace(m);
     }
 }
예제 #3
0
        internal static Tuple <IYodiiEngineStaticOnlyResult, ConfigurationSolver> CreateAndApplyStaticResolution(YodiiEngine engine, FinalConfiguration finalConfiguration, IDiscoveredInfo discoveredInfo, bool revertServices, bool revertPlugins, bool createStaticSolvedConfigOnSuccess)
        {
            ConfigurationSolver          temporarySolver = new ConfigurationSolver(engine, revertServices, revertPlugins);
            IYodiiEngineStaticOnlyResult result          = temporarySolver.StaticResolution(finalConfiguration, discoveredInfo, createStaticSolvedConfigOnSuccess);

            // StaticResolution returns null on success.
            // If there is a result, it is either an error or createStaticSolvedConfigOnSuccess is true and this is a StaticResolutionOnly: in both
            // case we do not need to keep the temporary solver.
            if (result != null)
            {
                temporarySolver = null;
            }
            return(Tuple.Create(result, temporarySolver));
        }
예제 #4
0
 public static void CheckPluginsRunning(this IYodiiEngineStaticOnlyResult @this, string pluginOrServiceNames)
 {
     CheckPluginsStatus(@this, SolvedConfigurationStatus.Running, pluginOrServiceNames, true);
 }
예제 #5
0
 public static void CheckAllPluginsDisabled(this IYodiiEngineStaticOnlyResult @this, string pluginOrServiceNames)
 {
     CheckPluginsStatus(@this, SolvedConfigurationStatus.Disabled, pluginOrServiceNames, false);
 }
예제 #6
0
 public static void CheckAllRunnable(this IYodiiEngineStaticOnlyResult @this, string pluginOrServiceNames)
 {
     CheckStatus(@this, SolvedConfigurationStatus.Runnable, pluginOrServiceNames, false);
 }
예제 #7
0
        public static void FullStaticResolutionOnly(this YodiiEngine @this, Action <IYodiiEngineStaticOnlyResult> tests, [CallerMemberName] string callerName = null)
        {
            IActivityMonitor m = TestHelper.ConsoleMonitor;

            IYodiiEngineStaticOnlyResult[] result = new IYodiiEngineStaticOnlyResult[4];

            using (m.OpenInfo().Send("FullStaticResolutionOnly for {0}.", callerName))
            {
                using (m.OpenInfo().Send("StaticResolutionOnly()."))
                {
                    result[0] = @this.StaticResolutionOnly(false, false);
                    result[0].Trace(m);
                }
                using (m.OpenInfo().Send("StaticResolutionOnly( revertServices )."))
                {
                    result[1] = @this.StaticResolutionOnly(true, false);
                    result[1].Trace(m);
                }
                using (m.OpenInfo().Send("StaticResolutionOnly( revertPlugins )."))
                {
                    result[2] = @this.StaticResolutionOnly(false, true);
                    result[2].Trace(m);
                }
                using (m.OpenInfo().Send("StaticResolutionOnly( revertServices, revertPlugins )."))
                {
                    result[3] = @this.StaticResolutionOnly(true, true);
                    result[3].Trace(m);
                }
                int comparingErrorCount   = 0;
                int comparingWarningCount = 0;
                using (m.CatchCounter((f, e, w) => { comparingErrorCount = f + e; comparingWarningCount = w; }))
                    using (m.OpenInfo().Send("Comparing results."))
                    {
                        if (result[0].Success)
                        {
                            if (!result[1].Success)
                            {
                                m.Error().Send("revertServices has failed.");
                            }
                            if (!result[2].Success)
                            {
                                m.Error().Send("revertPlugins has failed.");
                            }
                            if (!result[3].Success)
                            {
                                m.Error().Send("revertPlugins & revertServices has failed.");
                            }
                        }
                        else
                        {
                            var refItems = String.Join(", ", result[0].StaticFailureResult.BlockingItems.Select(i => i.FullName).OrderBy(Util.FuncIdentity));
                            if (result[1].Success)
                            {
                                m.Error().Send("revertServices succeeded.");
                            }
                            else
                            {
                                var items = String.Join(", ", result[1].StaticFailureResult.BlockingItems.Select(i => i.FullName).OrderBy(Util.FuncIdentity));
                                if (items != refItems)
                                {
                                    m.Warn().Send("revertServices found blocking items: '{1}' where default found: {0}.", refItems, items);
                                }
                            }
                            if (result[2].Success)
                            {
                                m.Error().Send("revertPlugins succeeded.");
                            }
                            else
                            {
                                var items = String.Join(", ", result[2].StaticFailureResult.BlockingItems.Select(i => i.FullName).OrderBy(Util.FuncIdentity));
                                if (items != refItems)
                                {
                                    m.Warn().Send("revertServices found blocking items: '{1}' where default found: {0}.", refItems, items);
                                }
                            }
                            if (result[3].Success)
                            {
                                m.Error().Send("revertPlugins & revertServices succeeded.");
                            }
                            else
                            {
                                var items = String.Join(", ", result[3].StaticFailureResult.BlockingItems.Select(i => i.FullName).OrderBy(Util.FuncIdentity));
                                if (items != refItems)
                                {
                                    m.Warn().Send("revertPlugins & revertServices found blocking items: '{1}' where default found: {0}.", refItems, items);
                                }
                            }
                        }
                    }
                using (m.OpenInfo().Send("Executing tests predicates."))
                {
                    tests(result[0]);
                    tests(result[1]);
                    tests(result[2]);
                    tests(result[3]);
                }
                if (comparingErrorCount == 0)
                {
                    if (comparingWarningCount == 0)
                    {
                        m.CloseGroup("No difference between plugin/service ordering.");
                    }
                    else
                    {
                        m.CloseGroup("Plugin/service ordering leads to different blocking detection. See logs for details.");
                    }
                }
                else
                {
                    Assert.Fail("Plugin/service ordering leads to different result! (See logs for details.)");
                }
            }
        }
예제 #8
0
        public static void FullStaticResolutionOnly( this YodiiEngine @this, Action<IYodiiEngineStaticOnlyResult> tests, [CallerMemberName]string callerName = null )
        {
            IActivityMonitor m = TestHelper.ConsoleMonitor;
            IYodiiEngineStaticOnlyResult[] result = new IYodiiEngineStaticOnlyResult[4];

            using( m.OpenInfo().Send( "FullStaticResolutionOnly for {0}.", callerName ) )
            {
                using( m.OpenInfo().Send( "StaticResolutionOnly()." ) )
                {
                    result[0] = @this.StaticResolutionOnly( false, false );
                    result[0].Trace( m );
                }
                using( m.OpenInfo().Send( "StaticResolutionOnly( revertServices )." ) )
                {
                    result[1] = @this.StaticResolutionOnly( true, false );
                    result[1].Trace( m );
                }
                using( m.OpenInfo().Send( "StaticResolutionOnly( revertPlugins )." ) )
                {
                    result[2] = @this.StaticResolutionOnly( false, true );
                    result[2].Trace( m );
                }
                using( m.OpenInfo().Send( "StaticResolutionOnly( revertServices, revertPlugins )." ) )
                {
                    result[3] = @this.StaticResolutionOnly( true, true );
                    result[3].Trace( m );
                }
                int comparingErrorCount = 0;
                int comparingWarningCount = 0;
                using( m.CatchCounter( ( f, e, w ) => { comparingErrorCount = f + e; comparingWarningCount = w; } ) )
                using( m.OpenInfo().Send( "Comparing results." ) )
                {
                    if( result[0].Success )
                    {
                        if( !result[1].Success ) m.Error().Send( "revertServices has failed." );
                        if( !result[2].Success ) m.Error().Send( "revertPlugins has failed." );
                        if( !result[3].Success ) m.Error().Send( "revertPlugins & revertServices has failed." );
                    }
                    else
                    {
                        var refItems = String.Join( ", ", result[0].StaticFailureResult.BlockingItems.Select( i => i.FullName ).OrderBy( Util.FuncIdentity ) );
                        if( result[1].Success ) m.Error().Send( "revertServices succeeded." );
                        else
                        {
                            var items = String.Join( ", ", result[1].StaticFailureResult.BlockingItems.Select( i => i.FullName ).OrderBy( Util.FuncIdentity ) );
                            if( items != refItems ) m.Warn().Send( "revertServices found blocking items: '{1}' where default found: {0}.", refItems, items );
                        }
                        if( result[2].Success ) m.Error().Send( "revertPlugins succeeded." );
                        else
                        {
                            var items = String.Join( ", ", result[2].StaticFailureResult.BlockingItems.Select( i => i.FullName ).OrderBy( Util.FuncIdentity ) );
                            if( items != refItems ) m.Warn().Send( "revertServices found blocking items: '{1}' where default found: {0}.", refItems, items );
                        }
                        if( result[3].Success ) m.Error().Send( "revertPlugins & revertServices succeeded." );
                        else
                        {
                            var items = String.Join( ", ", result[3].StaticFailureResult.BlockingItems.Select( i => i.FullName ).OrderBy( Util.FuncIdentity ) );
                            if( items != refItems ) m.Warn().Send( "revertPlugins & revertServices found blocking items: '{1}' where default found: {0}.", refItems, items );
                        }
                    }
                }
                using( m.OpenInfo().Send( "Executing tests predicates." ) )
                {
                    tests( result[0] );
                    tests( result[1] );
                    tests( result[2] );
                    tests( result[3] );
                }
                if( comparingErrorCount == 0 )
                {
                    if( comparingWarningCount == 0 )
                        m.CloseGroup( "No difference between plugin/service ordering." );
                    else m.CloseGroup( "Plugin/service ordering leads to different blocking detection. See logs for details." );
                }
                else
                {
                    Assert.Fail( "Plugin/service ordering leads to different result! (See logs for details.)" );
                }
            }
        }