Exemple #1
0
        public virtual void TestPositiveNewHarFsOnTheSameUnderlyingFs()
        {
            // Init 2nd har file system on the same underlying FS, so the
            // metadata gets reused:
            HarFileSystem hfs = new HarFileSystem(localFileSystem);
            URI           uri = new URI("har://" + harPath.ToString());

            hfs.Initialize(uri, new Configuration());
            // the metadata should be reused from cache:
            Assert.True(hfs.GetMetadata() == harFileSystem.GetMetadata());
        }
Exemple #2
0
        public virtual void TestNegativeInitWithAnUnsupportedVersion()
        {
            // NB: should wait at least 1 second to ensure the timestamp of the master
            // index will change upon the writing, because Linux seems to update the
            // file modification
            // time with 1 second accuracy:
            Thread.Sleep(1000);
            // write an unsupported version:
            WriteVersionToMasterIndexImpl(7777, new Path(harPath, "_masterindex"));
            // init the Har:
            HarFileSystem hfs = new HarFileSystem(localFileSystem);

            // the metadata should *not* be reused from cache:
            NUnit.Framework.Assert.IsFalse(hfs.GetMetadata() == harFileSystem.GetMetadata());
            URI uri = new URI("har://" + harPath.ToString());

            try
            {
                hfs.Initialize(uri, new Configuration());
                NUnit.Framework.Assert.Fail("IOException expected.");
            }
            catch (IOException)
            {
            }
        }
Exemple #3
0
        public virtual void TestPositiveLruMetadataCacheFs()
        {
            // Init 2nd har file system on the same underlying FS, so the
            // metadata gets reused:
            HarFileSystem hfs = new HarFileSystem(localFileSystem);
            URI           uri = new URI("har://" + harPath.ToString());

            hfs.Initialize(uri, new Configuration());
            // the metadata should be reused from cache:
            Assert.True(hfs.GetMetadata() == harFileSystem.GetMetadata());
            // Create more hars, until the cache is full + 1; the last creation should evict the first entry from the cache
            for (int i = 0; i <= hfs.MetadataCacheEntriesDefault; i++)
            {
                Path p = new Path(rootPath, "path1/path2/my" + i + ".har");
                CreateHarFileSystem(conf, p);
            }
            // The first entry should not be in the cache anymore:
            hfs = new HarFileSystem(localFileSystem);
            uri = new URI("har://" + harPath.ToString());
            hfs.Initialize(uri, new Configuration());
            Assert.True(hfs.GetMetadata() != harFileSystem.GetMetadata());
        }