Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEmacs
    public class BulkInsertTest : TestKitXunit
    {
        private AppSettings appSettings;

        public BulkInsertTest(ITestOutputHelper output) : base(output)
        {
            Setup();
        }

        public void Setup()
        {
            appSettings = new AppSettings()
            {
                DBConnection = "server=localhost;port=33061;database=showaakka_searchdb;user=root;password=root;"
            };
        }

        [Theory]
        [InlineData(50000, 100, 10)]    //5만개의 데이터 인입에 소요시간은 10초이내여야한다. (배치사이즈:한번처리하는데 최대수:튜닝)
        public void BulkSppedTest(int daatSize,int batchSize, int cutoff)
        {
            var bulkItems_reseverd = new List<MessageReseved>();
            for(int i = 0; i < daatSize; i++)
            {
                var addData = new MessageReseved()
                {
                    Seq = i.ToString(),
                    no = i,
                    Message = "TestMessage" + i,
                    updateTime = DateTime.Now
                };
                bulkItems_reseverd.Add(addData);
            }

            Within(TimeSpan.FromSeconds(cutoff), () => {
                EntityFrameworkManager.ContextFactory = context => new BatchRepository(appSettings);
                using (var context = new BatchRepository(appSettings))
                {
                    context.BulkInsertAsync(bulkItems_reseverd, options => {
                        options.BatchSize = batchSize;
                    }).Wait();
                }
            });
        }
    }

...