Example #1
0
        static int Main(string[] args)
        {
            foreach (string arg in args)
            {
                FileInfo fi = new FileInfo(arg);
                Console.WriteLine("Verzeichnis: " + fi.DirectoryName);
                Console.WriteLine("Datei: " + fi.Name);
                if (!fi.Exists) continue;
                if (fi.Extension.CompareTo(".xls") != 0) continue;

                Console.WriteLine();

                // Todo mentzel Proxy zum Generieren der richtigen Instanz (v4, v3 ...)
                IAnmeldung av4 = new Internal.AnmeldungV4(fi.FullName);

                Console.WriteLine(av4.Verein.Name + "  -> " + av4.Verein.GetNameHash());

                foreach (Judoka jk in av4.Judoka)
                {
                    Console.Write("    " + jk.Vorname + " " + jk.Nachname);
                    Console.WriteLine("  -> " + jk.GetNameHash(Judoka.HashType.Sum_Double | Judoka.HashType.Sum_DT));
                }

                List<Verein> vl = new List<Verein>();
                vl.Add(av4.Verein);

                List<Trainer> vt = new List<Trainer>();
                vt.Add(av4.Trainer);

                Console.WriteLine();

                CsvPersister<Verein> cpv = new CsvPersister<Verein>(fi.Directory + "\\" + av4.Verein.GetNameHash() + ".verein.csv");
                cpv.Persist(vl);
                Console.WriteLine("Ausgabe Verein: " + cpv.CsvFile.Substring(fi.DirectoryName.Length+1));

                CsvPersister<Trainer> cpt = new CsvPersister<Trainer>(fi.Directory + "\\" + av4.Verein.GetNameHash() + ".trainer.csv");
                cpt.Persist(vt);
                Console.WriteLine("Ausgabe Trainer: " + cpt.CsvFile.Substring(fi.DirectoryName.Length + 1));

                CsvPersister<Judoka> cpj = new CsvPersister<Judoka>(fi.Directory + "\\" + av4.Verein.GetNameHash() + ".judoka.csv");
                cpj.Persist(av4.Judoka);
                Console.WriteLine("Ausgabe Judoka: " + cpj.CsvFile.Substring(fi.DirectoryName.Length + 1));

                Console.WriteLine();
            }

            Console.ReadLine();
            return 0;
        }
    public async Task Run()
    {
        _testOutputHelper.WriteLine($"----------------Starting execution: {(ShouldRunLocally() ? "local" : "remote")}");
        _testOutputHelper.WriteLine($"Directory for iteration results created at: {_iterationResults}");

        var testConfig = TestConfig.Default;

        foreach (var agentConfig in testConfig.Agents)
        {
            // TestOutputHelper writes messages to test output, logged at the end of the test when run with dotnet test
            _testOutputHelper.WriteLine($"----------------Running configuration: {agentConfig.Name}");

            var resultsConvention = new NamingConvention(agentConfig, _iterationResults);

            Directory.CreateDirectory(resultsConvention.ContainerLogs);

            _testOutputHelper.WriteLine($"Directory for configuration created at: {resultsConvention.AgentResults}");

            await using var sqlServer = CreateSqlServer(resultsConvention);
            await sqlServer.StartAsync();

            await using var eshopApp = new EshopApp(_network, _collector, sqlServer, resultsConvention, agentConfig);
            await eshopApp.StartAsync();

            _testOutputHelper.WriteLine("----------------Starting warmup.");

            await using var loadDriver = new LoadDriver(_network, resultsConvention, testConfig);

            await using var warmupDriverContainer = loadDriver.BuildWarmup();
            await warmupDriverContainer.StartAsync();

            var warmupExitCode = await warmupDriverContainer.GetExitCode();

            Assert.Equal(0, warmupExitCode);

            _testOutputHelper.WriteLine($"Warmup finished with exit code: {warmupExitCode}");

            // start dotnet-counters inside the app container
            await eshopApp.StartCountersAsync();

            var processList = await eshopApp.ListProcessesAsync();

            // there should be 2 processes running inside the container: the app and dotnet-counters
            Assert.Equal(2, processList.Count);
            Assert.Contains(processList, s => s.Contains("dotnet Web.dll"));
            Assert.Contains(processList, s => s.Contains("./dotnet-counters"));

            _testOutputHelper.WriteLine("----------------Starting driving a load on the app.");
            await loadDriver.StartAsync();

            var exitCode = await loadDriver.StopAsync();

            _testOutputHelper.WriteLine($"Load driver exited with code: {exitCode}");
            Assert.Equal(0, exitCode);

            await eshopApp.StopAsync();
        }

        _testOutputHelper.WriteLine("----------------Starting perf results collection.");
        var results = await new ResultsCollector(_iterationResults).CollectResultsAsync(testConfig.Agents);

        _testOutputHelper.WriteLine("----------------Persisting test results.");
        // creates or appends to a single file, shared between different test runs
        await using var csvPersister = new CsvPersister(_iterationResults.Parent, results);
        await csvPersister.PersistResultsAsync();

        _testOutputHelper.WriteLine("----------------Persisting test configuration.");
        await using var configPersister = new ConfigPersister(_iterationResults.Parent);
        await configPersister.PersistConfigurationAsync(testConfig);
    }