public void EC_WinFormsTest_WMED0004() { using (var fs = new LocalFileSystem(null)) using (var mb = new Metabank(fs, null, TestSources.RPATH)) using (var session = BootConfLoader.LoadForTest(SystemApplicationType.TestRig, mb, TestSources.THIS_HOST)) { var host = mb.CatalogReg.NavigateHost(WMED0004); var conf = host.GetEffectiveAppConfig("WinFormsTest"); Aver.AreEqual("WinFormsTest on HOST1", conf.Navigate("/$application-name").Value); Aver.AreEqual("Nikulin", conf.Navigate("/$clown").Value); Aver.AreEqual("A", conf.Navigate("/gv/$a").Value); Aver.AreEqual("B", conf.Navigate("/gv/$b").Value); Aver.IsNull(conf.Navigate("/glue/$zoloto").Value); Aver.AreEqual("da", conf.Navigate("/glue/$serebro").Value); Aver.AreEqual(123, conf.Navigate("/east-block/$something").ValueAsInt()); Aver.IsTrue(conf.Navigate("/cleveland/$solon").ValueAsBool()); Aver.IsFalse(conf.Navigate("/cleveland/$hudson").ValueAsBool()); Aver.IsFalse(conf.Navigate("/windows7/$build").Exists); } }
public void EC_Various_Parallel() { using (var fs = new LocalFileSystem(null)) using (var mb = new Metabank(fs, null, TestSources.RPATH)) using (var session = BootConfLoader.LoadForTest(SystemApplicationType.TestRig, mb, TestSources.THIS_HOST)) { Parallel.For(0, TestSources.PARALLEL_LOOP_TO, (i) => { Thread.SpinWait(ExternalRandomGenerator.Instance.NextScaledRandomInteger(10, 2000)); var host = mb.CatalogReg.NavigateHost(WMED0004); var conf = host.GetEffectiveAppConfig("WebApp1"); Aver.AreEqual("WebApp1", conf.Navigate("/$application-name").Value); Aver.AreEqual("A", conf.Navigate("/gv/$a").Value); Aver.AreEqual("B", conf.Navigate("/gv/$b").Value); Aver.AreEqual("da", conf.Navigate("/glue/$zoloto").Value); Aver.AreEqual("da", conf.Navigate("/glue/$serebro").Value); Aver.AreEqual(123, conf.Navigate("/east-block/$something").ValueAsInt()); Aver.AreEqual(true, conf.Navigate("/cleveland/$solon").ValueAsBool()); Aver.AreEqual(true, conf.Navigate("/cleveland/$hudson").ValueAsBool()); Aver.IsFalse(conf.Navigate("/windows7/$build").Exists); //-------------------------------------------- Thread.SpinWait(ExternalRandomGenerator.Instance.NextScaledRandomInteger(10, 2000)); host = mb.CatalogReg.NavigateHost(WMED0002); conf = host.GetEffectiveAppConfig("WebApp"); Aver.AreEqual("1.2.0890b", conf.Navigate("/windows7/$build").Value); //-------------------------------------------- Thread.SpinWait(ExternalRandomGenerator.Instance.NextScaledRandomInteger(10, 2000)); host = mb.CatalogReg.NavigateHost(WMED0004); conf = host.GetEffectiveAppConfig("WinFormsTest"); Aver.AreEqual("WinFormsTest on HOST1", conf.Navigate("/$application-name").Value); Aver.AreEqual("A", conf.Navigate("/gv/$a").Value); Aver.AreEqual("B", conf.Navigate("/gv/$b").Value); Aver.IsNull(conf.Navigate("/glue/$zoloto").Value); Aver.AreEqual("da", conf.Navigate("/glue/$serebro").Value); Aver.AreEqual(123, conf.Navigate("/east-block/$something").ValueAsInt()); Aver.AreEqual(true, conf.Navigate("/cleveland/$solon").ValueAsBool()); Aver.AreEqual(false, conf.Navigate("/cleveland/$hudson").ValueAsBool()); Aver.IsFalse(conf.Navigate("/windows7/$build").Exists); }); } }
public void EC_Server_fail() { using (var fs = new LocalFileSystem(null)) using (var mb = new Metabank(fs, null, TestSources.RPATH)) using (var session = BootConfLoader.LoadForTest(SystemApplicationType.TestRig, mb, TestSources.THIS_HOST)) { var host = mb.CatalogReg.NavigateHost(WMED0002); var conf = host.GetEffectiveAppConfig("TestApp"); } }
void IRunnableHook.Prologue(Runner runner, FID id) { Console.WriteLine("{0}.{1}".Args(GetType().FullName, "RigSetup()...")); m_FS = new LocalFileSystem(null); m_Metabank = new Metabank(m_FS, null, TestSources.RPATH); m_TestSession = BootConfLoader.LoadForTest(SystemApplicationType.TestRig, m_Metabank, TestSources.THIS_HOST); DoRigSetup(); Console.WriteLine("{0}.{1}".Args(GetType().FullName, "...RigSetup() DONE")); }
public void EC_Server_success() { using (var fs = new LocalFileSystem(null)) using (var mb = new Metabank(fs, null, TestSources.RPATH)) using (var session = BootConfLoader.LoadForTest(SystemApplicationType.TestRig, mb, TestSources.THIS_HOST)) { var host = mb.CatalogReg.NavigateHost(WMED0003); var conf = host.GetEffectiveAppConfig("AZGov"); Aver.IsFalse(conf.Navigate("/windows7/$build").Exists); } }
public void MI_Test() { using (var fs = new LocalFileSystem(null)) using (var mb = new Metabank(fs, null, TestSources.RPATH)) using (var session = BootConfLoader.LoadForTest(SystemApplicationType.TestRig, mb, TestSources.THIS_HOST)) { var host = mb.CatalogReg.NavigateHost(WMED0004); var conf = host.GetEffectiveAppConfig("WebApp1"); Aver.AreEqual("value", conf.Navigate("/$var").Value); } }
//20150403 DKh added support for include pragmas private ConfigSectionNode calculateEffectiveAppConfig(string appName) { var pragmasDisabled = Metabank.RootConfig.AttrByName(Metabank.CONFIG_APP_CONFIG_INCLUDE_PRAGMAS_DISABLED_ATTR).ValueAsBool(false); var includePragma = Metabank.RootConfig.AttrByName(Metabank.CONFIG_APP_CONFIG_INCLUDE_PRAGMA_ATTR).Value; var conf = new MemoryConfiguration(); conf.CreateFromNode(Metabank.RootAppConfig); var result = conf.Root; if (!pragmasDisabled) { BootConfLoader.ProcessAllExistingIncludes(result, includePragma, "root"); } var derivation = new List <configLevel>(); #region build derivation chain -------------------------------------------------------------------------- //Role level var role = this.Role; if (!role.AppNames.Any(an => INVSTRCMP.Equals(an, appName))) { throw new MetabaseException(StringConsts.METABASE_HOST_ROLE_APP_MISMATCH_ERROR.Args(appName, RoleName)); } derivation.Add(new configLevel(role, role.AnyAppConfig)); //App level var app = Metabank.CatalogApp.Applications[appName]; if (app == null) { throw new MetabaseException(StringConsts.METABASE_BAD_HOST_APP_ERROR.Args(appName)); } derivation.Add(new configLevel(app, app.AnyAppConfig)); //Regional level var parents = this.ParentSectionsOnPath; foreach (var item in parents) { derivation.Add(new configLevel(item, item.AnyAppConfig)); derivation.Add(new configLevel(item, item.GetAppConfig(appName))); } //This Level derivation.Add(new configLevel(this, this.AnyAppConfig)); derivation.Add(new configLevel(this, this.GetAppConfig(appName))); #endregion foreach (var clevel in derivation.Where(cl => cl.Node != null)) { if (!pragmasDisabled) { BootConfLoader.ProcessAllExistingIncludes((ConfigSectionNode)clevel.Node, includePragma, clevel.From.ToString()); } try { result.OverrideBy(clevel.Node); } catch (Exception error) { throw new MetabaseException(StringConsts.METABASE_EFFECTIVE_APP_CONFIG_OVERRIDE_ERROR.Args(clevel.From.ToString(), error.ToMessageWithType()), error); } } //OS Include var include = result[CONFIG_OS_APP_CONFIG_INCLUDE_SECTION]; if (include.Exists) { var osInclude = Metabank.GetOSConfNode(this.OS)[CONFIG_APP_CONFIG_SECTION] as ConfigSectionNode; if (osInclude.Exists) { include.Configuration.Include(include, osInclude); } } result.ResetModified(); return(result); }
static void run(string[] args) { using (var app = new ServiceBaseApplication(args, null)) { var silent = app.CommandArgs["s", "silent"].Exists; if (!silent) { ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Welcome.txt")); ConsoleUtils.Info("Build information:"); Console.WriteLine(" NFX: " + BuildInformation.ForFramework); Console.WriteLine(" Agni: " + new BuildInformation(typeof(Agni.AgniSystem).Assembly)); Console.WriteLine(" Tool: " + new BuildInformation(typeof(amm.ProgramBody).Assembly)); } if (app.CommandArgs["?", "h", "help"].Exists) { ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Help.txt")); return; } var mbPath = app.CommandArgs .AttrByIndex(0) .ValueAsString(System.Environment.GetEnvironmentVariable(BootConfLoader.ENV_VAR_METABASE_FS_ROOT)); if (!Directory.Exists(mbPath)) { throw new Exception("Specified metabase path not found"); } var fromHost = app.CommandArgs["host", "from"].AttrByIndex(0).Value; if (fromHost.IsNullOrWhiteSpace()) { fromHost = System.Environment.GetEnvironmentVariable(BootConfLoader.ENV_VAR_HOST_NAME); } if (!silent) { ConsoleUtils.Info("Metabase path: " + mbPath); ConsoleUtils.Info("Host (this machine): " + fromHost); } var w = System.Diagnostics.Stopwatch.StartNew(); using (var fs = new LocalFileSystem("amm")) using (var mb = new Metabank(fs, new FileSystemSessionConnectParams(), mbPath)) { using (BootConfLoader.LoadForTest(SystemApplicationType.Tool, mb, fromHost)) { if (app.CommandArgs["gbm"].Exists) { generateManifests(mb, silent); } else { validate(mb, silent); } } } if (!silent) { Console.WriteLine(); ConsoleUtils.Info("Run time: " + w.Elapsed.ToString()); } }//using APP }