public void HandlesConcurrentRuns()
        {
            UseRealTables();
            CreateMetadataTable();

            store.Initialize();

            var countingCommand = new CountingCommand();

            Func <SchemaMigrationRunner> runnerFactory = () =>
                                                         new SchemaMigrationRunner(store, new SchemaDiffer());

            UseMigrations(new InlineMigration(1,
                                              new AddColumn("Other", new Column("Asger", typeof(int))),
                                              new CreateTable(new Table("Testing", new Column("Id", typeof(Guid), isPrimaryKey: true))),
                                              new SlowCommand(),
                                              countingCommand));

            new CreateTable(new DocumentTable("Other")).Execute(store.Database);

            Parallel.For(1, 10, x =>
            {
                Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
                runnerFactory().Run();
            });

            countingCommand.NumberOfTimesCalled.ShouldBe(1);
        }
Esempio n. 2
0
        public void HandlesConcurrentRuns()
        {
            InitializeStore();

            var command = new CountingCommand();

            Func <SchemaMigrationRunner> runnerFactory = () =>
                                                         new SchemaMigrationRunner(store, new SchemaDiffer());

            UseMigrations(new InlineMigration(1,
                                              new AddColumn("Other", new Column("Asger", typeof(int))),
                                              new CreateTable(new Table("Testing", new Column("Id", typeof(Guid), isPrimaryKey: true))),
                                              new SlowCommand(),
                                              command));

            store.Execute(new CreateTable(new DocumentTable("Other")));

            Parallel.For(1, 10, x =>
            {
                output.WriteLine(Thread.CurrentThread.ManagedThreadId.ToString());
                if (string.IsNullOrEmpty(Thread.CurrentThread.Name))
                {
                    Thread.CurrentThread.Name = $"Test thread {x}";
                }
                runnerFactory().Run();
            });

            command.NumberOfTimesCalled.ShouldBe(1);
        }
Esempio n. 3
0
        public void MultipleMigrationsAtTheSameTime()
        {
            CreateMetadataTable();

            var countingCommand = new CountingCommand();

            UseMigrations(
                new InlineMigration(1, countingCommand),
                new InlineMigration(2, countingCommand));

            Should.NotThrow(() => new SchemaMigrationRunner(store, new FakeSchemaDiffer()).Run());

            countingCommand.NumberOfTimesCalled.ShouldBe(2);
        }
        public void DoesNotRunSchemaMigrationTwice()
        {
            CreateMetadataTable();

            var command = new CountingCommand();

            UseMigrations(new InlineMigration(1, command));

            var runner = new SchemaMigrationRunner(store, new FakeSchemaDiffer());

            runner.Run();
            runner.Run();

            command.NumberOfTimesCalled.ShouldBe(1);
        }
        public void NextRunContinuesAtNextVersion()
        {
            CreateMetadataTable();

            var command = new CountingCommand();

            UseMigrations(new InlineMigration(1, command));

            new SchemaMigrationRunner(store, new FakeSchemaDiffer()).Run();

            Reset();

            UseMigrations(new InlineMigration(1, new ThrowingCommand()), new InlineMigration(2, command));

            new SchemaMigrationRunner(store, new FakeSchemaDiffer()).Run();

            command.NumberOfTimesCalled.ShouldBe(2);
        }
        public void DoesNotRunSchemaMigrationTwice()
        {
            CreateMetadataTable();

            var command = new CountingCommand();

            UseMigrations(new InlineMigration(1, command));

            var runner = new SchemaMigrationRunner(store, new FakeSchemaDiffer());

            runner.Run();
            runner.Run();

            command.NumberOfTimesCalled.ShouldBe(1);
        }
        public void NextRunContinuesAtNextVersion()
        {
            CreateMetadataTable();

            var command = new CountingCommand();

            UseMigrations(new InlineMigration(1, command));

            new SchemaMigrationRunner(store, new FakeSchemaDiffer()).Run();

            Reset();

            UseMigrations(new InlineMigration(1, new ThrowingCommand()), new InlineMigration(2, command));

            new SchemaMigrationRunner(store, new FakeSchemaDiffer()).Run();

            command.NumberOfTimesCalled.ShouldBe(2);
        }
        public void HandlesConcurrentRuns()
        {
            UseRealTables();
            CreateMetadataTable();

            store.Initialize();

            var countingCommand = new CountingCommand();

            Func<SchemaMigrationRunner> runnerFactory = () =>
                new SchemaMigrationRunner(store, new SchemaDiffer());

            UseMigrations(new InlineMigration(1,
                new AddColumn("Other", new Column("Asger", typeof(int))),
                new CreateTable(new Table("Testing", new Column("Id", typeof(Guid), isPrimaryKey: true))),
                new SlowCommand(),
                countingCommand));

            new CreateTable(new DocumentTable("Other")).Execute(store.Database);

            Parallel.For(1, 10, x =>
            {
                Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
                runnerFactory().Run();
            });

            countingCommand.NumberOfTimesCalled.ShouldBe(1);
        }