コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug13302_ConfigEnvironmentCleanup(DryadLinqContext context)
        {
            string testName = "Bug13302_ConfigEnvironmentCleanup";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var info             = pt1.Apply((en) => CheckEnvVar(en)).Submit();
                    info.Wait();
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #3
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug13245_QueryUsingNonHpcLinqOperator(DryadLinqContext context)
        {
            string testName = "Bug13245_QueryUsingNonHpcLinqOperator";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var info             = pt1.Blah().Submit();
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #4
0
        public static bool Aggregate_WithCombiner(DryadLinqContext context)
        {
            string testName = "Aggregate_WithCombiner";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    string           q1  = pt1.Aggregate("", (str, x) => IntToStringCSVAggregator(str, x));
                    passed &= (q1.Length == 27); // string should have numbers 1..12 separated by commas
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #5
0
        public static void Run(DryadLinqContext context, string matchPattern)
        {
            TestLog.Message(" **********************");
            TestLog.Message(" RangePartitionAPICoverageTests ");
            TestLog.Message(" **********************");

            var tests = new Dictionary <string, Action>()
            {
                { "RP_keySelector", () => RP_keySelector(context) },
                { "RP_keySelector_pcount", () => RP_keySelector_pcount(context) },
                { "RP_keySelector_isDescending", () => RP_keySelector_isDescending(context) },
                { "RP_keySelector_rangeKeys", () => RP_keySelector_rangeKeys(context) },
                { "RP_keySelector_isDescending_pcount", () => RP_keySelector_isDescending_pcount(context) },
                { "RP_keySelector_keyComparer_isDescending", () => RP_keySelector_keyComparer_isDescending(context) },
                { "RP_keySelector_rangeKeys_keyComparer", () => RP_keySelector_rangeKeys_keyComparer(context) },
                { "RP_keySelector_keyComparer_isDescending_pcount", () => RP_keySelector_keyComparer_isDescending_pcount(context) },
                { "RP_keySelector_rangeKeys_keyComparer_isDescending", () => RP_keySelector_rangeKeys_keyComparer_isDescending(context) },
                { "RP_singlePartition_autoSeparators", () => RP_singlePartition_autoSeparators(context) },
                { "RP_rangeSeparators_customComparer", () => RP_rangeSeparators_customComparer(context) },
                { "RP_rangeSeparators_nullCustomComparer", () => RP_rangeSeparators_nullCustomComparer(context) },
            };

            foreach (var test in tests)
            {
                if (Regex.IsMatch(test.Key, matchPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    test.Value.Invoke();
                }
            }
        }
コード例 #6
0
        public static void Run(DryadLinqContext context, string matchPattern)
        {
            TestLog.Message(" **********************");
            TestLog.Message(" ApplyAndForkTests ");
            TestLog.Message(" **********************");

            var tests = new Dictionary <string, Action>()
            {
                { "NonHomomorphicUnaryApply", () => NonHomomorphicUnaryApply(context) },
                { "HomomorphicUnaryApply", () => HomomorphicUnaryApply(context) },
                { "NonHomomorphicBinaryApply", () => NonHomomorphicBinaryApply(context) },
                { "LeftHomomorphicBinaryApply", () => LeftHomomorphicBinaryApply(context) },
                { "FullHomomorphicBinaryApply_DifferentDataSets", () => FullHomomorphicBinaryApply_DifferentDataSets(context) },
                { "FullHomomorphicBinaryApply_IdenticalDataSets", () => FullHomomorphicBinaryApply_IdenticalDataSets(context) },
                { "Aggregate_WithCombiner", () => Aggregate_WithCombiner(context) },
            };

            foreach (var test in tests)
            {
                if (Regex.IsMatch(test.Key, matchPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    test.Value.Invoke();
                }
            }
        }
コード例 #7
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug14870_LongIndexTakeWhile(DryadLinqContext context)
        {
            string testName = "Bug14870_LongIndexTakeWhile";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;

                    // ToDo - move to data generator
                    int[][] data = new[] {
                        new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, new int[] { }, new int[] { }
                    };

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var output           = pt1.LongTakeWhile((x, i) => i < 8).ToArray();
                    passed &= (output.Length == 8); // "Only eight items should be returned."
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #8
0
ファイル: TypesInQueryTests.cs プロジェクト: xyuan/Dryad
        public static void Run(DryadLinqContext context, string matchPattern)
        {
            TestLog.Message(" **********************");
            TestLog.Message(" TypesInQueryTests ");
            TestLog.Message(" **********************");

            var tests = new Dictionary <string, Action>()
            {
                { "NonSealedTypeRecords", () => NonSealedTypeRecords(context) },
                { "DerivedTypeRecords", () => DerivedTypeRecords(context) },
                { "ObjectRecords", () => ObjectRecords(context) },
                { "BadRecordsNotSerialized", () => BadRecordsNotSerialized(context) },
                { "GroupByWithAnonymousTypes_Bug15675", () => GroupByWithAnonymousTypes_Bug15675(context) },
                { "GroupByWithAnonymousTypes_Pipeline", () => GroupByWithAnonymousTypes_Pipeline(context) },
                { "GroupByWithAnonymousTypes_MultipleAnonymousTypes", () => GroupByWithAnonymousTypes_MultipleAnonymousTypes(context) },
                { "GroupByWithAnonymousTypes_GenericWithAnonTypeParam", () => GroupByWithAnonymousTypes_GenericWithAnonTypeParam(context) },
                { "GroupByWithAnonymousTypes_ArrayOfAnon", () => GroupByWithAnonymousTypes_ArrayOfAnon(context) },
                { "GroupByWithAnonymousTypes_NestedAnonTypes", () => GroupByWithAnonymousTypes_NestedAnonTypes(context) },
            };

            foreach (var test in tests)
            {
                if (Regex.IsMatch(test.Key, matchPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    test.Value.Invoke();
                }
            }
        }
コード例 #9
0
        public static bool TestRangePartitioned(IQueryable <int> pt, int expectedPCount, IComparer <int> comparer, bool expectedIsDescending)
        {
            bool passed = true;

            try
            {
                IEnumerable <int> ptCount = pt.ApplyPerPartition(x => CountPartitions(x));
                int cPartitions           = ptCount.Count();

                passed &= (expectedPCount == cPartitions);

                if (passed)
                {
                    int[] ptMax = pt.ApplyPerPartition(x => MaxInPartition(x)).ToArray();
                    int[] ptMin = pt.ApplyPerPartition(x => MinInPartition(x)).ToArray();

                    // compare mins and maxs of each partition
                    for (int i = 1; i < cPartitions; i++)
                    {
                        passed &= (comparer.Compare(ptMin[i], ptMax[i - 1]) == 0); // ToDo
                    }
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }
            return(passed);
        }
コード例 #10
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug15570_GetHashCodeAndEqualsForNullableFieldsOfAnonymousTypes(DryadLinqContext context)
        {
            string testName = "Bug15570_GetHashCodeAndEqualsForNullableFieldsOfAnonymousTypes";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    // use an anonymous type with nullable fields, and make sure we at least have some null values in the stream
                    var output = pt1.Select(x => new { FirstField = (x % 2 == 0) ? new int?(x) : default(int?), SecondField = x.ToString() })
                                 .GroupBy(x => x.FirstField, y => y.SecondField); // use of GB ensures we exercise the emitted GetHashCode() overload
                    passed &= (output.Count() != 0);                              // "Query return 0 length output"
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #11
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        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);
        }
コード例 #12
0
        public static bool FullHomomorphicBinaryApply_DifferentDataSets(DryadLinqContext context)
        {
            string testName = "FullHomomorphicBinaryApply_DifferentDataSets";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];

                // cluster
                {
                    context.LocalDebug = false;
                    string outFile = "unittest/output/FullHomomorphicBinaryApply_DifferentDataSets";

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    IQueryable <int> pt2 = DataGenerator.GetSimpleFileSets(context);
                    IQueryable <int> q1  = pt1.ApplyPerPartition(pt2, (x, y) => FullHomomorphic_Binary_Func(x, y), false);
                    var jobInfo          = q1.ToStore <int>(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true).Submit();
                    jobInfo.Wait();

                    passed   &= Validate.outFileExists(outFile);
                    result[0] = q1;
                }

                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    IQueryable <int> pt2 = DataGenerator.GetSimpleFileSets(context);
                    IQueryable <int> q1  = pt1.ApplyPerPartition(pt2, (x, y) => FullHomomorphic_Binary_Func(x, y), false);
                    result[1] = q1;
                }

                // 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);
        }
コード例 #13
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug12584_HashPartitionOutputCount(DryadLinqContext context) // ToDo
        {
            string testName = "Bug12584_HashPartitionOutputCount";

            TestLog.TestStart(testName);

            bool passed = true;

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

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var info             = pt1.HashPartition(x => x).ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true).Submit();
                    info.Wait();

                    //// partition verification are only valid for cluster execution..

                    //// check that nOutputPartitions == nInputPartitions.
                    //// Note: this is today's behavior, but we don't strictly guarantee this and the rules may change.
                    //var inFS = context.DscService.GetFileSet(DataGenerators.SIMPLE_FILESET_NAME);
                    //var inPCount = inFS.GetFiles().Count();
                    //var outFS = context.DscService.GetFileSet("DevUnitTest/Bug12584_out");
                    //var outPCount = outFS.GetFiles().Count();
                    //passed &= TestUtils.Assert(outPCount == inPCount, "Output nPartitions should be equal to input nPartitions.");
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                }

                // 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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
ファイル: TypesInQueryTests.cs プロジェクト: xyuan/Dryad
        public static bool DerivedTypeRecords(DryadLinqContext context)
        {
            string testName = "DerivedTypeRecords";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <ParentClass>[] result1 = new IEnumerable <ParentClass> [2];
                IEnumerable <ChildClass>[]  result2 = new IEnumerable <ChildClass> [2];

                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var output1          = pt1.Select(x => new ParentClass()).ToArray();
                    var output2          = pt1.Select(x => new ChildClass()).ToArray();
                    result1[0] = output1;
                    result2[0] = output2;
                }

                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var output1          = pt1.Select(x => new ParentClass()).ToArray();
                    var output2          = pt1.Select(x => new ChildClass()).ToArray();
                    result1[1] = output1;
                    result2[1] = output2;
                }

                // compare result
                try
                {
                    Validate.Check(result1);
                    Validate.Check(result2);
                }
                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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug13130_ReverseOperator(DryadLinqContext context)
        {
            string testName = "Bug13130_ReverseOperator";

            TestLog.TestStart(testName);

            bool passed = true;

            //data set #1
            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    result[0] = pt1.Reverse().ToArray();
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    result[1] = pt1.Reverse().ToArray();
                }

                // 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;
            }

            //data set #2 ToDo
            //data set #3 ToDo

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #18
0
ファイル: TypesInQueryTests.cs プロジェクト: xyuan/Dryad
        public static bool BadRecordsNotSerialized(DryadLinqContext context)
        {
            string testName = "BadRecordsNotSerialized";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <string>[] result = new IEnumerable <string> [2];

                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var output           = pt1.Select(x => (x % 2 == 0 ? new ChildClass() : new ParentClass())).Select(x => x is ChildClass ? "child" : "parent").ToArray();
                    result[0] = output;
                }

                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var output           = pt1.Select(x => (x % 2 == 0 ? new ChildClass() : new ParentClass())).Select(x => x is ChildClass ? "child" : "parent").ToArray();
                    result[1] = output;
                }

                // 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);
        }
コード例 #19
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug15159_NotOperatorForNullableBool(DryadLinqContext context)
        {
            string testName = "Bug15159_NotOperatorForNullableBool";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <bool?>[] result = new IEnumerable <bool?> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var output           = pt1.Select <int, bool?>(x => x == 1 ? (bool?)null : true).Select(x => !x);
                    result[0] = output.ToArray();
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var output           = pt1.Select <int, bool?>(x => x == 1 ? (bool?)null : true).Select(x => !x);
                    result[1] = output.ToArray();
                }

                // 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);
        }
コード例 #20
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug11447_GroupByWithComparer(DryadLinqContext context)
        {
            string testName = "Bug11447_GroupByWithComparer";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var a = pt1.GroupBy(x => x, EqualityComparer <int> .Default).SelectMany(x => x).ToList();
                    result[0] = a;
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var a = pt1.GroupBy(x => x, EqualityComparer <int> .Default).SelectMany(x => x).ToList();
                    result[1] = a;
                }

                // 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);
        }
コード例 #21
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug14190_MergeJoin_DecreasingOrder(DryadLinqContext context) // TODO
        {
            string testName = "Bug14190_MergeJoin_DecreasingOrder";

            TestLog.TestStart(testName);

            bool passed = true;

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

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                }

                // 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);
        }
コード例 #22
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug13637_LocalDebugProducingZeroRecords(DryadLinqContext context)
        {
            string testName = "Bug13637_LocalDebugProducingZeroRecords";

            TestLog.TestStart(testName);

            bool passed = true;

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

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    IQueryable <int> pt2 = pt1.Where(x => false).ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true);
                    var queryInfo2       = pt2.Submit();
                    queryInfo2.Wait();
                    int[] data2 = pt2.ToArray();
                    passed &= (data2.Length == 0);

                    // query producing no records -> anonymous output
                    IQueryable <int> pt3 = pt1.Where(x => false);
                    var queryInfo3       = pt3.Submit();
                    queryInfo3.Wait();

                    int[] data3 = pt3.ToArray();
                    passed &= (data3.Length == 0);
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #23
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static void Run(DryadLinqContext context, string matchPattern)
        {
            TestLog.Message(" **********************");
            TestLog.Message(" MiscBugFixTests ");
            TestLog.Message(" **********************");

            var tests = new Dictionary <string, Action>()
            {
                { "Bug11447_GroupByWithComparer", () => Bug11447_GroupByWithComparer(context) },
                { "Bug12584_HashPartitionOutputCount", () => Bug12584_HashPartitionOutputCount(context) },
                { "Bug13108_DisableSequenceEquals", () => Bug13108_DisableSequenceEquals(context) },
                { "Bug13529_and_Bug13593_IndexedOperatorCompilation", () => Bug13529_and_Bug13593_IndexedOperatorCompilation(context) },
                { "Bug13130_ReverseOperator", () => Bug13130_ReverseOperator(context) },
                { "Bug13736_IndexedTakeWhile", () => Bug13736_IndexedTakeWhile(context) },
                { "Bug13534_HashPartitionNegIndexIsError", () => Bug13534_HashPartitionNegIndexIsError(context) },
                { "Bug13474_and_Bug13483_FromDscOnBadFileSet", () => Bug13474_and_Bug13483_FromDscOnBadFileSet(context) },
                { "Bug13637_EmptyFilesInFilesets", () => Bug13637_EmptyFilesInFilesets(context) },
                { "Bug13637_LocalDebugProducingZeroRecords", () => Bug13637_LocalDebugProducingZeroRecords(context) },
                { "Bug13245_FromDsc_Submit_throws", () => Bug13245_FromDsc_Submit_throws(context) },
                { "Bug13245_QueryUsingNonHpcLinqOperator", () => Bug13245_QueryUsingNonHpcLinqOperator(context) },
                { "Bug13302_ConfigEnvironmentCleanup", () => Bug13302_ConfigEnvironmentCleanup(context) },
                { "Bug13970_MismatchedDataTypes", () => Bug13970_MismatchedDataTypes(context) },
                { "Bug14010_AlreadyDisposedContext", () => Bug14010_AlreadyDisposedContext(context) },
                { "Bug14256_LeaseOnTempDscFileset", () => Bug14256_LeaseOnTempDscFileset(context) },
                { "Bug14189_OrderPreservation", () => Bug14189_OrderPreservation(context) },
                { "Bug14190_MergeJoin_DecreasingOrder", () => Bug14190_MergeJoin_DecreasingOrder(context) },
                { "Bug14192_MultiApplySubExpressionReuse", () => Bug14192_MultiApplySubExpressionReuse(context) },
                { "Bug14870_LongIndexTakeWhile", () => Bug14870_LongIndexTakeWhile(context) },
                { "Bug15159_NotOperatorForNullableBool", () => Bug15159_NotOperatorForNullableBool(context) },
                { "Bug15371_NoDataMembersForSerialization", () => Bug15371_NoDataMembersForSerialization(context) },
                { "Bug15570_GetHashCodeAndEqualsForNullableFieldsOfAnonymousTypes", () => Bug15570_GetHashCodeAndEqualsForNullableFieldsOfAnonymousTypes(context) },
            };

            foreach (var test in tests)
            {
                if (Regex.IsMatch(test.Key, matchPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    test.Value.Invoke();
                }
            }
        }
コード例 #24
0
ファイル: TypesInQueryTests.cs プロジェクト: xyuan/Dryad
        public static bool GroupByWithAnonymousTypes_MultipleAnonymousTypes(DryadLinqContext context)
        {
            string testName = "GroupByWithAnonymousTypes_MultipleAnonymousTypes";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                // cluster
                context.LocalDebug = false;
                IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                var result1          = pt1.Select(i => new { Num = i % 10 })
                                       .Where(x => true)
                                       .Select(i => new { Num2 = i.Num })
                                       .GroupBy(x => x.Num2, x => x.Num2)
                                       .ToArray();

                // local
                context.LocalDebug = true;
                IQueryable <int> pt2 = DataGenerator.GetSimpleFileSets(context);
                var result2          = pt2.Select(i => new { Num = i % 10 })
                                       .Where(x => true)
                                       .Select(i => new { Num2 = i.Num })
                                       .GroupBy(x => x.Num2, x => x.Num2)
                                       .ToArray();

                passed &= (result1.Count() == result2.Count());
                passed &= (result1.Where(g => g.Key == 1).SelectMany(g => g).Count() == result2.Where(g => g.Key == 1).SelectMany(g => g).Count());
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #25
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug14192_MultiApplySubExpressionReuse(DryadLinqContext context)
        {
            string testName = "Bug14192_MultiApplySubExpressionReuse";

            TestLog.TestStart(testName);

            bool passed = true;

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

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var data             = pt1.Select(x => x);

                    var info = pt1.Apply(new[] { pt1, pt1 }, (sources) => new int[] { 1, 2, 3 }).ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true).Submit();
                    info.Wait();

                    // ToDo
                    //string queryPlan = TestUtils.GetRecentQueryXmlAsText();
                    //int nVerticesInPlan = TestUtils.GetVertexStageCount(queryPlan);

                    //passed &= (nVerticesInPlan == 7); // "Only seven vertices should appear (before bug, there were 10 of which the last three were extraneous.");
                }
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #26
0
ファイル: TypesInQueryTests.cs プロジェクト: xyuan/Dryad
        public static bool GroupByWithAnonymousTypes_NestedAnonTypes(DryadLinqContext context)
        {
            string testName = "GroupByWithAnonymousTypes_NestedAnonTypes";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                // cluster
                context.LocalDebug = false;
                IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                var result1          = pt1.Select(i => new { Num = new { NumInner = new int?(i % 10) } }) // nullable-fields present particular challenge.
                                       .GroupBy(x => x.Num.NumInner, x => x.Num.NumInner)
                                       .ToArray();

                // local
                context.LocalDebug = true;
                IQueryable <int> pt2 = DataGenerator.GetSimpleFileSets(context);
                var result2          = pt2.Select(i => new { Num = new { NumInner = new int?(i % 10) } }) // nullable-fields present particular challenge.
                                       .GroupBy(x => x.Num.NumInner, x => x.Num.NumInner)
                                       .ToArray();


                passed &= (result1.Count() == result2.Count());
                passed &= (result1.Where(g => g.Key == 1).SelectMany(g => g).Count() == result2.Where(g => g.Key == 1).SelectMany(g => g).Count());
            }
            catch (Exception Ex)
            {
                TestLog.Message("Error: " + Ex.Message);
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #27
0
ファイル: SerializationTests.cs プロジェクト: xyuan/Dryad
        // the generic entry method used by most tests in this file
        public static bool TestUDT <TRecord>(DryadLinqContext context, IQueryable <int> source, string testMessage, Type expectedExceptionType, int expectedErrorCode)
        {
            string testName = testMessage;

            TestLog.TestStart(testName);

            bool passed = true;

            // first make sure SelectFunc knows how to handle the type.
            try
            {
                object o = SelectFunc <TRecord>(0);
            }
            catch
            {
                TestLog.Message(String.Format("SelectFunc doesn't support type {0}", typeof(TRecord).Name));
                passed &= false;
                goto Done;
            }

            try
            {
                var results = source.Select(x => SelectFunc <TRecord>(x));

                int count = 0;
                foreach (var r in results)
                {
                    count++;
                }

                if (count == 0)
                {
                    TestLog.Message("...FAILED! No elements returned from query");
                    passed &= false;
                    goto Done;
                }
            }
            catch (Exception exp)
            {
                if (expectedExceptionType == null)
                {
                    TestLog.Message(String.Format("...FAILED! Caught {0} while none was expected: ", exp.GetType().Name));
                    passed &= false;
                    goto Done;
                }
                else if (expectedExceptionType != exp.GetType())
                {
                    TestLog.Message(String.Format("...FAILED! Caught {0} while while {1} was expected: {0}", exp.GetType().Name, expectedExceptionType.Name));
                    passed &= false;
                    goto Done;
                }
                else if (exp is DryadLinqException && expectedErrorCode != 0 && ((DryadLinqException)exp).ErrorCode != expectedErrorCode)
                {
                    TestLog.Message("...FAILED! Caught DryadLinqException but fault code is wrong.");
                    passed &= false;
                    goto Done;
                }

                TestLog.Message("....PASSED (caught correct exception)");
                goto Done;
            }

            if (expectedExceptionType == null)
            {
                TestLog.Message(".....PASSED");
            }
            else
            {
                TestLog.Message("...FAILED! No exception was thrown from query.");
                passed &= false;
            }

Done:
            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #28
0
ファイル: SerializationTests.cs プロジェクト: xyuan/Dryad
        public static void Run(DryadLinqContext context, string matchPattern)
        {
            TestLog.Message(" **********************");
            TestLog.Message(" SerializationTests ");
            TestLog.Message(" **********************");

            context.LocalDebug = false;

            IQueryable <int> source = DataGenerator.GetSimpleFileSets(context);

            var tests = new Dictionary <string, Action>()
            {
                { "UDT_Undecorated", () =>
                  SerializationTests.TestUDT <UDT_Undecorated>(context, source, "Basic UDT with no attribute. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("TypeNotSerializable")) },

                { "UDT_MarkedSerializable", () =>
                  SerializationTests.TestUDT <UDT_MarkedSerializable>(context, source, "Basic UDT which is marked as serializable.", null, 0) },

                { "UDT_StaticSerializer", () =>
                  SerializationTests.TestUDT <UDT_StaticSerializer>(context, source, "Basic UDT with old stype static serializers. Should be rejected.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("TypeNotSerializable")) },

                { "UDT_SelfCustomSerializer", () =>
                  SerializationTests.TestUDT <UDT_SelfCustomSerializer>(context, source, "UDT implementing custom serializer for itself.", null, 0) },

                { "UDT_ExternalCustomSerializer", () =>
                  SerializationTests.TestUDT <UDT_ExternalCustomSerializer>(context, source, "UDT with a custom serializer", null, 0) },

                { "UDT_BadCustomSerializerType1", () =>
                  SerializationTests.TestUDT <UDT_BadCustomSerializerType1>(context, source, "UDT decorated with an invalid custom serializer type.", typeof(DryadLinqException), 0) },

                { "UDT_BadCustomSerializerType2", () =>
                  SerializationTests.TestUDT <UDT_BadCustomSerializerType2>(context, source, "UDT decorated with another UDT's custom serializer.", typeof(DryadLinqException), 0) },

                { "UDT_BaseType", () =>
                  SerializationTests.TestUDT <UDT_BaseType>(context, source, "UDT with subtypes. Should be rejected", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleSubtypes")) },

                { "UDT_DerivedType", () =>
                  SerializationTests.TestUDT <UDT_DerivedType>(context, source, "UDT with a base type. Should be rejected", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleDerivedtypes")) },

                { "UDT_FieldOfNonPublicType", () =>
                  SerializationTests.TestUDT <UDT_FieldOfNonPublicType>(context, source, "UDT with a field of a non-public type. Should be rejected", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("UDTHasFieldOfNonPublicType")) },

                { "UDT_Nested_OuterSerializableInnerNotSerializable", () =>
                  SerializationTests.TestUDT <UDT_Nested_OuterSerializableInnerNotSerializable>(context, source, "Nested UDT, outer type Serializable, inner type not Serializable. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("TypeNotSerializable")) },

                { "UDT_Nested_OuterNotSerializableInnerSerializable", () =>
                  SerializationTests.TestUDT <UDT_Nested_OuterNotSerializableInnerSerializable>(context, source, "Nested UDT, outer type not Serializable, inner type Serializable. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("TypeNotSerializable")) },

                { "UDT_Nested_InnerAndOuterSerializable", () =>
                  SerializationTests.TestUDT <UDT_Nested_InnerAndOuterSerializable>(context, source, "Nested UDT, both outer and innter types marked Serializable.", null, 0) },

                { "UDT_Nested_InnerEnum_InnerAndOuterSerializable", () =>
                  SerializationTests.TestUDT <UDT_Nested_InnerEnum_InnerAndOuterSerializable>(context, source, "Nested UDT, inner enum, both outer and innter types marked Serializable.", null, 0) },

                { "int?", () =>
                  SerializationTests.TestUDT <int?>(context, source, "Nullable type as the UDT. Should be autoserialized.", null, 0) },

                { "UDT_FirstLevelCircular", () =>
                  SerializationTests.TestUDT <UDT_FirstLevelCircular>(context, source, "Circular UDT. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleCircularTypes")) },

                { "UDT_FirstLevelCircularArrayRef", () =>
                  SerializationTests.TestUDT <UDT_FirstLevelCircularArrayRef>(context, source, "Circular UDT with array reference to self. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleCircularTypes")) },

                { "UDT_SecondLevelCircular", () =>
                  SerializationTests.TestUDT <UDT_SecondLevelCircular>(context, source, "Circular UDT with indirect reference to self. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleCircularTypes")) },

                { "UDT_CircularTypeWithCustomSerializer", () =>
                  SerializationTests.TestUDT <UDT_CircularTypeWithCustomSerializer>(context, source, "Circular UDT with a custom serializer. Should not be rejected.", null, 0) },

                { "UDT_TypeContainingCustomSerializedCircularType", () =>
                  SerializationTests.TestUDT <UDT_TypeContainingCustomSerializedCircularType>(context, source, "An UDT containing a field of a circular UDT with a custom serializer. Should be autoserialized.", null, 0) },

                { "UDT_ObjectField", () =>
                  SerializationTests.TestUDT <UDT_ObjectField>(context, source, "UDT with a field of type System.Object. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleObjectFields")) },

                { "UDT_ObjectArrayField", () =>
                  SerializationTests.TestUDT <UDT_ObjectArrayField>(context, source, "UDT with a field of type System.Object[]. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleObjectFields")) },

                { "UDT_ObjectListField", () =>
                  SerializationTests.TestUDT <UDT_ObjectListField>(context, source, "UDT with a field of type List<object>. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleObjectFields")) },

                { "object", () =>
                  SerializationTests.TestUDT <object>(context, source, "UDT = System.Object. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleObjectFields")) },

                { "object[]", () =>
                  SerializationTests.TestUDT <object[]>(context, source, "UDT = System.Object[]. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleObjectFields")) },

                { "List<object>", () =>
                  SerializationTests.TestUDT <List <object> >(context, source, "UDT = List<object>. Should not be autoserialized.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("CannotHandleObjectFields")) },

                { "UDT_EmptyType", () =>
                  SerializationTests.TestUDT <UDT_EmptyType>(context, source, "Empty UDT. Should be rejected.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("TypeMustHaveDataMembers")) },

                { "UDT_ObjectFieldAndCustomSerializer", () =>
                  SerializationTests.TestUDT <UDT_ObjectFieldAndCustomSerializer>(context, source, "UDT with an Object field, and a custom serializer. Should not be rejected.", null, 0) },

                { "UDT_EmptyTypeWithCustomSerializer", () =>
                  SerializationTests.TestUDT <UDT_EmptyTypeWithCustomSerializer>(context, source, "Empty UDT with a custom serializer. Should be rejected.", typeof(DryadLinqException), ReflectionHelper.GetDryadLinqErrorCode("TypeMustHaveDataMembers")) },

                { "UDT_PrivateFieldOfPublicType", () =>
                  SerializationTests.TestUDT <UDT_PrivateFieldOfPublicType>(context, source, "UDT with a private field of a public type. Should be autoserialized.", null, 0) },
            };

            foreach (var test in tests)
            {
                if (Regex.IsMatch(test.Key, matchPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    test.Value.Invoke();
                }
            }
        }
コード例 #29
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug13736_IndexedTakeWhile(DryadLinqContext context)
        {
            string testName = "Bug13736_IndexedTakeWhile";

            TestLog.TestStart(testName);

            bool passed = true;

            // dataset #1
            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var pt2 = pt1.TakeWhile((x, i) => i < 6).ToArray();
                    result[0] = pt1.AsEnumerable().TakeWhile((x, i) => i < 6).ToArray();
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var pt2 = pt1.TakeWhile((x, i) => i < 6).ToArray();
                    result[1] = pt1.AsEnumerable().TakeWhile((x, i) => i < 6).ToArray();
                }

                // 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;
            }

            // dataset #2
            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    var pt2 = pt1.TakeWhile((x, i) => i < 125).ToArray();
                    result[0] = pt1.AsEnumerable().TakeWhile((x, i) => i < 125).ToArray();
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetGroupByReduceDataSet(context);
                    var pt2 = pt1.TakeWhile((x, i) => i < 125).ToArray();
                    result[0] = pt1.AsEnumerable().TakeWhile((x, i) => i < 125).ToArray();
                }

                // compare result
                try
                {
                    Validate.Check(result);
                }
                catch (Exception)
                {
                    passed &= false;
                }
            }
            catch (Exception)
            {
                passed &= false;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
コード例 #30
0
ファイル: MiscBugFixTests.cs プロジェクト: xyuan/Dryad
        public static bool Bug13529_and_Bug13593_IndexedOperatorCompilation(DryadLinqContext context)
        {
            string testName = "Bug13529_and_Bug13593_IndexedOperatorCompilation";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    result[0] = pt1.Select((x, i) => x)
                                .LongSelect((x, i) => x)
                                .LongSelectMany((x, i) => new[] { x })
                                .SelectMany((x, i) => new[] { x })
                                .Where((x, i) => true)
                                .LongWhere((x, i) => true)
                                .TakeWhile((x, i) => true)
                                .LongTakeWhile((x, i) => true)
                                .SkipWhile((x, i) => false)
                                .LongSkipWhile((x, i) => false)
                                .ToArray();
                }
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    result[1] = pt1.Select((x, i) => x)
                                .LongSelect((x, i) => x)
                                .LongSelectMany((x, i) => new[] { x })
                                .SelectMany((x, i) => new[] { x })
                                .Where((x, i) => true)
                                .LongWhere((x, i) => true)
                                .TakeWhile((x, i) => true)
                                .LongTakeWhile((x, i) => true)
                                .SkipWhile((x, i) => false)
                                .LongSkipWhile((x, i) => false)
                                .ToArray();
                }

                // 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);
        }