Exemple #1
0
        public void TestLinkedQuery()
        {
            int numberOfIter = 10;

            var rootFile = TestUtils.CreateFileOfInt(numberOfIter);
            var q        = new QueriableDummy <TestNtupe>();
            var dude1    = q.Count();
            var query1   = DummyQueryExectuor.LastQueryModel;

            var dude2  = q.Where(v => v.run > 20).Count();
            var query2 = DummyQueryExectuor.LastQueryModel;

            var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe));

            var result1 = exe.ExecuteScalarAsFuture <int>(query1);
            var result2 = exe.ExecuteScalarAsFuture <int>(query2);

            Assert.IsFalse(result1.HasValue, "r1 should not have a value yet");
            Assert.IsFalse(result2.HasValue, "r2 should not have a value yet");

            var r1v = result1.Value;

            Assert.IsTrue(result1.HasValue, "r1 should have a value");
            Assert.IsTrue(result2.HasValue, "r2 should have a value");

            Assert.AreEqual(0, result2.Value, "incorrect r2");
            Assert.AreEqual(numberOfIter, result1.Value, "incorrect r1");
        }
        /// <summary>
        /// Run a simple test that looks for errors and warnings
        /// </summary>
        /// <param name="configureMe"></param>
        private static void RunSimpleTestForErrorsAndWarnings(Action <TTreeQueryExecutor> configureMe)
        {
            var rootFile = TestUtils.CreateFileOfInt(20);

            // Get a simple query we can "play" with
            var q     = new QueriableDummy <TestNtupe>();
            var dude  = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            // Ok, now we can actually see if we can make it "go".
            var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe));

            configureMe(exe);

            // Look for warning or error
            var errorLines = new List <string>();

            CommandLineExecutor.AddLogEndpoint(s =>
            {
                if (s.ToLower().Contains("warning") || s.ToLower().Contains("error"))
                {
                    errorLines.Add(s);
                }
            });
            int result = exe.ExecuteScalar <int>(query);

            foreach (var l in errorLines)
            {
                Console.WriteLine("************ Contains error or warning: " + l);
            }

            Assert.AreEqual(0, errorLines.Count, "See std out for list of error liens");
        }
 public void TestSimpleCountReturn()
 {
     var q = new QueriableDummy<ntup2>();
     var result = q.Count();
     Assert.IsNotNull(DummyQueryExectuor.FinalResult, "final result");
     var r = DummyQueryExectuor.FinalResult.ResultValue;
     Assert.AreEqual(typeof(int), r.Type, "result type");
     Assert.AreEqual(DeclarableParameter.ExpressionType, r.NodeType, "Expression type incorrect");
     var dv = r as DeclarableParameter;
     Assert.IsTrue(dv.InitialValue == null || dv.InitialValue.RawValue == "0", "Initial value incorrect");
 }
Exemple #4
0
        public void TestSimpleCountReturn()
        {
            var q      = new QueriableDummy <ntup2>();
            var result = q.Count();

            Assert.IsNotNull(DummyQueryExectuor.FinalResult, "final result");
            var r = DummyQueryExectuor.FinalResult.ResultValue;

            Assert.AreEqual(typeof(int), r.Type, "result type");
            Assert.AreEqual(DeclarableParameter.ExpressionType, r.NodeType, "Expression type incorrect");
            var dv = r as DeclarableParameter;

            Assert.IsTrue(dv.InitialValue == null || dv.InitialValue.RawValue == "0", "Initial value incorrect");
        }
Exemple #5
0
        public void LocalWinCmdLineCountOperator()
        {
            var rootFile = TestUtils.CreateFileOfInt(20);

            // Get a simple query we can "play" with
            var q     = new QueriableDummy <TestNtupe>();
            var dude  = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            // Ok, now we can actually see if we can make it "go".
            var exe    = new TTreeQueryExecutor(new[] { rootFile.AsLocalWinUri() }, "dude", typeof(ntuple), typeof(TestNtupe));
            int result = exe.ExecuteScalar <int>(query);

            Assert.AreEqual(20, result);
        }
        public void RemoteBashCmdSplitExecution()
        {
            var rootFile = TestUtils.CreateFileOfInt(20).AsRemoteBashUri(2);

            // Get a simple query we can "play" with
            var q     = new QueriableDummy <TestNtupe>();
            var dude  = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            // Ok, now we can actually see if we can make it "go".
            var exe    = new TTreeQueryExecutor(new[] { rootFile, rootFile }, "dude", typeof(ntuple), typeof(TestNtupe));
            int result = exe.ExecuteScalar <int>(query);

            Assert.AreEqual(40, result);

            Assert.AreEqual(2, exe.CountExecutionRuns);
        }
        public void LocalBashMultiThreaded()
        {
            // Create one file of int, but use it 20 times.
            var       rootFile     = TestUtils.CreateFileOfInt(20);
            var       files        = Enumerable.Range(0, 20).Select(c => rootFile.AsLocalBashUri()).ToArray();
            const int expectedSize = 20 * 20;

            // Get a simple query we can "play" with
            var q     = new QueriableDummy <TestNtupe>();
            var dude  = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            // Ok, now we can actually see if we can make it "go".
            var exe    = new TTreeQueryExecutor(files, "dude", typeof(ntuple), typeof(TestNtupe));
            int result = exe.ExecuteScalar <int>(query);

            Assert.AreEqual(expectedSize, result);

            // We should have split this many files into the number of CPU's we have.
            Assert.AreEqual(Environment.ProcessorCount, exe.CountExecutionRuns);
        }
Exemple #8
0
        public void TestSimpleSingleQuery()
        {
            int numberOfIter = 10;

            var rootFile = TestUtils.CreateFileOfInt(numberOfIter);
            var q        = new QueriableDummy <TestNtupe>();
            var dude     = q.Count();
            var query    = DummyQueryExectuor.LastQueryModel;

            var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe));

            var result = exe.ExecuteScalarAsFuture <int>(query);

            Assert.IsNotNull(result, "future should exist!");
            Assert.IsFalse(result.HasValue, "future shoudl not have executed by now!");

            var val = result.Value;

            Assert.AreEqual(numberOfIter, val, "incorrect result came back.");
            Assert.IsTrue(result.HasValue, "value should be marked by now!");
        }
        public void RemoteBashCmdLineCheckDebugDumps()
        {
            // When we run in debug mode, make sure the command line dumps are there.
            var rootFile = TestUtils.CreateFileOfInt(20);

            // Get a simple query we can "play" with
            var q     = new QueriableDummy <TestNtupe>();
            var dude  = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            // Ok, now we can actually see if we can make it "go".
            var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe));

            // Capture the lines
            bool seenCacheInfo = false;

            CommandLineExecutor.AddLogEndpoint(s => seenCacheInfo |= s.ToLower().Contains("cache"));
            exe.CompileDebug = true;
            int result = exe.ExecuteScalar <int>(query);

            Assert.IsTrue(seenCacheInfo);
        }
        public void RemoteBashNoROOTFound()
        {
            try
            {
                // This should cause a hard fail.
                RemoteBashExecutor.ROOTVersionNumber = "22322";

                // Set it up to look for something else.

                var rootFile = TestUtils.CreateFileOfInt(20);

                // Get a simple query we can "play" with
                var q     = new QueriableDummy <TestNtupe>();
                var dude  = q.Count();
                var query = DummyQueryExectuor.LastQueryModel;

                // Ok, now we can actually see if we can make it "go".
                var exe    = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe));
                int result = exe.ExecuteScalar <int>(query);
            } catch (AggregateException exp)
            {
                throw exp.UnrollAggregateExceptions();
            }
        }
        public void TestLoadingCommonFiles()
        {
            /// Create a common C++ object that can be loaded and checked for.
            var d = PrepNonSpaceDir("TestLoadingCommonFiles");
            string fnamebase = "TestLoadingCommonFilesObj";
            var f = CreateCommonObject(fnamebase, d);

            ///
            /// Run a simple query - but fool it against another ntuple
            /// 

            var rootFile = TestUtils.CreateFileOfInt(1);
            var q = new QueriableDummy<TestNtupe>();
            var dude = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            ///
            /// First, make sure to clear out the common area. We are relying on the fact that we know
            /// where the common area is for this step.
            /// 

            var commonArea = new DirectoryInfo(Path.GetTempPath() + @"\LINQToROOT\CommonFiles");
            if (commonArea.Exists)
            {
                var filesToKill = (from fd in commonArea.EnumerateFiles()
                                   where fd.Name.Contains(fnamebase)
                                   select fd).ToArray();
                foreach (var theFile in filesToKill)
                {
                    theFile.Delete();
                }
            }

            ///
            /// Setup all the files we will have to have!
            /// 

            ///
            /// Generate a proxy .h file that we can use
            /// 

            var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude");
            ntuple._gProxyFile = proxyFile.FullName;
            ntuple._gObjectFiles = new string[] { f.FullName };

            ///
            /// Now run
            /// 

            var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe));
            int result = exe.ExecuteScalar<int>(query);

            Assert.AreEqual(1, result, "The result should have run correctly.");

            ///
            /// Next, see if we can find the files in the common area.
            /// 

            commonArea.Refresh();
            Assert.IsTrue(commonArea.Exists, string.Format("The common build area doesn't exist currently ({0}).", commonArea.FullName));
            var filesFromOurObj = (from fd in commonArea.EnumerateFiles()
                                   where fd.Name.Contains(fnamebase)
                                   select fd).ToArray();
            Assert.IsTrue(filesFromOurObj.Length > 0, "no files from our common object");
        }
        public void TestDualQueryOnSameQueriable()
        {
            var rootFile = TestUtils.CreateFileOfInt(5);

            ///
            /// Generate a proxy .h file that we can use
            /// 

            var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude");

            ///
            /// Get a simple query we can "play" with
            /// 

            var q = new QueriableDummy<TestNtupe>();
            var dude = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            ///
            /// Ok, now we can actually see if we can make it "go".
            /// 

            ntuple._gProxyFile = proxyFile.FullName;
            var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe));
            int result = exe.ExecuteScalar<int>(query);

            ///
            /// Run the second one now
            /// 

            var dude1 = q.Where(e => e.run > 10).Count();
            query = DummyQueryExectuor.LastQueryModel;
            result = exe.ExecuteScalar<int>(query);
        }
        public void TestTempDirectoryLocationAndEmptying()
        {
            var rootFile = TestUtils.CreateFileOfInt(1);

            ///
            /// Get a simple query we can "play" with
            /// 

            var q = new QueriableDummy<TestNtupe>();
            var dude = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            ///
            /// Generate a proxy .h file that we can use
            /// 

            var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude");
            ntuple._gProxyFile = proxyFile.FullName;

            ///
            /// Ok, now we can actually see if we can make it "go".
            /// 

            var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe));
            int result = exe.ExecuteScalar<int>(query);

            var dir = new DirectoryInfo(Path.GetTempPath() + "\\LINQToROOT"); ;
            dir.Refresh();
            Assert.IsTrue(dir.Exists, "Temp directory doesn't exist");
            Assert.AreEqual(0, dir.EnumerateFiles().Count(), "Expected no spare files in there!");
            Assert.AreEqual(2, dir.EnumerateDirectories().Count(), "Incorrect # of subdirectories");
            Assert.AreEqual("CommonFiles", dir.GetDirectories()[0].Name, "incorrect name of single existing directory");
        }
        public void TestForZeroInputFiles()
        {
            var rootFile = TestUtils.CreateFileOfInt(5);

            ///
            /// Generate a proxy .h file that we can use
            /// 

            var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude");

            ///
            /// Get a simple query we can "play" with
            /// 

            var q = new QueriableDummy<TestNtupe>();
            var dude = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            ///
            /// Ok, now we can actually see if we can make it "go".
            /// 

            ntuple._gProxyFile = proxyFile.FullName;
            var exe = new TTreeQueryExecutor(new Uri[] { }, "dude", typeof(ntuple));
            int result = exe.ExecuteScalar<int>(query);
        }
        public void TestSimpleResultDebugCompile()
        {
            var rootFile = TestUtils.CreateFileOfInt(10);

            ///
            /// Generate a proxy .h file that we can use
            /// 

            var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude");

            ///
            /// Get a simple query we can "play" with
            /// 

            var q = new QueriableDummy<TestNtupe>();
            var dude = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            ///
            /// Ok, now we can actually see if we can make it "go".
            /// 

            ntuple._gProxyFile = proxyFile.FullName;
            var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe));
            exe.CompileDebug = true;
            int result = exe.ExecuteScalar<int>(query);
            Assert.AreEqual(10, result);
        }
        public void TestSimpleReultOperatorNtupleOkButBogusProxyPath()
        {
            int numberOfIter = 10;

            var rootFile = TestUtils.CreateFileOfInt(numberOfIter);

            ///
            /// Get a simple query we can "play" with
            /// 

            var q = new QueriableDummy<TestNtupe>();
            var dude = q.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            ///
            /// Ok, now we can actually see if we can make it "go".
            /// 

            ntuple._gProxyFile = "junk.cppxdude";
            var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple));
            int result = exe.ExecuteScalar<int>(query);
            Assert.AreEqual(numberOfIter, result);
        }