static void Main(string[] args) { try { string szConfigurationFile = @"./config.XML"; TestConfiguration Config = new TestConfiguration (); // Save configuration file Console.WriteLine ("Writing configuration file"); Config.Save (szConfigurationFile); // Assign new values Console.WriteLine ("Reset values"); Config.MyFloat = 0.0f; Config.MyString =String.Empty; Config.MyInt = 64; // Reload default values Console.WriteLine ("Reload default configuration"); Config = TestConfiguration.Load (szConfigurationFile); } catch (Exception e) { Console.WriteLine ("ERROR"); Console.WriteLine (e.ToString ()); } Console.WriteLine ("Press Return to quit"); Console.ReadLine (); }
public void Act(string configurationDescription) { this.configuration = new TestConfiguration (configurationDescription); if (configuration.DTDA) { Thread thread = new Thread (new ThreadStart (this.RunTest)); thread.Start (); thread.Join (); } else { RunTest (); } }
public async Task<LoginAttempt> AuthenticateAsync(TestConfiguration configuration, string username, string password, IPAddress clientAddress = null, IPAddress serverAddress = null, string api = "web", string cookieProvidedByBrowser = null, DateTimeOffset? eventTime = null, CancellationToken cancellationToken = default(CancellationToken) ) { clientAddress = clientAddress ?? new IPAddress(new byte[] {42, 42, 42, 42}); serverAddress = serverAddress ?? new IPAddress(new byte[] {127, 1, 1, 1}); LoginAttempt attempt = new LoginAttempt { UsernameOrAccountId = username, AddressOfClientInitiatingRequest = clientAddress, AddressOfServerThatInitiallyReceivedLoginAttempt = serverAddress, TimeOfAttempt = eventTime ?? DateTimeOffset.Now, Api = api, CookieProvidedByBrowser = cookieProvidedByBrowser }; return await configuration.MyLoginAttemptClient.PutAsync(attempt, password, cancellationToken: cancellationToken); }
public static string[] CreateUserAccounts(TestConfiguration configuration, int numberOfAccounts) { string[] usernames = Enumerable.Range(1, numberOfAccounts).Select(x => "testuser" + x.ToString()).ToArray(); foreach (string username in usernames) LoginTestCreateAccount(configuration, username, "passwordfor" + username); return usernames; }
public RESTService(TestConfiguration config) { _testConfig = config; ServiceURI = _testConfig.ServiceURI; //ServicePort = TestConfig.ServicePort; AuthRequired = _testConfig.AuthRequired; AuthType = (AuthSchema)_testConfig.AuthType; Username = _testConfig.Username; Password = _testConfig.Password; AuthToken = _testConfig.AuthToken; IsConfigured = true; //IsOnline = true; // Now that the service is configured, create an http client that can talk to it... _client = new HttpClient(); // Is auth required? if (AuthRequired) { if (AuthType == AuthSchema.Basic) _client.TransportSettings.Credentials = new NetworkCredential(Username, Password); else if (AuthType == AuthSchema.Token) _client.DefaultHeaders.Authorization = new Credential(AuthToken); } }
public static UserAccount LoginTestCreateAccount(TestConfiguration configuration, string usernameOrAccountId, string password) { UserAccount account = UserAccount.Create(usernameOrAccountId, (int) configuration.CreditLimits.Last().Limit, password); configuration.MyUserAccountController.PutAsync(account.UsernameOrAccountId, account).Wait(); return account; }
/// <summary> /// Validate the configuration model /// </summary> /// <param name="configuration">Configuration instance</param> /// <returns>Instance of a test configuration</returns> private bool Validate(TestConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } bool returnValue = true; if (configuration.Settings == null) { listener.Error("Configuration.Validation", "Could not find `settings` in Testproject configuration"); returnValue = false; } else { if (string.IsNullOrWhiteSpace(configuration.Settings.Project)) { listener.Error("Configuration.Validation", "Could not find `project`-name in `settings`"); returnValue = false; } } if (configuration.TestCases == null || configuration.TestCases.Count == 0) { listener.Error("Configuration.Validation", "Could not find any `testCase` in Testproject configuration"); returnValue = false; } return returnValue; }
public async static Task<UserAccount> CreateTestAccountAsync(TestConfiguration configuration, string usernameOrAccountId, string password) { UserAccount account = UserAccount.Create(usernameOrAccountId, (int) configuration.CreditLimits.Last().Limit, password, numberOfIterationsToUseForPhase1Hash: 1); await configuration.MyUserAccountController.PutAsync(account.UsernameOrAccountId, account); return account; }
public void load(string configFile) { // Console.WriteLine(now() + ": Reading configuration from " + configFile); XmlTextReader reader = new XmlTextReader(configFile); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: { switch (reader.Name) { case "General": { DROPDIR = reader.GetAttribute("DROPDIR"); REGRESSIONDIR = reader.GetAttribute("REGRESSIONDIR"); TIMEOUT = Convert.ToDouble(reader.GetAttribute("TIMEOUT")); MEMOUT = Convert.ToUInt32(reader.GetAttribute("MEMOUT")); } break; case "Developer": { Developers.Add(reader.GetAttribute("name")); break; } case "Directory": { DirTypePair np = new DirTypePair(); np.dir = reader.GetAttribute("name"); np.type = reader.GetAttribute("type"); if (np.type == "") np.type = "smt2"; Directories.Add(np); break; } case "ExcludeDirectory": { ExcludeDirectories.Add(reader.GetAttribute("name")); break; } case "TestConfig": { TestConfiguration t = new TestConfiguration(); t.Read(reader); if (!testConfigs.ContainsKey(t.type)) testConfigs.Add(t.type, new List<TestConfiguration>()); testConfigs[t.type].Add(t); break; } default: /* nothing */ break; } break; } default: /* nothing */ break; } } }
public void BigFreakinAllocationTestLoop(TestConfiguration config, uint threadIndex, uint levelOfParallelism) { for (uint i = threadIndex; i < 512 * 1024; i += levelOfParallelism) { string username = "******" + i + BigString; System.Threading.Thread.Sleep(10); FunctionalTests.CreateTestAccountAsync(config, username, "passwordfor" + i); } }
TestConfiguration Create() { var cfg = new TestConfiguration() { Container = _container, WebServer = _webServer, WebDriver = _webDriver, }; return cfg; }
public static void FillGraph(IGraph<int> graph, TestConfiguration conf) { if (String.IsNullOrEmpty(conf.TestFile)) { GraphGenerator.FillGraph(graph, conf.Levels, conf.Descendants, conf.Precedents); return; } var sequencesToAdd = LoadSequencesFromFile(conf.TestFile); graph.AddSequences(sequencesToAdd); }
public static IUserAccount CreateTestAccount(TestConfiguration configuration, string usernameOrAccountId, string password, CancellationToken cancellationToken = default(CancellationToken)) { MemoryUserAccount account = configuration.MemUserAccountController.Create(usernameOrAccountId, password, 1); account.CreditLimit = configuration.MyBlockingAlgorithmOptions.AccountCreditLimit; account.CreditHalfLife = configuration.MyBlockingAlgorithmOptions.AccountCreditLimitHalfLife; configuration.MyAccountFactory.Add(account); return account; }
public static String toATML(CASS_MTPSI tpsi) { StringWriter tw = new StringWriter(); TestConfiguration testConfig = new TestConfiguration(); ManufacturerData configManager = testConfig.ConfigurationManager; List<CASS_MTPSICASS_MTPSI_page> pages = tpsi.CASS_MTPSI_page; foreach( CASS_MTPSICASS_MTPSI_page page in pages ) { CASS_MTPSICASS_MTPSI_pageUUT uut = page.UUT; String partNo = uut.UUT_ID.Part_Number; //UUTInstance instance = new UUTInstance(); UUTDescription item = new UUTDescription(); //item.Item.name = uut.UUT_ID.Part_Number; //Lookup UUT Information ItemDescriptionReference reference = new ItemDescriptionReference(); DocumentReference docRef = new DocumentReference(); //docRef.ID = uut.UUT_ID.Part_Number; docRef.uuid = "{SOMEUUIDHERE}"; reference.Item = docRef;// item.Item; //testConfig.TestedUUTs.Add(reference); TestConfigurationTestEquipmentItem testEquipment = new TestConfigurationTestEquipmentItem(); foreach( CASS_MTPSICASS_MTPSI_pageATE_assets asset in page.ATE_assets ) { ItemDescriptionReference refEquip = new ItemDescriptionReference(); ItemDescription instrument = new ItemDescription(); instrument.name = asset.Asset_Identifier; refEquip.Item = instrument; //testEquipment.Instrumentation.Add(refEquip); } // testConfig.TestEquipment.Add(testEquipment); try { XmlSerializer serializerObj = new XmlSerializer(typeof(TestConfiguration)); serializerObj.Serialize(tw, testConfig); } catch( Exception e ) { Exception ie = e.InnerException; while( ie != null ) { Trace.WriteLine(ie.Message); ie = ie.InnerException; } } break; } return tw.ToString(); }
public FeedBuilderTests() { _config = new TestConfiguration(); _builder = new FeedBuilder(_config); _config.Title = "Rosanna"; _config.Url = "http://example.com"; _config.Author = "Author"; _feed = _builder.GetFeed(new ArticleRepository(_config, new PathResolver(_config)).GetArticles()); }
public static string[] CreateUserAccounts(TestConfiguration configuration, int numberOfAccounts) { string[] usernames = Enumerable.Range(1, numberOfAccounts).Select(x => "testuser" + x.ToString()).ToArray(); //foreach (string username in usernames) // CreateTestAccountAsync(configuration, username, "passwordfor" + username).Wait(); Parallel.ForEach(usernames, async (username) => await CreateTestAccountAsync(configuration, username, "passwordfor" + username) ); return usernames; }
/// <summary> /// Given a test configuration this returns true if the configuration should be skipped as per these limits. /// </summary> /// <param name="testConfiguration">The test configuration to check.</param> /// <returns>true if the configuration is not allowed by these limits (and thus should be skipped).</returns> public bool SkipTestConfiguration(TestConfiguration testConfiguration) { if (this.disallowRequest && testConfiguration.IsRequest) { return true; } if (this.disallowResponse && !testConfiguration.IsRequest) { return true; } return this.SkipVersion(testConfiguration.Version); }
public void MissingSettingsHaveDefaultValue() { // Arrange var configSettings = new ConfigSettings(); configSettings.RegisterConfigType(new PartialConfig()); var config = new TestConfiguration(configSettings); // Act config.Load(); // Assert config.Item2.Should().BeNull("there was no AppConfig value to load"); config.Item3.Should().Be(0, "there was no AppConfig value to load"); }
public void when_statsd_port_is_different_then_it_is_included_in_the_difference_summary() { var first = new TestConfiguration { StatsdPort = 0 }; var second = new TestConfiguration { StatsdPort = 5 }; var summary = new ConfigurationDifferenceSummary(first, second); Assert.That(summary.ToString(), Is.EqualTo("StatsdPort: '0' → '5'\r\n")); }
public void when_statsd_host_is_different_then_it_is_included_in_the_difference_summary() { var first = new TestConfiguration { StatsdHost = "first.host" }; var second = new TestConfiguration { StatsdHost = "second.host" }; var summary = new ConfigurationDifferenceSummary(first, second); Assert.That(summary.ToString(), Is.EqualTo("StatsdHost: 'first.host' → 'second.host'\r\n")); }
public void when_metric_prefix_is_different_then_it_is_included_in_the_difference_summary() { var first = new TestConfiguration { MetricPrefix = "first.metric.prefix" }; var second = new TestConfiguration { MetricPrefix = "second.metric.prefix" }; var summary = new ConfigurationDifferenceSummary(first, second); Assert.That(summary.ToString(), Is.EqualTo("MetricPrefix: 'first.metric.prefix' → 'second.metric.prefix'\r\n")); }
public void when_interval_is_different_then_it_is_included_in_the_difference_summary() { var first = new TestConfiguration { Interval = TimeSpan.Zero }; var second = new TestConfiguration { Interval = TimeSpan.FromMinutes(5) }; var summary = new ConfigurationDifferenceSummary(first, second); Assert.That(summary.ToString(), Is.EqualTo("Interval: '00:00:00' → '00:05:00'\r\n")); }
public virtual void LaunchApplication() { try { keyboard = Keyboard.Instance; testConfiguration = testMode.GetConfiguration(CommandLineArguments, this); application = testConfiguration.Launch(); BaseTestFixtureSetup(); TestFixtureSetUp(); } catch (Exception e) { WhiteLogger.Instance.Error(e); TextFixtureTearDown(); throw; } }
public string RunTestRemotelyAsString(string hostName, string testName) { TestConfiguration testConfiguration = new TestConfiguration(testName, hostName); string url = string.Format(@"http://{0}/?sc_test={1}", hostName, testName); string results = string.Empty; using (WebClient client = new WebClient()) { if (testConfiguration.IsPostBack) { results = RunTestRemotelyAsPost(client, testConfiguration, url + "&method=post"); } else { results = RunTestRemotelyAsGet(client, testConfiguration, url + "&method=get"); } } return results; }
/// <summary> /// Create test-process by a jsonConfiguration /// </summary> /// <param name="jsonConfiguration">Configuration of the current adaptive test.</param> /// <param name="listener">Error-Listener</param> /// <param name="autoPlugInDetection">If set to true, the system will look for plugins in the current AppDomain</param> public TestProcess(string jsonConfiguration, IListener listener, bool autoPlugInDetection = true) { this.listener = listener; plugInManager = new PlugIns.PlugInManager(listener); // Load module definitions if autoPlugInDetection is enabled if (autoPlugInDetection) { plugInManager.LoadPlugIns(); } configuration = JsonConvert.DeserializeObject<TestConfiguration>(jsonConfiguration); // Validate configuration errorsOccured = !Validate(configuration); testCollection = new TestCollection(); testReport = new TestReport(this, configuration.Settings.Output); }
public static TestConfiguration InitTest(BlockingAlgorithmOptions options = default(BlockingAlgorithmOptions)) { if (options == null) options = new BlockingAlgorithmOptions(); TestConfiguration configuration = new TestConfiguration(); configuration.MyBlockingAlgorithmOptions = options ?? new BlockingAlgorithmOptions(); //configuration.MyResponsibleHosts = new MaxWeightHashing<RemoteHost>("FIXME-uniquekeyfromconfig"); //RemoteHost localHost = new RemoteHost { Uri = new Uri("http://localhost:80") }; //configuration.MyResponsibleHosts.Add("localhost", localHost); //IStableStore stableStore = configuration.StableStore = new MemoryOnlyStableStore(); //configuration.MyLoginAttemptClient = new LoginAttemptClient(configuration.MyResponsibleHosts, localHost); MemoryUsageLimiter memoryUsageLimiter = new MemoryUsageLimiter(); BinomialLadderFilter localPasswordBinomialLadderFilter = new BinomialLadderFilter(options.NumberOfBitsInBinomialLadderFilter_N, options.HeightOfBinomialLadder_H); //MultiperiodFrequencyTracker<string> localPasswordFrequencyTracker = // new MultiperiodFrequencyTracker<string>( // options.NumberOfPopularityMeasurementPeriods, // options.LengthOfShortestPopularityMeasurementPeriod, // options.FactorOfGrowthBetweenPopularityMeasurementPeriods); configuration.MyAccountFactory = new MemoryOnlyUserAccountFactory(); configuration.MemUserAccountController = new MemoryUserAccountController(); LoginAttemptController<MemoryUserAccount> myLoginAttemptController = new LoginAttemptController<MemoryUserAccount>( new MemoryUserAccountControllerFactory(), configuration.MyAccountFactory, localPasswordBinomialLadderFilter, memoryUsageLimiter, configuration.MyBlockingAlgorithmOptions); configuration.MyLoginAttemptClient = myLoginAttemptController; //configuration.MyLoginAttemptClient.SetLocalLoginAttemptController(myLoginAttemptController); return configuration; }
public void RunTest(TestConfiguration testConfig) { string assemblyPath = string.Format(@"{0}\{1}.dll", HttpContext.Current.Server.MapPath("~/bin"), testConfig.Assembly); Assembly dll = Assembly.LoadFrom(assemblyPath); Type type = dll.GetType(testConfig.Class); object o = Activator.CreateInstance(type); SetupTest(testConfig, type, o); if (typeof(System.Web.UI.Control).IsAssignableFrom(type)) { SetupTestControl(testConfig, type, o as System.Web.UI.Control); RunTestEvents(testConfig, type, o); } else if (typeof(System.Web.UI.Page).IsAssignableFrom(type)) { SetupTestPage(testConfig, type, o as System.Web.UI.Page); RunTestEvents(testConfig, type, o); } RunTestMethod(testConfig, type, o); }
public static TestConfiguration InitTest(BlockingAlgorithmOptions options = default(BlockingAlgorithmOptions)) { TestConfiguration configuration = new TestConfiguration(); if (options == null) options = new BlockingAlgorithmOptions(); configuration.CreditLimits = new[] { // 3 per hour new LimitPerTimePeriod(new TimeSpan(1, 0, 0), 3f), // 6 per day (24 hours, not calendar day) new LimitPerTimePeriod(new TimeSpan(1, 0, 0, 0), 6f), // 10 per week new LimitPerTimePeriod(new TimeSpan(6, 0, 0, 0), 10f), // 15 per month new LimitPerTimePeriod(new TimeSpan(30, 0, 0, 0), 15f) }; configuration.MyResponsibleHosts = new MaxWeightHashing<RemoteHost>("FIXME-uniquekeyfromconfig"); RemoteHost localHost = new RemoteHost { Uri = new Uri("http://localhost:80") }; configuration.MyResponsibleHosts.Add("localhost", localHost); IStableStore stableStore = configuration.StableStore = new MemoryOnlyStableStore(); configuration.MyUserAccountClient = new UserAccountClient(configuration.MyResponsibleHosts, localHost); configuration.MyLoginAttemptClient = new LoginAttemptClient(configuration.MyResponsibleHosts, localHost); MemoryUsageLimiter memoryUsageLimiter = new MemoryUsageLimiter(); configuration.MyUserAccountController = new UserAccountController(configuration.MyUserAccountClient, configuration.MyLoginAttemptClient, memoryUsageLimiter, options, stableStore, configuration.CreditLimits); LoginAttemptController myLoginAttemptController = new LoginAttemptController(configuration.MyLoginAttemptClient, configuration.MyUserAccountClient, memoryUsageLimiter, options, stableStore); configuration.MyUserAccountController.SetLoginAttemptClient(configuration.MyLoginAttemptClient); configuration.MyUserAccountClient.SetLocalUserAccountController(configuration.MyUserAccountController); myLoginAttemptController.SetUserAccountClient(configuration.MyUserAccountClient); configuration.MyLoginAttemptClient.SetLocalLoginAttemptController(myLoginAttemptController); return configuration; }
/// <summary> /// Default constructor /// </summary> /// <param name="parameters">Dictionary with parameter values</param> public TestManager(Dictionary<string, string> parameters) { //System.Diagnostics.Debugger.Launch(); loggerParameters = parameters; // validate is we've the needed params if (String.IsNullOrEmpty(GetParameter("PnPSQLConnectionString")) || String.IsNullOrEmpty(GetParameter("PnPConfigurationToTest"))) { throw new ArgumentException("Requested parameters (PnPSQLConnectionString and PnPConfigurationToTest) are not defined"); } // we pass the connection string as base64 encoded + replaced "=" with " to avoid problems with the default implementation of the VSTestLogger interface context = new TestModelContainer(Base64Decode(GetParameter("PnPSQLConnectionString")).Replace(""", "\"")); // find the used configuration string configurationToTest = GetParameter("PnPConfigurationToTest"); testConfiguration = context.TestConfigurationSet.Where(s => s.Name.Equals(configurationToTest, StringComparison.InvariantCultureIgnoreCase)).First(); if (testConfiguration == null) { throw new Exception(String.Format("Test configuration with name {0} was not found", configurationToTest)); } }
bool CSCompile(FileInfo fi, TestConfiguration tc, ref Result res) { string dll = tc.absolute_dir + @"\" + tc.bindir + @"\" + tc.bin; string driver = fi.DirectoryName + @"\" + tc.driver; StringWriter out_writer = new StringWriter(); StringWriter err_writer = new StringWriter(); Process compiler = new Process(); compiler.StartInfo.FileName = tc.executor; compiler.StartInfo.Arguments = tc.executor_args + " /Reference:" + dll + " /OUT:" + tc.absolute_dir + @"\" + tc.bindir + @"\cstest.exe" + " " + driver + " " + fi.FullName; compiler.OutputDataReceived += (sender, args) => out_writer.WriteLine(args.Data); compiler.ErrorDataReceived += (sender, args) => err_writer.WriteLine(args.Data); compiler.StartInfo.RedirectStandardOutput = true; compiler.StartInfo.RedirectStandardError = true; compiler.StartInfo.CreateNoWindow = true; compiler.StartInfo.UseShellExecute = false; compiler.Start(); compiler.BeginOutputReadLine(); compiler.BeginErrorReadLine(); compiler.WaitForExit(); int rv = compiler.ExitCode; compiler.Close(); Thread.Sleep(10); // Give the asynch stdout/stderr events a chance to finish. out_writer.Flush(); err_writer.Flush(); if (rv != 0) { res.stdout += out_writer.ToString(); res.stderr += err_writer.ToString(); return false; } return true; }
static void Main(string[] args) { //var config = new TestConfiguration(SelectionMode.Attribute, Configuration.DefaultStatCollectors.Append("TestStatCollector")); var config = new TestConfiguration(SelectionMode.All, Configuration.DefaultStatCollectors.Append("TestStatCollector")); //var autoStat1 = new AutoStat<Host>(config); var autoStat1 = new AutoStat <Host>(keyName: "id"); //var autoStat2 = new AutoStat<Host>(config); var autoStat2 = new AutoStat <Host>(keyName: "id"); Random random = new Random(); int recordCount = 1_000_000; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < recordCount; i++) { Host record = new Host() { Name = "Wyatt" + i.ToString().PadLeft(6, '0'), SerialNumber = i, Id = i, Uptime = TimeSpan.FromMinutes(i), PokerMoney = new decimal(0.01) * new decimal(i), DeathCount = recordCount - (i / (recordCount - i)), Awareness = Awareness.NotAlive, Escaped = random.Next(0, 2) == 1 }; autoStat1.Collect(record); } Console.WriteLine(stopwatch.Elapsed); //return; var recordStats1 = autoStat1.GetStats(); Console.Write(recordStats1.ToTextFormat()); //recordStats = recordStats.Where(stat => stat.MemberName == "SerialNumber").ToRecordStats(); Console.Write(recordStats1.ToTextTableFormat(Console.WindowWidth)); //recordStats1.OpenCsvInPowershell("stats.csv"); for (int i = 0; i < recordCount; i++) { Host record = new Host() { Name = "Wyatt" + i.ToString().PadLeft(6, '0'), SerialNumber = i + recordCount, Id = i, Uptime = TimeSpan.FromMinutes(i), PokerMoney = new decimal(0.02) * new decimal(i), DeathCount = recordCount - (i / (recordCount - i)), Awareness = random.Next(0, 2) == 1 ? Awareness.NotAlive : Awareness.Alive, Escaped = true }; autoStat2.Collect(record); } var recordStats2 = autoStat2.GetStats(); Console.Write(recordStats2.ToTextFormat()); Console.Write(recordStats2.ToTextTableFormat(Console.WindowWidth)); //recordStats1.OpenCsvInPowershell("stats.csv"); var recordStats3 = autoStat1.GetStatsComparedTo(autoStat2) .HighlightWhen(stat => stat.DiffPct >= .30); Console.Write(recordStats3.ToTextFormat()); Console.Write(recordStats3.ToTextTableFormat(Console.WindowWidth)); //recordStats1.OpenCsvInPowershell("stats.csv"); Console.ReadKey(); }
public PFMPings(TestConfiguration config) : base(config) { }
public SimpleInstrumentationTest(TestConfiguration config, ClientAndServerFactory factory) : base(config, factory) { }
public async Task LineNums(TestConfiguration config) { await RunTest(config, "LineNums", "LineNums.script", testTriage : true); }
/// <summary> /// Run a debuggee and create a dump. /// </summary> /// <param name="config">test configuration</param> /// <param name="output">output instance</param> /// <param name="testName">name of test</param> /// <param name="debuggeeName">debuggee name</param> /// <param name="debuggeeArguments">optional args to pass to debuggee</param> /// <param name="useCreateDump">if true, use "createdump" to generate core dump</param> public static async Task CreateDump(TestConfiguration config, ITestOutputHelper output, string testName, string debuggeeName, string debuggeeArguments = null, bool useCreateDump = true) { Directory.CreateDirectory(config.DebuggeeDumpOutputRootDir()); if (!config.CreateDumpExists || !useCreateDump || config.GenerateDumpWithLLDB() || config.GenerateDumpWithGDB()) { using (SOSRunner runner = await SOSRunner.StartDebugger(config, output, testName, debuggeeName, debuggeeArguments, Options.GenerateDump)) { try { await runner.LoadSosExtension(); string command = null; switch (runner.Debugger) { case SOSRunner.NativeDebugger.Cdb: await runner.ContinueExecution(); // On desktop create triage dump. On .NET Core, create full dump. command = config.IsDesktop ? ".dump /o /mshuRp %DUMP_NAME%" : ".dump /o /ma %DUMP_NAME%"; break; case SOSRunner.NativeDebugger.Gdb: command = "generate-core-file %DUMP_NAME%"; break; case SOSRunner.NativeDebugger.Lldb: await runner.ContinueExecution(); command = "sos CreateDump %DUMP_NAME%"; break; default: throw new Exception(runner.Debugger.ToString() + " does not support creating dumps"); } await runner.RunCommand(command); await runner.QuitDebugger(); } catch (Exception ex) { runner.WriteLine(ex.ToString()); throw; } } } else { TestRunner.OutputHelper outputHelper = null; try { // Setup the logging from the options in the config file outputHelper = TestRunner.ConfigureLogging(config, output, testName); // Restore and build the debuggee. The debuggee name is lower cased because the // source directory name has been lowercased by the build system. DebuggeeConfiguration debuggeeConfig = await DebuggeeCompiler.Execute(config, debuggeeName, outputHelper); outputHelper.WriteLine("Starting {0}", testName); outputHelper.WriteLine("{"); // Get the full debuggee launch command line (includes the host if required) string exePath = debuggeeConfig.BinaryExePath; var arguments = new StringBuilder(); if (!string.IsNullOrWhiteSpace(config.HostExe)) { exePath = config.HostExe; if (!string.IsNullOrWhiteSpace(config.HostArgs)) { arguments.Append(config.HostArgs); arguments.Append(" "); } arguments.Append(debuggeeConfig.BinaryExePath); } if (!string.IsNullOrWhiteSpace(debuggeeArguments)) { arguments.Append(" "); arguments.Append(debuggeeArguments); } // Run the debuggee with the createdump environment variables set to generate a coredump on unhandled exception var testLogger = new TestRunner.TestLogger(outputHelper.IndentedOutput); var variables = GenerateVariables(config, debuggeeConfig, Options.GenerateDump); ProcessRunner processRunner = new ProcessRunner(exePath, ReplaceVariables(variables, arguments.ToString())). WithLog(testLogger). WithTimeout(TimeSpan.FromMinutes(5)). WithEnvironmentVariable("COMPlus_DbgEnableMiniDump", "1"). WithEnvironmentVariable("COMPlus_DbgMiniDumpName", ReplaceVariables(variables, "%DUMP_NAME%")); processRunner.Start(); // Wait for the debuggee to finish await processRunner.WaitForExit(); } catch (Exception ex) { // Log the exception outputHelper?.WriteLine(ex.ToString()); throw; } finally { outputHelper?.WriteLine("}"); outputHelper?.Dispose(); } } }
/// <summary> /// Generates a function which normalizes the given payload element and all of its descendants. /// </summary> /// <param name="testConfiguration">Test configuration to apply during normalization.</param> /// <returns>A function which normalizes the ATOM metadata of a payload element and returns the modified payload element.</returns> public static Func <ODataPayloadElement, ODataPayloadElement> GenerateNormalizer(TestConfiguration testConfiguration) { return(new Func <ODataPayloadElement, ODataPayloadElement>(payloadElement => { new ODataPayloadElementAtomMetadataNormalizer(testConfiguration).Recurse(payloadElement); return payloadElement; })); }
public static string GetMsSqlConnectionString() { TestConfiguration config = ConfigurationHelper.GetTestConfiguration(); return($"Data Source={config.MsSqlServer},{config.MsSqlPort};User Id={config.MsSqlUsername};Password={config.MsSqlPassword};"); }
public void Setup() { _cluster = new Cluster(TestConfiguration.GetDefaultConfiguration()); _cluster.SetupEnhancedAuth(); _bucket = _cluster.OpenBucket("default"); }
protected override void Configure(Configuration configuration) { TestConfiguration.Configure(configuration); }
public virtual void TextFixtureTearDown() { BaseTestFixtureTearDown(); application = null; testConfiguration = null; }
protected virtual string GetConfigArg(TestConfiguration config) { return(string.Format("-c {0}", QuoteArg(config.ToString()))); }
public void GetUserSecrets() { _config = Hooks.GetUserSecrets(); }
/// <summary> /// Creates a new ATOM metadata normalizer. /// </summary> /// <param name="testConfiguration">Test configuration to apply during normalization.</param> public ODataPayloadElementAtomMetadataNormalizer(TestConfiguration testConfiguration) { this.testConfiguration = testConfiguration; }
public override void SetUp() { var noIndexTablePrefix = typeof(GlobalSecondaryIndexTests).Name + Guid.NewGuid(); var oneIndexTablePrefix = typeof(GlobalSecondaryIndexTests).Name + Guid.NewGuid(); var twoIndexTablePrefix = typeof(GlobalSecondaryIndexTests).Name + Guid.NewGuid(); this.ClearFlags(); TestConfiguration.GetDataContext(noIndexTablePrefix).CreateTableIfNotExists ( new CreateTableArgs <GameScores> ( // hash key score => score.UserId, // range key score => score.GameTitle, // initial values GameScoresQueries.GetInitialRecords ) ); TestConfiguration.GetDataContext(oneIndexTablePrefix).CreateTableIfNotExists ( new CreateTableArgs <GameScores> ( // hash key score => score.UserId, // range key score => score.GameTitle, // local secondary indexes, null, // global secondary indexes, new GlobalSecondaryIndexDefinitions <GameScores> ( score => new GlobalSecondaryIndexDefinition { HashKeyField = score.GameTitle, RangeKeyField = score.TopScore } ), // initial values GameScoresQueries.GetInitialRecords ) ); TestConfiguration.GetDataContext(twoIndexTablePrefix).CreateTableIfNotExists ( new CreateTableArgs <GameScores> ( // hash key score => score.UserId, // range key score => score.GameTitle, // local secondary indexes, null, // global secondary indexes, new GlobalSecondaryIndexDefinitions <GameScores> ( score => new GlobalSecondaryIndexDefinition { HashKeyField = score.GameTitle, RangeKeyField = score.TopScore }, score => new GlobalSecondaryIndexDefinition { HashKeyField = score.Wins } ), // initial values GameScoresQueries.GetInitialRecords ) ); this.NoIndexContext = TestConfiguration.GetDataContext(noIndexTablePrefix); this.OneIndexContext = TestConfiguration.GetDataContext(oneIndexTablePrefix); this.TwoIndexContext = TestConfiguration.GetDataContext(twoIndexTablePrefix); this.NoIndexContext.OnLog += this.Context_OnLog; this.OneIndexContext.OnLog += this.Context_OnLog; this.TwoIndexContext.OnLog += this.Context_OnLog; this.NoIndexThreadTable = this.NoIndexContext.GetTable <GameScores>(); this.OneIndexThreadTable = this.OneIndexContext.GetTable <GameScores>(); this.TwoIndexThreadTable = this.TwoIndexContext.GetTable <GameScores>(); }
public async Task LLDBPluginTests(TestConfiguration config) { if (OS.Kind == OSKind.Windows || config.IsDesktop || config.RuntimeFrameworkVersionMajor == 1 || SOSRunner.IsAlpine()) { throw new SkipTestException("lldb plugin tests not supported on Windows, Alpine Linux or .NET Core 1.1"); } string testName = "SOS." + nameof(LLDBPluginTests); TestRunner.OutputHelper outputHelper = null; try { // Setup the logging from the options in the config file outputHelper = TestRunner.ConfigureLogging(config, Output, testName); outputHelper.WriteLine("Starting {0}", testName); outputHelper.WriteLine("{"); string program = "/usr/bin/python"; if (!File.Exists(program)) { throw new ArgumentException($"{program} does not exists"); } var arguments = new StringBuilder(); string repoRootDir = TestConfiguration.MakeCanonicalPath(config.AllSettings["RepoRootDir"]); // Get test python script path string scriptDir = Path.Combine(repoRootDir, "src", "SOS", "lldbplugin.tests"); arguments.Append(Path.Combine(scriptDir, "test_libsosplugin.py")); arguments.Append(" "); // Get lldb path arguments.AppendFormat("--lldb {0} ", Environment.GetEnvironmentVariable("LLDB_PATH") ?? throw new ArgumentException("LLDB_PATH environment variable not set")); // Add dotnet host program and arguments arguments.Append("--host \""); arguments.Append(config.HostExe); arguments.Append(" "); if (!string.IsNullOrWhiteSpace(config.HostArgs)) { arguments.Append(config.HostArgs); arguments.Append(" "); } arguments.Append("\" "); // Add lldb plugin path arguments.AppendFormat("--plugin {0} ", config.SOSPath() ?? throw new ArgumentException("SOSPath config not set")); // Add log directory string logFileDir = Path.Combine(config.LogDirPath, config.RuntimeFrameworkVersion); Directory.CreateDirectory(logFileDir); arguments.AppendFormat("--logfiledir {0} ", logFileDir); // Add test debuggee assembly string testDebuggee = Path.Combine(repoRootDir, "artifacts", "bin", "TestDebuggee", config.TargetConfiguration, config.BuildProjectFramework, "TestDebuggee.dll"); arguments.AppendFormat("--assembly {0}", testDebuggee); // Create the python script process runner ProcessRunner processRunner = new ProcessRunner(program, arguments.ToString()). WithEnvironmentVariable("DOTNET_ROOT", config.DotNetRoot()). WithLog(new TestRunner.TestLogger(outputHelper.IndentedOutput)). WithTimeout(TimeSpan.FromMinutes(10)). WithExpectedExitCode(0). WithWorkingDirectory(scriptDir). // Turn on stress logging so the dumplog and histinit commands pass WithEnvironmentVariable("COMPlus_LogFacility", "0xffffffbf"). WithEnvironmentVariable("COMPlus_LogLevel", "6"). WithEnvironmentVariable("COMPlus_StressLog", "1"). WithEnvironmentVariable("COMPlus_StressLogSize", "65536"); // Start the process runner processRunner.Start(); // Wait for the debuggee to finish await processRunner.WaitForExit(); } catch (Exception ex) { // Log the exception outputHelper?.WriteLine(ex.ToString()); throw; } finally { outputHelper?.WriteLine("}"); outputHelper?.Dispose(); } }
public static string DebuggeeDumpOutputRootDir(this TestConfiguration config) { return(TestConfiguration.MakeCanonicalPath(config.GetValue("DebuggeeDumpOutputRootDir"))); }
/// <summary> /// Start a debuggee under a native debugger returning a sos runner instance. /// </summary> /// <param name="config">test configuration</param> /// <param name="output">output instance</param> /// <param name="testName">name of test</param> /// <param name="debuggeeName">debuggee name</param> /// <param name="debuggeeArguments">optional args to pass to debuggee</param> /// <param name="options">dump options</param> /// <returns>sos runner instance</returns> public static async Task <SOSRunner> StartDebugger(TestConfiguration config, ITestOutputHelper output, string testName, string debuggeeName, string debuggeeArguments = null, Options options = Options.None) { TestRunner.OutputHelper outputHelper = null; SOSRunner sosRunner = null; // Figure out which native debugger to use NativeDebugger debugger = GetNativeDebuggerToUse(config, options); try { // Setup the logging from the options in the config file outputHelper = TestRunner.ConfigureLogging(config, output, testName); // Restore and build the debuggee. DebuggeeConfiguration debuggeeConfig = await DebuggeeCompiler.Execute(config, debuggeeName, outputHelper); outputHelper.WriteLine("SOSRunner processing {0}", testName); outputHelper.WriteLine("{"); var variables = GenerateVariables(config, debuggeeConfig, options); var scriptLogger = new ScriptLogger(debugger, outputHelper.IndentedOutput); if (options == Options.LoadDump || options == Options.LoadDumpWithDotNetDump) { if (!variables.TryGetValue("%DUMP_NAME%", out string dumpName) || !File.Exists(dumpName)) { throw new FileNotFoundException($"Dump file does not exist: {dumpName ?? ""}"); } } // Get the full debuggee launch command line (includes the host if required) var debuggeeCommandLine = new StringBuilder(); if (!string.IsNullOrWhiteSpace(config.HostExe)) { debuggeeCommandLine.Append(config.HostExe); debuggeeCommandLine.Append(" "); if (!string.IsNullOrWhiteSpace(config.HostArgs)) { debuggeeCommandLine.Append(config.HostArgs); debuggeeCommandLine.Append(" "); } } debuggeeCommandLine.Append(debuggeeConfig.BinaryExePath); if (!string.IsNullOrWhiteSpace(debuggeeArguments)) { debuggeeCommandLine.Append(" "); debuggeeCommandLine.Append(debuggeeArguments); } // Get the native debugger path string debuggerPath = GetNativeDebuggerPath(debugger, config); if (string.IsNullOrWhiteSpace(debuggerPath) || !File.Exists(debuggerPath)) { throw new FileNotFoundException($"Native debugger path not set or does not exist: {debuggerPath}"); } // Get the debugger arguments and commands to run initially List <string> initialCommands = new List <string>(); var arguments = new StringBuilder(); switch (debugger) { case NativeDebugger.Cdb: string helperExtension = config.CDBHelperExtension(); if (string.IsNullOrWhiteSpace(helperExtension) || !File.Exists(helperExtension)) { throw new ArgumentException($"CDB helper script path not set or does not exist: {helperExtension}"); } arguments.AppendFormat(@"-c "".load {0}""", helperExtension); if (options == Options.LoadDump) { arguments.Append(" -z %DUMP_NAME%"); } else { arguments.AppendFormat(" -Gsins {0}", debuggeeCommandLine); // disable stopping on integer divide-by-zero and integer overflow exceptions initialCommands.Add("sxd dz"); initialCommands.Add("sxd iov"); } initialCommands.Add(".sympath %DEBUG_ROOT%"); initialCommands.Add(".extpath " + Path.GetDirectoryName(config.SOSPath())); // Add the path to runtime so cdb/sos can find mscordbi. string runtimeSymbolsPath = config.RuntimeSymbolsPath; if (runtimeSymbolsPath != null) { initialCommands.Add(".sympath+ " + runtimeSymbolsPath); } // Turn off warnings that can happen in the middle of a command's output initialCommands.Add(".outmask- 4"); break; case NativeDebugger.Lldb: // Get the lldb python script file path necessary to capture the output of commands // by printing a prompt after all the command output is printed. string lldbHelperScript = config.LLDBHelperScript(); if (string.IsNullOrWhiteSpace(lldbHelperScript) || !File.Exists(lldbHelperScript)) { throw new ArgumentException("LLDB helper script path not set or does not exist: " + lldbHelperScript); } arguments.AppendFormat(@"--no-lldbinit -o ""settings set interpreter.prompt-on-quit false"" -o ""command script import {0}"" -o ""version""", lldbHelperScript); // Load the dump or launch the debuggee process if (options == Options.LoadDump) { initialCommands.Add($@"target create --core ""%DUMP_NAME%"" ""{config.HostExe}"""); } else { var sb = new StringBuilder("settings set -- target.run-args"); if (!string.IsNullOrWhiteSpace(config.HostArgs)) { string[] args = ReplaceVariables(variables, config.HostArgs).Trim().Split(' '); foreach (string arg in args) { sb.AppendFormat(@" ""{0}""", arg); } } sb.AppendFormat(@" ""{0}""", debuggeeConfig.BinaryExePath); if (!string.IsNullOrWhiteSpace(debuggeeArguments)) { string[] args = ReplaceVariables(variables, debuggeeArguments).Trim().Split(' '); foreach (string arg in args) { sb.AppendFormat(@" ""{0}""", arg); } } initialCommands.Add($@"target create ""{config.HostExe}"""); initialCommands.Add(sb.ToString()); initialCommands.Add("process launch -s"); // .NET Core 1.1 or less don't catch stack overflow and abort so need to catch SIGSEGV if (config.StackOverflowSIGSEGV) { initialCommands.Add("process handle -s true -n true -p true SIGSEGV"); } else { initialCommands.Add("process handle -s false -n false -p true SIGSEGV"); } initialCommands.Add("process handle -s false -n false -p true SIGFPE"); initialCommands.Add("process handle -s true -n true -p true SIGABRT"); } break; case NativeDebugger.Gdb: if (options == Options.LoadDump || options == Options.LoadDumpWithDotNetDump) { throw new ArgumentException("GDB not meant for loading core dumps"); } arguments.AppendFormat("--args {0}", debuggeeCommandLine); // .NET Core 1.1 or less don't catch stack overflow and abort so need to catch SIGSEGV if (config.StackOverflowSIGSEGV) { initialCommands.Add("handle SIGSEGV stop print"); } else { initialCommands.Add("handle SIGSEGV nostop noprint"); } initialCommands.Add("handle SIGFPE nostop noprint"); initialCommands.Add("handle SIGABRT stop print"); initialCommands.Add("set startup-with-shell off"); initialCommands.Add("set use-coredump-filter on"); initialCommands.Add("run"); break; case NativeDebugger.DotNetDump: if (options != Options.LoadDumpWithDotNetDump) { throw new ArgumentException($"{options} not supported for dotnet-dump testing"); } if (string.IsNullOrWhiteSpace(config.HostExe)) { throw new ArgumentException("No HostExe in configuration"); } arguments.Append(debuggerPath); arguments.Append(@" analyze %DUMP_NAME%"); debuggerPath = config.HostExe; break; } // Create the native debugger process running ProcessRunner processRunner = new ProcessRunner(debuggerPath, ReplaceVariables(variables, arguments.ToString())). WithLog(scriptLogger). WithTimeout(TimeSpan.FromMinutes(10)); // Create the sos runner instance sosRunner = new SOSRunner(debugger, config, outputHelper, variables, scriptLogger, processRunner, options == Options.LoadDump || options == Options.LoadDumpWithDotNetDump); // Start the native debugger processRunner.Start(); // Set the coredump_filter flags on the gdb process so the coredump it // takes of the target process contains everything the tests need. if (debugger == NativeDebugger.Gdb) { initialCommands.Insert(0, string.Format("shell echo 0x3F > /proc/{0}/coredump_filter", processRunner.ProcessId)); } // Execute the initial debugger commands await sosRunner.RunCommands(initialCommands); return(sosRunner); } catch (Exception ex) { // Log the exception outputHelper?.WriteLine(ex.ToString()); // The runner needs to kill the process and dispose of the file logger sosRunner?.Dispose(); // The file logging output helper needs to be disposed to close the file outputHelper?.Dispose(); throw; } }
public async Task Reflection(TestConfiguration config) { await RunTest(config, "ReflectionTest", "Reflection.script", testTriage : true); }
public async Task StackTests(TestConfiguration config) { await RunTest(config, "NestedExceptionTest", "StackTests.script", testName : "SOS.StackTests"); }
public async Task DivZero(TestConfiguration config) { await RunTest(config, "DivZero", "DivZero.script", testTriage : true); }
public async Task SimpleThrow(TestConfiguration config) { await RunTest(config, "SimpleThrow", "SimpleThrow.script", testTriage : true); }
public static int Main(string[] arguments) { var clusters = GetClusters(); if (arguments.Length < 1) { Console.Error.WriteLine("cluster command needs atleast one argument to indicate the cluster to start"); foreach (var c in clusters) { Console.WriteLine(" - " + c.Name.Replace("Cluster", "").ToLowerInvariant()); } return(3); } // Force TestConfiguration to load as if started from the command line even if we are actually starting // from the IDE. Also force configuration mode to integration test so the seeders run Environment.SetEnvironmentVariable("NEST_COMMAND_LINE_BUILD", "1", EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("NEST_INTEGRATION_TEST", "1", EnvironmentVariableTarget.Process); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NEST_YAML_FILE"))) { // build always sets previous argument, assume we are running from the IDE or dotnet run var yamlFile = TestConfiguration.LocateTestYamlFile(); Environment.SetEnvironmentVariable("NEST_YAML_FILE", yamlFile, EnvironmentVariableTarget.Process); } // if version is passed this will take precedence over the version in the yaml file // in the constructor of EnvironmentConfiguration var clusterName = arguments[0]; if (arguments.Length > 1) { Environment.SetEnvironmentVariable("NEST_INTEGRATION_VERSION", arguments[1], EnvironmentVariableTarget.Process); } var cluster = clusters.FirstOrDefault(c => c.Name.StartsWith(clusterName, StringComparison.OrdinalIgnoreCase)); if (cluster == null) { Console.Error.WriteLine($"No cluster found that starts with '{clusterName}"); Console.Out.WriteLine("Available clusters:"); foreach (var c in clusters) { Console.Out.WriteLine($" - {c.Name.Replace("Cluster", "")}"); } return(4); } //best effort, wont catch all the things //https://github.com/dotnet/coreclr/issues/8565 //Don't want to make this windows only by registering a SetConsoleCtrlHandler though P/Invoke. AppDomain.CurrentDomain.ProcessExit += (s, ev) => Instance?.Dispose(); Console.CancelKeyPress += (s, ev) => Instance?.Dispose(); if (!TryStartClientTestClusterBaseImplementation(cluster) && !TryStartXPackClusterImplementation(cluster)) { Console.Error.WriteLine($"Could not create an instance of '{cluster.FullName}"); return(1); } return(0); }
public void TestFixtureSetUp() { testConfig = new ConfigReader().Read(); }
public async Task TaskNestedException(TestConfiguration config) { await RunTest(config, "TaskNestedException", "TaskNestedException.script", testTriage : true); }
public static bool GenerateDumpWithGDB(this TestConfiguration config) { return(config.GetValue("GenerateDumpWithGDB")?.ToLowerInvariant() == "true"); }
public IAuthentication GetAuthentication(TestConfiguration config) { return(new ClientCredentialsAuthentication(config.ClientCredentials.ClientId, config.ClientCredentials.ClientSecret)); }
public void FixtureSetup() { TestMode testMode = TestMode.Create(Environment.CommandLine); configuration = testMode.GetConfiguration(string.Empty, this); }
public TestStatCollector(string memberName, TestConfiguration configuration, out bool cancel) { MemberName = memberName; cancel = false; _divisor = configuration.Divisor; }
public static ControllersTestConfiguration GetControllersConfiguration(this TestConfiguration testConfiguration) => testConfiguration.GetConfiguration(() => new ControllersTestConfiguration(testConfiguration.Configuration));
public OpenWeatherMapApi() { _configuration = TestConfiguration.GetConfiguration(); _url = _configuration["apiUrl"]; _apiKey = _configuration["apiKey"]; }