Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo n.º 3
0
        public void RunAzureTest()
        {
            var connectionInfo = ConfigurationManager.AppSettings[AzureConnectionStringKey];
            var containerName = ConfigurationManager.AppSettings[AzureContainerName];
            var account = CloudStorageAccount.Parse(ConfigurationManager.AppSettings[AzureConnectionStringKey]);
            var container = account.CreateCloudBlobClient().GetContainerReference(containerName);
            if (connectionInfo.StartsWith("UseDevelopmentStorage=true"))
            {
                container.CreateIfNotExists();
            }
            Assert.IsTrue(container.Exists());

            // Clean the container
            var bundleIds = new List<string>();
            bundleIds.AddRange(inputBundleIds);
            bundleIds.AddRange(outputBundleIds);
            DeleteBlobsIfExists(container, bundleIds);

            string azureStorePath = Path.Combine(_context.TestRunDirectory, @"RunAzureTestBlobs");
            Directory.CreateDirectory(azureStorePath);
            AzureBundleStore azureStore = new AzureBundleStore(container, azureStorePath);
            for (int i = 0; i < inputBundleIds.Length; i++)
            {
                string bundleId = inputBundleIds[i];
                Assert.IsFalse(azureStore.HasReference(bundleId));
                string bundlePath = Path.Combine(Test1.TestDataParentPath, inputBundlePaths[i]);
                azureStore.PutReference(bundleId, bundlePath);
                Assert.IsTrue(azureStore.HasReference(bundleId));
                var bundleRef = azureStore.GetReference(bundleId);
                Assert.IsNotNull(bundleRef.Value);
            }

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

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

            var runId = inputBundleIds[2];
            var outputId = outputBundleIds[0];
            Assert.IsFalse(bundleSvc.Has(outputId));

            Run.executeIt(bundleSvc, runId, AzureDiagnostics.get(container));

            Assert.IsTrue(bundleSvc.Has(outputId));
            Assert.IsTrue(azureStore.HasReference(outputId));
            var outputRef = azureStore.GetReference(outputId);
            Assert.IsTrue(outputRef.Value.IsZipBundle);
            var blobOutput = container.GetBlockBlobReference(outputId);
            Assert.IsTrue(blobOutput.Exists());

            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 stdoutId = outputBundleIds[1];
            var blobStdout = container.GetBlockBlobReference(stdoutId);
            Assert.IsTrue(blobStdout.Exists());
            var stderrId = outputBundleIds[2];
            var blobStderr = container.GetBlockBlobReference(stderrId);
            Assert.IsFalse(blobStderr.Exists()); // does not exist because nothing was written to std error

            DeleteBlobsIfExists(container, bundleIds);
        }
Ejemplo n.º 4
0
        public void RunAzureTest()
        {
            var connectionInfo = ConfigurationManager.AppSettings[AzureConnectionStringKey];
            var containerName  = ConfigurationManager.AppSettings[AzureContainerName];
            var account        = CloudStorageAccount.Parse(ConfigurationManager.AppSettings[AzureConnectionStringKey]);
            var container      = account.CreateCloudBlobClient().GetContainerReference(containerName);

            if (connectionInfo.StartsWith("UseDevelopmentStorage=true"))
            {
                container.CreateIfNotExists();
            }
            Assert.IsTrue(container.Exists());

            // Clean the container
            var bundleIds = new List <string>();

            bundleIds.AddRange(inputBundleIds);
            bundleIds.AddRange(outputBundleIds);
            DeleteBlobsIfExists(container, bundleIds);

            string azureStorePath = Path.Combine(_context.TestRunDirectory, @"RunAzureTestBlobs");

            Directory.CreateDirectory(azureStorePath);
            AzureBundleStore azureStore = new AzureBundleStore(container, azureStorePath);

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

            BundleStore store = azureStore.GetStore();

            Assert.IsNotNull(store);

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

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

            var runId    = inputBundleIds[2];
            var outputId = outputBundleIds[0];

            Assert.IsFalse(bundleSvc.Has(outputId));

            Run.executeIt(bundleSvc, runId, AzureDiagnostics.get(container));

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

            Assert.IsTrue(outputRef.Value.IsZipBundle);
            var blobOutput = container.GetBlockBlobReference(outputId);

            Assert.IsTrue(blobOutput.Exists());

            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 stdoutId   = outputBundleIds[1];
            var blobStdout = container.GetBlockBlobReference(stdoutId);

            Assert.IsTrue(blobStdout.Exists());
            var stderrId   = outputBundleIds[2];
            var blobStderr = container.GetBlockBlobReference(stderrId);

            Assert.IsFalse(blobStderr.Exists()); // does not exist because nothing was written to std error

            DeleteBlobsIfExists(container, bundleIds);
        }