public static bool RP_rangeSeparators_nullCustomComparer(DryadLinqContext context)
        {
            string testName = "RP_rangeSeparators_nullCustomComparer";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);
                    var results1         = pt1.RangePartition(x => x, new int[] { 1, 2, 3, 4 }, null, false).ToArray();
                    var results2         = pt1.RangePartition(x => x, new int[] { 1, 2, 3, 4 }, null).ToArray();
                    //passing is not throwing.
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
Example #2
0
        public static bool Bug14189_OrderPreservation(DryadLinqContext context)
        {
            string testName = "Bug14189_OrderPreservation";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IGrouping <int, int>[] clusterSorted, localSorted;
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);
                    var output           = pt1.OrderBy(x => x % 4)
                                           .Select(x => x).Select(x => x).Where(x => true) // this pipeline was not preserving order correctly.
                                           .GroupBy(x => x % 4)
                                           .ToArray();

                    passed &= (output.Count() == output.Select(x => x.Key).Distinct().Count()); // "each group should have a distinct key");
                    // sort back on the key for deterministic output.
                    clusterSorted = output.OrderBy(x => x.Key).ToArray();
                }

                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);
                    var output           = pt1.OrderBy(x => x % 4)
                                           .Select(x => x).Select(x => x).Where(x => true) // this pipeline was not preserving order correctly.
                                           .GroupBy(x => x % 4)
                                           .ToArray();

                    passed &= (output.Count() == output.Select(x => x.Key).Distinct().Count()); // "each group should have a distinct key");
                    // sort back on the key for deterministic output.
                    localSorted = output.OrderBy(x => x.Key).ToArray();
                }

                // check that each group of output has the same elements as the LINQ groups.
                for (int i = 0; i < 4; i++)
                {
                    var a = clusterSorted[i].OrderBy(x => x);
                    var b = localSorted[i].OrderBy(x => x);

                    passed &= a.SequenceEqual(b); //the output should match linq. Error for group: + i);
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
        public static bool RP_singlePartition_autoSeparators(DryadLinqContext context)
        {
            string testName = "RP_singlePartition_autoSeparators";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    string outFile = "unittest/output/RP_singlePartition_autoSeparators";

                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);
                    IQueryable <int> pt2 = pt1.Apply(x => x) // force a merge
                                           .RangePartition(x => x)
                                           .ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true);
                    var jobInfo = pt2.Submit();
                    jobInfo.Wait();

                    passed   &= TestRangePartitioned(pt2, 1, false);
                    result[0] = pt2.ToList();
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);
                    IQueryable <int> pt2 = pt1.Apply(x => x) // force a merge
                                           .RangePartition(x => x);
                    result[1] = pt2.ToList();
                }

                // compare result
                try
                {
                    Validate.Check(result);
                }
                catch (Exception ex)
                {
                    TestLog.Message("Error: " + ex.Message);
                    passed &= false;
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
        public static bool RP_keySelector_rangeKeys_keyComparer_isDescending(DryadLinqContext context)
        {
            string testName = "RP_keySelector_rangeKeys_keyComparer_isDescending";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    string outFile = "unittest/output/RP_keySelector_rangeKeys_keyComparer_isDescending";

                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);
                    IQueryable <int> pt2 = pt1.RangePartition(x => x, new[] { 8, 5, 2 }, Comparer <int> .Default, true)
                                           .ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true);
                    var jobInfo = pt2.Submit();
                    jobInfo.Wait();

                    passed   &= TestRangePartitioned(pt2, 4, true);
                    result[0] = pt2.ToList();
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);
                    IQueryable <int> pt2 = pt1.RangePartition(x => x, new[] { 8, 5, 2 }, Comparer <int> .Default, true);
                    result[1] = pt2.ToList();
                }

                // compare result
                try
                {
                    Validate.Check(result);
                }
                catch (Exception ex)
                {
                    TestLog.Message("Error: " + ex.Message);
                    passed &= false;
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
        public static bool RP_rangeSeparators_customComparer(DryadLinqContext context)
        {
            string testName = "RP_rangeSeparators_customComparer";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    string outFile = "unittest/output/RP_rangeSeparators_customComparer";

                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);

                    //these keys should be considered not-sorted
                    try
                    {
                        var results = pt1.RangePartition(x => x, new int[] { 1, 2, 3, 4 }, new WeirdIntComparer(), false).ToArray();
                        passed &= false; // "an exception should have been thrown (non-sorted separators)."
                    }
                    catch (ArgumentException)
                    {
                        //expected
                    }

                    //these keys should also be considered not-sorted
                    try
                    {
                        var results = pt1.RangePartition(x => x, new int[] { 4, 3, 2, 1 }, new WeirdIntComparer(), false).ToArray();
                        passed &= false; // "an exception should have been thrown (non-sorted separators)."
                    }
                    catch (ArgumentException)
                    {
                        //expected
                    }

                    //these keys should work
                    IQueryable <int> pt2 = pt1.RangePartition(x => x, new int[] { 6, 6, 3, 1 }, new WeirdIntComparer(), false)
                                           .ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true);
                    var jobInfo = pt2.Submit();
                    jobInfo.Wait();

                    passed   &= TestRangePartitioned(pt2, 5, new WeirdIntComparer(), false);
                    result[0] = pt2.ToList();
                }
                // local
                {
                    context.LocalDebug = true;
                    string outFile = "unittest/output/RP_rangeSeparators_customComparer";

                    IQueryable <int> pt1 = DataGenerator.GetRangePartitionDataSet(context);

                    //these keys should be considered not-sorted
                    try
                    {
                        var results = pt1.RangePartition(x => x, new int[] { 1, 2, 3, 4 }, new WeirdIntComparer(), false).ToArray();
                        passed &= false; // "an exception should have been thrown (non-sorted separators)."
                    }
                    catch (ArgumentException)
                    {
                        //expected
                    }

                    //these keys should also be considered not-sorted
                    try
                    {
                        var results = pt1.RangePartition(x => x, new int[] { 4, 3, 2, 1 }, new WeirdIntComparer(), false).ToArray();
                        passed &= false; // "an exception should have been thrown (non-sorted separators)."
                    }
                    catch (ArgumentException)
                    {
                        //expected
                    }

                    //these keys should work
                    IQueryable <int> pt2 = pt1.RangePartition(x => x, new int[] { 6, 6, 3, 1 }, new WeirdIntComparer(), false)
                                           .ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true);
                    var jobInfo = pt2.Submit();
                    jobInfo.Wait();

                    result[1] = pt2.ToList();
                }

                // compare result
                try
                {
                    Validate.Check(result);
                }
                catch (Exception ex)
                {
                    TestLog.Message("Error: " + ex.Message);
                    passed &= false;
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }