Example #1
0
        public XDocument GetXDocument(TestNodes testNodes)
        {
            Logger.Info($"Serializing {testNodes} to XDocument.");

            var xmlDocument = XDocument.Parse(GetXml(testNodes));

            Logger.Debug(xmlDocument);

            return(xmlDocument);
        }
Example #2
0
        public void Finish(FinishLaunchRequest request, bool force = false)
        {
            FinishTask = Task.Run(async() =>
            {
                StartTask.Wait();

                TestNodes.ToList().ForEach(tn => tn.FinishTask.Wait());

                await _service.FinishLaunchAsync(LaunchId, request, force);
            });
        }
        public void DeployDatabase(TestNodes mainTestNode, string connectionString, string dbName, string connStringWithoutCatalog, DatabaseType dbType, string pathToScript)
        {
            DatabaseHandler db     = new DatabaseHandler(connectionString, dbType);
            DatabaseHandler db1    = new DatabaseHandler(connStringWithoutCatalog, dbType);
            MySqlDeploy     deploy = new MySqlDeploy();

            if (!deploy.CheckDatabaseExists(db1.Database, dbName))
            {
                deploy.CreateDatabase(db1.Database, dbName);
            }
            deploy.DeployScript(pathToScript, mainTestNode, db);
        }
Example #4
0
        public void Finish(FinishTestItemRequest request)
        {
            FinishTask = Task.Run(async() =>
            {
                StartTask.Wait();

                AdditionalTasks.ToList().ForEach(at => at.Wait());

                TestNodes.ToList().ForEach(tn => tn.FinishTask.Wait());

                await _service.FinishTestItemAsync(TestId, request);
            });
        }
        public void DeployScript(string pathToScript, TestNodes mainTestNode, DatabaseHandler db)
        {
            try
            {
                var msScriptParser = new MsSqlScriptParser();

                var deployTestNode = ObjectComparator.CreateTestNode(new List <TestResult>(), ObjectType.ScriptTests,
                                                                     "Set of tests for Script");

                var scriptFromFile = File.ReadAllText(Path.Combine(pathToScript));

                var parsedScript = msScriptParser.GetScriptArray(scriptFromFile);

                var dbCreated = msScriptParser.ExecuteTransactionScript(parsedScript, db.Database);

                if (dbCreated)
                {
                    return;
                }

                ObjectComparator.AddTestResult($"Creation of Database objects failed. Databaes: {db.Database.ConnectionString}",
                                               ErrorTypes.CreationScriptFailed,
                                               ObjectType.Script,
                                               $"Script: {pathToScript}",
                                               deployTestNode.Results);

                ObjectComparator.SetResultLevel(deployTestNode);

                mainTestNode.Nodes.Add(deployTestNode);

                var resultPath = Settings.SettingsObject.ResultPath;

                Xml xmlCreator = new Xml();

                var xmlContent = xmlCreator.GetXml(mainTestNode);

                xmlCreator.SaveResultTree(resultPath, xmlContent);
                Environment.Exit((int)ExitCodes.ScriptFailed);
            }
            catch (IOException ex)
            {
                Logger.Error(ex, "Unable to finish script file.");
                Environment.Exit((int)ExitCodes.ScriptFailed);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Error when executing script file.");
                Environment.Exit((int)ExitCodes.ScriptFailed);
            }
        }
        public void DeployDatabase(TestNodes mainTestNode, string connectionString, string dbName, string connStringWithoutCatalog, DatabaseType dbType, string pathToScript)
        {
            Logger.Info("Deploying database.");

            Logger.Debug($"Deploying database {dbName}. Deployed script path: {pathToScript}.");

            DatabaseHandler db     = new DatabaseHandler(connectionString, dbType);
            DatabaseHandler db1    = new DatabaseHandler(connStringWithoutCatalog, dbType);
            MsSqlDeploy     deploy = new MsSqlDeploy();

            if (!deploy.CheckDatabaseExists(db1.Database, dbName))
            {
                deploy.CreateDatabase(db1.Database, dbName);
            }
            deploy.DeployScript(pathToScript, mainTestNode, db);

            Logger.Info("Deployed successful.");
        }
Example #7
0
        public string GetXml(TestNodes testNodes)
        {
            Logger.Info($"Serialization of {testNodes} to XML string");
            XmlSerializer xsSubmit = new XmlSerializer(typeof(TestNodes), "http://alef.com/db-comparator/test");

            var subReq = testNodes;

            string xmlDocument;

            using (var sww = new StringWriter())
            {
                using (XmlWriter writer = XmlWriter.Create(sww))
                {
                    xsSubmit.Serialize(writer, subReq);
                    xmlDocument = sww.ToString();
                    Logger.Debug($"Serialized xml: {xmlDocument}");
                }
            }
            Logger.Info("Serialization successful.");

            return(xmlDocument);
        }