Exemplo n.º 1
0
        public void CreateIndexWithInclude()
        {
            //Arrange
            string indexName = "ix_IndexTest3";

            CreateTableTask.Create(SqlConnection, "dbo.IndexCreation3", new List <TableColumn>()
            {
                new TableColumn("Key1", "INT", allowNulls: false),
                new TableColumn("Key2", "CHAR(2)", allowNulls: true),
                new TableColumn("Value1", "NVARCHAR(10)", allowNulls: true),
                new TableColumn("Value2", "DECIMAL(10,2)", allowNulls: false),
            });
            //Act
            CreateIndexTask.CreateOrRecreate(SqlConnection, indexName, "dbo.IndexCreation3",
                                             new List <string>()
            {
                "Key1", "Key2"
            },
                                             new List <string>()
            {
                "Value1", "Value2"
            });
            //Assert
            Assert.True(IfIndexExistsTask.IsExisting(SqlConnection, "ix_IndexTest3", "dbo.IndexCreation3"));
        }
Exemplo n.º 2
0
        public void ReCreateIndex(IConnectionManager connection)
        {
            //Arrange
            string indexName = "ix_IndexTest2";

            CreateTableTask.Create(connection, "IndexCreationTable2", new List <TableColumn>()
            {
                new TableColumn("Key1", "INT", allowNulls: false),
                new TableColumn("Key2", "INT", allowNulls: true),
            });
            CreateIndexTask.CreateOrRecreate(connection, indexName, "IndexCreationTable2",
                                             new List <string>()
            {
                "Key1", "Key2"
            });

            //Act
            CreateIndexTask.CreateOrRecreate(connection, indexName, "IndexCreationTable2",
                                             new List <string>()
            {
                "Key1", "Key2"
            });

            //Assert
            Assert.True(IfIndexExistsTask.IsExisting(connection, "ix_IndexTest2", "IndexCreationTable2"));
        }
Exemplo n.º 3
0
        public void TestCreateIndex()
        {
            string indexName = "ix_" + TestHelper.RandomString(5);

            CreateIndexTask.Create(indexName, "test.Table1", new List <string>()
            {
                "key1", "key2"
            });
            Assert.IsTrue(SqlTask.ExecuteScalarAsBool("Check if index exists", $"select count(*) from sys.indexes where name = '{indexName}'"));
        }
Exemplo n.º 4
0
 public void TestLogging()
 {
     CreateLogTablesTask.CreateLog();
     CreateIndexTask.Create("ix_" + TestHelper.RandomString(5), "test.Table1", new List <string>()
     {
         "key1", "key2"
     });
     Assert.AreEqual(2, new SqlTask("Find log entry", "select count(*) from etl.Log where TaskType='CREATEINDEX' group by TaskHash")
     {
         DisableLogging = true
     }.ExecuteScalar <int>());
 }
 public void CreateIndexLogging()
 {
     //Arrange
     CreateSimpleTable("dbo.CreateIndex");
     //Act
     CreateIndexTask.CreateOrRecreate(SqlConnection, "ix_logIndexTest", "dbo.CreateIndex",
                                      new List <string>()
     {
         "Col1", "Col2"
     });
     //Assert
     Assert.Equal(2, CountLogEntries("CreateIndexTask"));
 }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            var         p       = InitProps();
            Config      conf    = new Config(p);
            PerfRunData runData = new PerfRunData(conf);

            // 1. top sequence
            TaskSequence top = new TaskSequence(runData, null, null, false); // top level, not parallel

            // 2. task to create the index
            CreateIndexTask create = new CreateIndexTask(runData);

            top.AddTask(create);

            // 3. task seq to add 500 docs (order matters - top to bottom - add seq to top, only then add to seq)
            TaskSequence seq1 = new TaskSequence(runData, "AddDocs", top, false);

            seq1.SetRepetitions(500);
            seq1.SetNoChildReport();
            top.AddTask(seq1);

            // 4. task to add the doc
            AddDocTask addDoc = new AddDocTask(runData);

            //addDoc.setParams("1200"); // doc size limit if supported
            seq1.AddTask(addDoc); // order matters 9see comment above)

            // 5. task to close the index
            CloseIndexTask close = new CloseIndexTask(runData);

            top.AddTask(close);

            // task to report
            RepSumByNameTask rep = new RepSumByNameTask(runData);

            top.AddTask(rep);

            // print algorithm
            Console.WriteLine(top.ToString());

            // execute
            top.DoLogic();
        }
Exemplo n.º 7
0
        public void Drop(IConnectionManager connection)
        {
            //Arrange
            CreateTableTask.Create(connection, "DropIndexTable", new List <TableColumn>()
            {
                new TableColumn("Test1", "INT")
            });
            CreateIndexTask.CreateOrRecreate(connection, "IndexToDrop", "DropIndexTable",
                                             new List <string>()
            {
                "Test1"
            });
            Assert.True(IfIndexExistsTask.IsExisting(connection, "IndexToDrop", "DropIndexTable"));

            //Act
            DropIndexTask.Drop(connection, "IndexToDrop", "DropIndexTable");

            //Assert
            Assert.False(IfIndexExistsTask.IsExisting(connection, "IndexToDrop", "DropIndexTable"));
        }
Exemplo n.º 8
0
        public void CreateTableWithPrimaryKeyAndIndex(IConnectionManager connection)
        {
            //Arrange
            List <TableColumn> columns = new List <TableColumn>()
            {
                new TableColumn("Id", "INT", allowNulls: false, isPrimaryKey: true),
                new TableColumn("value2", "DATE", allowNulls: true)
            };

            //Act
            CreateTableTask.Create(connection, "CreateTablePKWithIDX", columns);
            CreateIndexTask.CreateOrRecreate(connection, "testidx", "CreateTablePKWithIDX", new List <string>()
            {
                "value2"
            });

            //Assert
            Assert.True(IfTableOrViewExistsTask.IsExisting(connection, "CreateTablePKWithIDX"));
            Assert.True(IfIndexExistsTask.IsExisting(connection, "testidx", "CreateTablePKWithIDX"));
            var td = TableDefinition.GetDefinitionFromTableName("CreateTablePKWithIDX", connection);

            Assert.True(td.Columns.Where(col => col.IsPrimaryKey).Count() == 1);
        }