mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Change reading order of tailfile
change reading order from beginning at the end to beginning at a buffer start added intergration tests for boundary cases Removed whitespace Signed-off-by: Shayne Wang <shaynexwang@gmail.com>
This commit is contained in:
		
							parent
							
								
									89c4410799
								
							
						
					
					
						commit
						19c16fd95e
					
				
					 2 changed files with 13 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -117,22 +117,28 @@ func (s *DockerSuite) TestLogsTail(c *check.C) {
 | 
			
		|||
	id := strings.TrimSpace(out)
 | 
			
		||||
	dockerCmd(c, "wait", id)
 | 
			
		||||
 | 
			
		||||
	out, _ = dockerCmd(c, "logs", "--tail", "5", id)
 | 
			
		||||
 | 
			
		||||
	out, _ = dockerCmd(c, "logs", "--tail", "0", id)
 | 
			
		||||
	lines := strings.Split(out, "\n")
 | 
			
		||||
	c.Assert(lines, checker.HasLen, 1)
 | 
			
		||||
 | 
			
		||||
	out, _ = dockerCmd(c, "logs", "--tail", "5", id)
 | 
			
		||||
	lines = strings.Split(out, "\n")
 | 
			
		||||
	c.Assert(lines, checker.HasLen, 6)
 | 
			
		||||
 | 
			
		||||
	out, _ = dockerCmd(c, "logs", "--tail", "all", id)
 | 
			
		||||
 | 
			
		||||
	out, _ = dockerCmd(c, "logs", "--tail", "99", id)
 | 
			
		||||
	lines = strings.Split(out, "\n")
 | 
			
		||||
	c.Assert(lines, checker.HasLen, 100)
 | 
			
		||||
 | 
			
		||||
	out, _ = dockerCmd(c, "logs", "--tail", "all", id)
 | 
			
		||||
	lines = strings.Split(out, "\n")
 | 
			
		||||
	c.Assert(lines, checker.HasLen, testLen+1)
 | 
			
		||||
 | 
			
		||||
	out, _ = dockerCmd(c, "logs", "--tail", "-1", id)
 | 
			
		||||
	lines = strings.Split(out, "\n")
 | 
			
		||||
	c.Assert(lines, checker.HasLen, testLen+1)
 | 
			
		||||
 | 
			
		||||
	out, _, _ = dockerCmdWithStdoutStderr(c, "logs", "--tail", "random", id)
 | 
			
		||||
 | 
			
		||||
	lines = strings.Split(out, "\n")
 | 
			
		||||
 | 
			
		||||
	c.Assert(lines, checker.HasLen, testLen+1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,7 +44,7 @@ func TailFile(f io.ReadSeeker, n int) ([][]byte, error) {
 | 
			
		|||
			break
 | 
			
		||||
		} else {
 | 
			
		||||
			b = make([]byte, blockSize)
 | 
			
		||||
			if _, err := f.Seek(step, os.SEEK_END); err != nil {
 | 
			
		||||
			if _, err := f.Seek(left, os.SEEK_SET); err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
			if _, err := f.Read(b); err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue