示例#1
0
        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);
        }
示例#2
0
        public static bool Bug13108_DisableSequenceEquals(DryadLinqContext context)
        {
            string testName = "Bug13108_DisableSequenceEquals";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                // cluster
                {
                    context.LocalDebug = false;

                    IQueryable <int> pt1    = DataGenerator.GetSimpleFileSets(context);
                    IQueryable <int> pt2    = DataGenerator.GetSimpleFileSets(context);
                    bool             result = pt1.Select(x => x).SequenceEqual(pt2.Select(x => x));
                    passed &= false; // NotSupportedException should have been thrown
                }
            }
            catch (Exception Ex)
            {
            }
            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
示例#3
0
        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);
        }
示例#4
0
        public static bool Bug13970_MismatchedDataTypes(DryadLinqContext context)
        {
            string testName = "Bug13970_MismatchedDataTypes";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                // local
                {
                    context.LocalDebug = true;
                    IQueryable <int> pt1    = DataGenerator.GetGroupByReduceDataSet(context);
                    double?          output = pt1.AverageAsQuery().Single();
                    passed &= false;
                }
            }
            catch (Exception)
            {
                passed &= true; // expected
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
示例#5
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);
        }
        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);
        }
示例#7
0
        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
        public static bool Bug15371_NoDataMembersForSerialization(DryadLinqContext context)
        {
            string testName = "Bug15371_NoDataMembersForSerialization";

            TestLog.TestStart(testName);

            bool passed = true;

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

                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    IQueryable <NoDataMembersClass> output = pt1.Select(x => new NoDataMembersClass());
                    var jobInfo = output.ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, outFile), true).Submit();
                    jobInfo.Wait();
                    var result = context.FromStore <NoDataMembersClass>(AzureUtils.ToAzureUri(Config.accountName, Config.storageKey, Config.containerName, outFile)).ToArray();
                    passed &= false;
                }
            }
            catch (DryadLinqException Ex)
            {
                passed &= (Ex.ErrorCode == ReflectionHelper.GetDryadLinqErrorCode("TypeMustHaveDataMembers") ||
                           Ex.InnerException != null && ((DryadLinqException)Ex.InnerException).ErrorCode == ReflectionHelper.GetDryadLinqErrorCode("TypeMustHaveDataMembers")); // "exception should have been thrown.
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
示例#9
0
        public static bool Bug13245_FromDsc_Submit_throws(DryadLinqContext context)
        {
            string testName = "Bug13245_FromDsc_Submit_throws";

            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.Submit();
                    passed &= false; // should throw ArgEx as the input isn't well formed
                }
            }
            catch (ArgumentException)
            {
            }
            catch (Exception)
            {
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
示例#10
0
        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
        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 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);
        }
示例#13
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);
        }
        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
        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);
        }
        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
        public static bool Bug14010_AlreadyDisposedContext(DryadLinqContext context)
        {
            string testName = "Bug14010_AlreadyDisposedContext";

            TestLog.TestStart(testName);

            bool passed = true;

            context.LocalDebug = false;
            try
            {
                DryadLinqContext ctx = new DryadLinqContext(Config.cluster);
                ctx.Dispose();
                IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(ctx);
                int output           = pt1.Select(x => x).First();
                passed &= false;
            }
            catch (Exception)
            {
                passed &= true;
            }

            try
            {
                DryadLinqContext ctx = new DryadLinqContext(Config.cluster);
                IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(ctx);
                ctx.Dispose();
                int output = pt1.Select(x => x).First();
                passed &= false;
            }
            catch (Exception)
            {
                passed &= true;
            }

            try
            {
                DryadLinqContext ctx = new DryadLinqContext(Config.cluster);
                IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(ctx);
                ctx.Dispose();
                IQueryable <int> query = pt1.Select(x => x).ToStore(AzureUtils.ToAzureUri(Config.accountName, Config.containerName, "abc"), true);
                var info = DryadLinqQueryable.Submit(query);
                passed &= false;
            }
            catch (Exception)
            {
                passed &= true;
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
示例#18
0
        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);
        }
示例#19
0
        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);
        }
示例#20
0
        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);
        }
示例#21
0
        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);
        }
示例#22
0
        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);
        }
示例#23
0
        public static bool Bug13534_HashPartitionNegIndexIsError(DryadLinqContext context)
        {
            string testName = "Bug13534_HashPartitionNegIndexIsError";

            TestLog.TestStart(testName);

            bool passed = true;

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    pt1.HashPartition(x => x, 0); // exception should be thrown
                    passed &= false;
                }
            }
            catch (Exception)
            {
            }

            try
            {
                IEnumerable <int>[] result = new IEnumerable <int> [2];
                // cluster
                {
                    context.LocalDebug = false;
                    IQueryable <int> pt1 = DataGenerator.GetSimpleFileSets(context);
                    pt1.HashPartition(x => x, -1); // exception should be thrown
                    passed &= false;
                }
            }
            catch (Exception)
            {
            }

            TestLog.LogResult(new TestResult(testName, context, passed));
            return(passed);
        }
示例#24
0
        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);
        }
示例#25
0
        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);
        }
示例#26
0
        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);
        }
示例#27
0
        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);
        }
示例#28
0
        // 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);
        }
示例#29
0
        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);
        }
示例#30
0
        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);
        }