Esempio n. 1
0
        public void RunLocalTest()
        {
            LocalBundleStore localStore = new LocalBundleStore();

            for (int i = 0; i < inputBundleIds.Length; i++)
            {
                string bundleId = inputBundleIds[i];
                Assert.IsFalse(localStore.HasReference(bundleId));
                string bundlePath = Path.Combine(Test1.TestDataParentPath, inputBundlePaths[i]);
                localStore.PutReference(bundleId, bundlePath);
                Assert.IsTrue(localStore.HasReference(bundleId));
                var bundleRef = localStore.GetReference(bundleId);
                Assert.IsNotNull(bundleRef.Value);
            }

            BundleStore store = localStore.GetStore();

            Assert.IsNotNull(store);

            string bundleSvcPath = Path.Combine(_context.TestRunDirectory, @"RunLocalTestBundles");

            Directory.CreateDirectory(bundleSvcPath);
            BundleService bundleSvc = new BundleService(store, bundleSvcPath, false);

            var runId    = inputBundleIds[2];
            var outputId = runId.Substring(0, runId.Length - Path.GetExtension(runId).Length) + @"/output.zip";

            Assert.AreEqual(outputId, outputBundleIds[0]);
            Assert.IsFalse(bundleSvc.Has(outputId));

            Run.executeIt(bundleSvc, runId, LocalDiagnostics.get());

            Assert.IsTrue(bundleSvc.Has(outputId));
            Assert.IsTrue(localStore.HasReference(outputId));
            var outputRef = localStore.GetReference(outputId);

            Assert.IsTrue(outputRef.Value.IsZipBundle);

            var outputBundle = bundleSvc.Get(outputId);

            Assert.IsNotNull(outputBundle);
            var scorepath = Path.Combine(outputBundle.AbsolutePath, @"scores.txt");

            Assert.IsTrue(File.Exists(scorepath));
            string[] lines = File.ReadAllLines(scorepath);
            Assert.AreEqual(1, lines.Length);
            string[] line1Parts = lines[0].Split(':');
            Assert.AreEqual(2, line1Parts.Length);
            Assert.AreEqual("Difference", line1Parts[0].Trim());
            Assert.AreEqual("0.041593", line1Parts[1].Trim());

            var stdoutPath = Path.Combine(bundleSvcPath, @"competition1\submission1\run\stdout.txt");

            Assert.IsTrue(File.Exists(scorepath));
            var stderrPath = Path.Combine(bundleSvcPath, @"competition1\submission1\run\stderr.txt");

            Assert.IsTrue(File.Exists(scorepath));
        }
Esempio n. 2
0
        public void RunLocalTest()
        {
            LocalBundleStore localStore = new LocalBundleStore();
            for (int i = 0; i < inputBundleIds.Length; i++)
            {
                string bundleId = inputBundleIds[i];
                Assert.IsFalse(localStore.HasReference(bundleId));
                string bundlePath = Path.Combine(Test1.TestDataParentPath, inputBundlePaths[i]);
                localStore.PutReference(bundleId, bundlePath);
                Assert.IsTrue(localStore.HasReference(bundleId));
                var bundleRef = localStore.GetReference(bundleId);
                Assert.IsNotNull(bundleRef.Value);
            }

            BundleStore store = localStore.GetStore();
            Assert.IsNotNull(store);

            string bundleSvcPath = Path.Combine(_context.TestRunDirectory, @"RunLocalTestBundles");
            Directory.CreateDirectory(bundleSvcPath);
            BundleService bundleSvc = new BundleService(store, bundleSvcPath, false);

            var runId = inputBundleIds[2];
            var outputId = runId.Substring(0, runId.Length - Path.GetExtension(runId).Length) + @"/output.zip";
            Assert.AreEqual(outputId, outputBundleIds[0]);
            Assert.IsFalse(bundleSvc.Has(outputId));

            Run.executeIt(bundleSvc, runId, LocalDiagnostics.get());

            Assert.IsTrue(bundleSvc.Has(outputId));
            Assert.IsTrue(localStore.HasReference(outputId));
            var outputRef = localStore.GetReference(outputId);
            Assert.IsTrue(outputRef.Value.IsZipBundle);

            var outputBundle = bundleSvc.Get(outputId);
            Assert.IsNotNull(outputBundle);
            var scorepath = Path.Combine(outputBundle.AbsolutePath, @"scores.txt");
            Assert.IsTrue(File.Exists(scorepath));
            string[] lines = File.ReadAllLines(scorepath);
            Assert.AreEqual(1, lines.Length);
            string[] line1Parts = lines[0].Split(':');
            Assert.AreEqual(2, line1Parts.Length);
            Assert.AreEqual("Difference", line1Parts[0].Trim());
            Assert.AreEqual("0.041593", line1Parts[1].Trim());

            var stdoutPath = Path.Combine(bundleSvcPath, @"competition1\submission1\run\stdout.txt");
            Assert.IsTrue(File.Exists(scorepath));
            var stderrPath = Path.Combine(bundleSvcPath, @"competition1\submission1\run\stderr.txt");
            Assert.IsTrue(File.Exists(scorepath));
        }