Esempio n. 1
0
        public void RTableStableTwoReplicaCRUDTest()
        {
            try
            {
                string tableName = this.GenerateRandomTableName("RTable2Perf");
                this.SetupRTableEnv(tableName, true, "", new List <int> {
                    0, 1
                });
                Console.WriteLine("tableName = {0}", tableName);

                // two-replica and stable?
                View view = this.configurationService.GetTableView(tableName);
                Assert.IsTrue(view != null && view.Chain != null && view.Chain.Count == 2 && view.IsStable);
                // convert mode is Off ? yes, because we can't have more than 1 replica while in convert mode!

                ReplicatedTable rtable = this.repTable;

                Console.WriteLine("[C]reate stats ...");
                entries = ShuffleList(entries);
                DataSampling createStats = CreateEntriesStats(rtable, entries);

                Console.WriteLine("[R]etrieve stats ...");
                entries = ShuffleList(entries);
                DataSampling retrieveStats = RetrieveEntriesPerf(rtable, entries);

                Console.WriteLine("[U]pdate stats ...");
                entries = ShuffleList(entries);
                DataSampling updateStats = UpdateEntriesPerf(rtable, entries);

                Console.WriteLine("[D]elete stats ...");
                entries = ShuffleList(entries);
                DataSampling deleteStats = DeleteEntriesPerf(rtable, entries);


                //// TODO: Add perf. tests for LINQ query ...


                IEnumerable <CustomerEntity> customers = GetCustomerEntities(rtable);
                Assert.AreEqual(customers.Count(), 0);

                var report = new StringBuilder();
                report.AppendLine("RTable Stable Two-Replicas CRUD perf (ms)");
                report.AppendFormat("{0}\n", createStats.ToString());
                report.AppendFormat("{0}\n", retrieveStats.ToString());
                report.AppendFormat("{0}\n", updateStats.ToString());
                report.AppendFormat("{0}\n", deleteStats.ToString());
                report.AppendLine("End report.");

                Console.WriteLine(report);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex);
                Assert.Fail();
            }
            finally
            {
                base.DeleteAllRtableResources();
            }
        }
Esempio n. 2
0
        private DataSampling DeleteEntriesPerf(ReplicatedTable rtable, List <CustomerEntity> entries)
        {
            var stats = new DataSampling("[D]elete");

            foreach (var entry in entries)
            {
                TableOperation retrieveOperation = TableOperation.Retrieve <CustomerEntity>(entry.PartitionKey, entry.RowKey);
                TableResult    retrieveResult    = rtable.Execute(retrieveOperation);

                Assert.IsNotNull(retrieveResult, "retrieveResult = null");
                Assert.AreEqual((int)HttpStatusCode.OK, retrieveResult.HttpStatusCode, "retrieveResult.HttpStatusCode mismatch");
                Assert.IsNotNull((CustomerEntity)retrieveResult.Result, "Retrieve: customer = null");

                // Delete entity
                var customer = (CustomerEntity)retrieveResult.Result;
                Assert.IsTrue(customer._rtable_Version == 2, "entry was updated once, version should be 2");

                TableOperation deleteOperation = TableOperation.Delete(customer);

                TableResult deleteResult;
                var         watch = System.Diagnostics.Stopwatch.StartNew();
                {
                    deleteResult = rtable.Execute(deleteOperation);
                }
                watch.Stop();
                stats.AddPoint(watch.ElapsedMilliseconds);

                Assert.IsNotNull(deleteResult, "deleteResult = null");
                Assert.AreEqual((int)HttpStatusCode.NoContent, deleteResult.HttpStatusCode, "deleteResult.HttpStatusCode mismatch");
            }

            return(stats);
        }
Esempio n. 3
0
        private DataSampling UpdateEntriesPerf(ReplicatedTable rtable, List <CustomerEntity> entries)
        {
            var stats = new DataSampling("[U]pdate");

            foreach (var entry in entries)
            {
                TableOperation retrieveOperation = TableOperation.Retrieve <CustomerEntity>(entry.PartitionKey, entry.RowKey);
                TableResult    retrieveResult    = rtable.Execute(retrieveOperation);

                Assert.IsNotNull(retrieveResult, "retrieveResult = null");
                Assert.AreEqual((int)HttpStatusCode.OK, retrieveResult.HttpStatusCode, "retrieveResult.HttpStatusCode mismatch");
                Assert.IsNotNull((CustomerEntity)retrieveResult.Result, "Retrieve: customer = null");

                // Update entity
                var customer = (CustomerEntity)retrieveResult.Result;
                customer.Email = string.Format("{0}.{1}@email.com", entry.PartitionKey, entry.RowKey);

                TableOperation updateOperation = TableOperation.Replace(customer);

                TableResult updateResult;
                var         watch = System.Diagnostics.Stopwatch.StartNew();
                {
                    updateResult = rtable.Execute(updateOperation);
                }
                watch.Stop();
                stats.AddPoint(watch.ElapsedMilliseconds);

                Assert.IsNotNull(updateResult, "updateResult = null");
                Assert.AreEqual((int)HttpStatusCode.NoContent, updateResult.HttpStatusCode, "updateResult.HttpStatusCode mismatch");
            }

            return(stats);
        }
Esempio n. 4
0
        private DataSampling RetrieveEntriesPerf(ReplicatedTable rtable, List <CustomerEntity> entries)
        {
            var stats = new DataSampling("[R]etrieve");

            foreach (var entry in entries)
            {
                TableOperation retrieveOperation = TableOperation.Retrieve <CustomerEntity>(entry.PartitionKey, entry.RowKey);

                TableResult retrieveResult = null;
                var         watch          = System.Diagnostics.Stopwatch.StartNew();
                {
                    retrieveResult = rtable.Execute(retrieveOperation);
                }
                watch.Stop();
                stats.AddPoint(watch.ElapsedMilliseconds);

                Assert.IsNotNull(retrieveResult, "retrieveResult = null");
                Assert.AreEqual((int)HttpStatusCode.OK, retrieveResult.HttpStatusCode, "retrieveResult.HttpStatusCode mismatch");

                var customer = (CustomerEntity)retrieveResult.Result;
                Assert.IsNotNull(customer, "Retrieve: customer = null");

                Assert.IsTrue(customer._rtable_Version == 1, "new entry should have version 1");
            }

            return(stats);
        }
Esempio n. 5
0
        public void XStoreCRUDTest()
        {
            try
            {
                string tableName = this.GenerateRandomTableName("XStorePerf");
                this.SetupRTableEnv(tableName, true, "", new List <int> {
                    0
                });
                Console.WriteLine("tableName = {0}", tableName);

                CloudTableClient tableClient = this.cloudTableClients[0];
                CloudTable       table       = tableClient.GetTableReference(tableName);

                Console.WriteLine("[C]reate stats ...");
                entries = ShuffleList(entries);
                DataSampling createStats = CreateEntriesStats(table, entries);

                Console.WriteLine("[R]etrieve stats ...");
                entries = ShuffleList(entries);
                DataSampling retrieveStats = RetrieveEntriesPerf(table, entries);

                Console.WriteLine("[U]pdate stats ...");
                entries = ShuffleList(entries);
                DataSampling updateStats = UpdateEntriesPerf(table, entries);

                Console.WriteLine("[D]elete stats ...");
                entries = ShuffleList(entries);
                DataSampling deleteStats = DeleteEntriesPerf(table, entries);


                // TODO: Add perf. tests for LINQ query ...


                IEnumerable <CustomerEntity> customers = GetCustomerEntities(table);
                Assert.AreEqual(customers.Count(), 0);

                var report = new StringBuilder();
                report.AppendLine("XStore CRUD perf (ms)");
                report.AppendFormat("{0}\n", createStats.ToString());
                report.AppendFormat("{0}\n", retrieveStats.ToString());
                report.AppendFormat("{0}\n", updateStats.ToString());
                report.AppendFormat("{0}\n", deleteStats.ToString());
                report.AppendLine("End report.");

                Console.WriteLine(report);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex);
                Assert.Fail();
            }
            finally
            {
                base.DeleteAllRtableResources();
            }
        }
Esempio n. 6
0
        private DataSampling CreateEntriesStats(ReplicatedTable rtable, List <CustomerEntity> entries)
        {
            var stats = new DataSampling("[C]reate");

            foreach (var entry in entries)
            {
                TableOperation insertOperation = TableOperation.Insert(entry);

                TableResult insertResult = null;
                var         watch        = System.Diagnostics.Stopwatch.StartNew();
                {
                    insertResult = rtable.Execute(insertOperation);
                }
                watch.Stop();
                stats.AddPoint(watch.ElapsedMilliseconds);

                Assert.IsNotNull(insertResult, "insertResult = null");
                Assert.AreEqual((int)HttpStatusCode.NoContent, insertResult.HttpStatusCode, "insertResult.HttpStatusCode mismatch");
            }

            return(stats);
        }