Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
0
        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();
                }
            }
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
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);
        }