Beispiel #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestInterruptOnDisk()
        {
            int           Fetcher = 7;
            Path          p       = new Path("file:///tmp/foo");
            Path          pTmp    = OnDiskMapOutput.GetTempPath(p, Fetcher);
            FileSystem    mFs     = Org.Mockito.Mockito.Mock <FileSystem>(ReturnsDeepStubs);
            MapOutputFile mof     = Org.Mockito.Mockito.Mock <MapOutputFile>();

            Org.Mockito.Mockito.When(mof.GetInputFileForWrite(Matchers.Any <TaskID>(), Matchers.AnyLong
                                                                  ())).ThenReturn(p);
            OnDiskMapOutput <Text, Text> odmo = Org.Mockito.Mockito.Spy(new OnDiskMapOutput <Text
                                                                                             , Text>(map1ID, id, mm, 100L, job, mof, Fetcher, true, mFs, p));

            Org.Mockito.Mockito.When(mm.Reserve(Matchers.Any <TaskAttemptID>(), Matchers.AnyLong
                                                    (), Matchers.AnyInt())).ThenReturn(odmo);
            Org.Mockito.Mockito.DoNothing().When(mm).WaitForResource();
            Org.Mockito.Mockito.When(ss.GetHost()).ThenReturn(host);
            string replyHash = SecureShuffleUtils.GenerateHash(Sharpen.Runtime.GetBytesForString
                                                                   (encHash), key);

            Org.Mockito.Mockito.When(connection.GetResponseCode()).ThenReturn(200);
            Org.Mockito.Mockito.When(connection.GetHeaderField(SecureShuffleUtils.HttpHeaderReplyUrlHash
                                                               )).ThenReturn(replyHash);
            ShuffleHeader         header = new ShuffleHeader(map1ID.ToString(), 10, 10, 1);
            ByteArrayOutputStream bout   = new ByteArrayOutputStream();

            header.Write(new DataOutputStream(bout));
            TestFetcher.StuckInputStream @in = new TestFetcher.StuckInputStream(new ByteArrayInputStream
                                                                                    (bout.ToByteArray()));
            Org.Mockito.Mockito.When(connection.GetInputStream()).ThenReturn(@in);
            Org.Mockito.Mockito.When(connection.GetHeaderField(ShuffleHeader.HttpHeaderName))
            .ThenReturn(ShuffleHeader.DefaultHttpHeaderName);
            Org.Mockito.Mockito.When(connection.GetHeaderField(ShuffleHeader.HttpHeaderVersion
                                                               )).ThenReturn(ShuffleHeader.DefaultHttpHeaderVersion);
            Org.Mockito.Mockito.DoAnswer(new _Answer_610(@in)).When(connection).Disconnect();
            Fetcher <Text, Text> underTest = new TestFetcher.FakeFetcher <Text, Text>(job, id,
                                                                                      ss, mm, r, metrics, except, key, connection, Fetcher);

            underTest.Start();
            // wait for read in inputstream
            @in.WaitForFetcher();
            underTest.ShutDown();
            underTest.Join();
            // rely on test timeout to kill if stuck
            NUnit.Framework.Assert.IsTrue(@in.WasClosedProperly());
            Org.Mockito.Mockito.Verify(mFs).Create(Matchers.Eq(pTmp));
            Org.Mockito.Mockito.Verify(mFs).Delete(Matchers.Eq(pTmp), Matchers.Eq(false));
            Org.Mockito.Mockito.Verify(odmo).Abort();
        }
Beispiel #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestInterruptInMemory()
        {
            int Fetcher = 2;
            InMemoryMapOutput <Text, Text> immo = Org.Mockito.Mockito.Spy(new InMemoryMapOutput
                                                                          <Text, Text>(job, id, mm, 100, null, true));

            Org.Mockito.Mockito.When(mm.Reserve(Matchers.Any <TaskAttemptID>(), Matchers.AnyLong
                                                    (), Matchers.AnyInt())).ThenReturn(immo);
            Org.Mockito.Mockito.DoNothing().When(mm).WaitForResource();
            Org.Mockito.Mockito.When(ss.GetHost()).ThenReturn(host);
            string replyHash = SecureShuffleUtils.GenerateHash(Sharpen.Runtime.GetBytesForString
                                                                   (encHash), key);

            Org.Mockito.Mockito.When(connection.GetResponseCode()).ThenReturn(200);
            Org.Mockito.Mockito.When(connection.GetHeaderField(ShuffleHeader.HttpHeaderName))
            .ThenReturn(ShuffleHeader.DefaultHttpHeaderName);
            Org.Mockito.Mockito.When(connection.GetHeaderField(ShuffleHeader.HttpHeaderVersion
                                                               )).ThenReturn(ShuffleHeader.DefaultHttpHeaderVersion);
            Org.Mockito.Mockito.When(connection.GetHeaderField(SecureShuffleUtils.HttpHeaderReplyUrlHash
                                                               )).ThenReturn(replyHash);
            ShuffleHeader         header = new ShuffleHeader(map1ID.ToString(), 10, 10, 1);
            ByteArrayOutputStream bout   = new ByteArrayOutputStream();

            header.Write(new DataOutputStream(bout));
            TestFetcher.StuckInputStream @in = new TestFetcher.StuckInputStream(new ByteArrayInputStream
                                                                                    (bout.ToByteArray()));
            Org.Mockito.Mockito.When(connection.GetInputStream()).ThenReturn(@in);
            Org.Mockito.Mockito.DoAnswer(new _Answer_562(@in)).When(connection).Disconnect();
            Fetcher <Text, Text> underTest = new TestFetcher.FakeFetcher <Text, Text>(job, id,
                                                                                      ss, mm, r, metrics, except, key, connection, Fetcher);

            underTest.Start();
            // wait for read in inputstream
            @in.WaitForFetcher();
            underTest.ShutDown();
            underTest.Join();
            // rely on test timeout to kill if stuck
            NUnit.Framework.Assert.IsTrue(@in.WasClosedProperly());
            Org.Mockito.Mockito.Verify(immo).Abort();
        }
Beispiel #3
0
 public _Answer_610(TestFetcher.StuckInputStream @in)
 {
     this.@in = @in;
 }