public async Task TestBuildAsync() { SystemPath layerDirectory = Paths.Get(TestResources.GetResource("core/layer").ToURI()); SystemPath blobA = Paths.Get(TestResources.GetResource("core/blobA").ToURI()); ReproducibleLayerBuilder layerBuilder = new ReproducibleLayerBuilder( LayerConfiguration.CreateBuilder() .AddEntryRecursive( layerDirectory, AbsoluteUnixPath.Get("/extract/here/apple/layer")) .AddEntry(blobA, AbsoluteUnixPath.Get("/extract/here/apple/blobA")) .AddEntry(blobA, AbsoluteUnixPath.Get("/extract/here/banana/blobA")) .Build() .LayerEntries); // Writes the layer tar to a temporary file. IBlob unwrittenBlob = layerBuilder.Build(); SystemPath temporaryFile = temporaryFolder.NewFile().ToPath(); using (Stream temporaryFileOutputStream = new BufferedStream(Files.NewOutputStream(temporaryFile))) { await unwrittenBlob.WriteToAsync(temporaryFileOutputStream).ConfigureAwait(false); } // Reads the file back. TarInputStream tarArchiveInputStream = new TarInputStream(Files.NewInputStream(temporaryFile)); VerifyNextTarArchiveEntryIsDirectory(tarArchiveInputStream, "extract/"); VerifyNextTarArchiveEntryIsDirectory(tarArchiveInputStream, "extract/here/"); VerifyNextTarArchiveEntryIsDirectory(tarArchiveInputStream, "extract/here/apple/"); VerifyNextTarArchiveEntry(tarArchiveInputStream, "extract/here/apple/blobA", blobA); VerifyNextTarArchiveEntryIsDirectory(tarArchiveInputStream, "extract/here/apple/layer/"); VerifyNextTarArchiveEntryIsDirectory(tarArchiveInputStream, "extract/here/apple/layer/a/"); VerifyNextTarArchiveEntryIsDirectory(tarArchiveInputStream, "extract/here/apple/layer/a/b/"); VerifyNextTarArchiveEntry( tarArchiveInputStream, "extract/here/apple/layer/a/b/bar", Paths.Get(TestResources.GetResource("core/layer/a/b/bar").ToURI())); VerifyNextTarArchiveEntryIsDirectory(tarArchiveInputStream, "extract/here/apple/layer/c/"); VerifyNextTarArchiveEntry( tarArchiveInputStream, "extract/here/apple/layer/c/cat", Paths.Get(TestResources.GetResource("core/layer/c/cat").ToURI())); VerifyNextTarArchiveEntry( tarArchiveInputStream, "extract/here/apple/layer/foo", Paths.Get(TestResources.GetResource("core/layer/foo").ToURI())); VerifyNextTarArchiveEntryIsDirectory(tarArchiveInputStream, "extract/here/banana/"); VerifyNextTarArchiveEntry(tarArchiveInputStream, "extract/here/banana/blobA", blobA); }
/// <exception cref="System.IO.IOException"/> public virtual void TestTruncatedFSImage() { FilePath truncatedFile = folder.NewFile(); TextWriter output = new TextWriter(NullOutputStream.NullOutputStream); CopyPartOfFile(originalFsimage, truncatedFile); new FileDistributionCalculator(new Configuration(), 0, 0, output).Visit(new RandomAccessFile (truncatedFile, "r")); }
public virtual void TestGenerated() { // edits generated by nnHelper (MiniDFSCluster), should have all op codes // binary, XML, reparsed binary string edits = nnHelper.GenerateEdits(); Log.Info("Generated edits=" + edits); string editsParsedXml = folder.NewFile("editsParsed.xml").GetAbsolutePath(); string editsReparsed = folder.NewFile("editsParsed").GetAbsolutePath(); // parse to XML then back to binary NUnit.Framework.Assert.AreEqual(0, RunOev(edits, editsParsedXml, "xml", false)); NUnit.Framework.Assert.AreEqual(0, RunOev(editsParsedXml, editsReparsed, "binary" , false)); // judgment time NUnit.Framework.Assert.IsTrue("Edits " + edits + " should have all op codes", HasAllOpCodes (edits)); Log.Info("Comparing generated file " + editsReparsed + " with reference file " + edits); NUnit.Framework.Assert.IsTrue("Generated edits and reparsed (bin to XML to bin) should be same" , FilesEqualIgnoreTrailingZeros(edits, editsReparsed)); }
public void TestWithDirectory_existsButNotDirectory() { SystemPath file = temporaryFolder.NewFile().ToPath(); try { LayersCache.WithDirectory(file); Assert.Fail(); } catch (IOException) { // pass } }