mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	provide more information when TestTop tests fail
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
		
							parent
							
								
									2d6f537bb3
								
							
						
					
					
						commit
						3ac90aeed5
					
				
					 1 changed files with 20 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -18,14 +18,22 @@ func TestTopNonPrivileged(t *testing.T) {
 | 
			
		|||
	out, _, err = runCommandWithOutput(topCmd)
 | 
			
		||||
	errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out, err))
 | 
			
		||||
 | 
			
		||||
	topCmd = exec.Command(dockerBinary, "top", cleanedContainerID)
 | 
			
		||||
	out2, _, err2 := runCommandWithOutput(topCmd)
 | 
			
		||||
	errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out2, err2))
 | 
			
		||||
 | 
			
		||||
	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
 | 
			
		||||
	_, err = runCommand(killCmd)
 | 
			
		||||
	errorOut(err, t, fmt.Sprintf("failed to kill container: %v", err))
 | 
			
		||||
 | 
			
		||||
	deleteContainer(cleanedContainerID)
 | 
			
		||||
 | 
			
		||||
	if !strings.Contains(out, "sleep 20") {
 | 
			
		||||
		t.Fatal("top should've listed sleep 20 in the process list")
 | 
			
		||||
	if !strings.Contains(out, "sleep 20") && !strings.Contains(out2, "sleep 20") {
 | 
			
		||||
		t.Fatal("top should've listed `sleep 20` in the process list, but failed twice")
 | 
			
		||||
	} else if !strings.Contains(out, "sleep 20") {
 | 
			
		||||
		t.Fatal("top should've listed `sleep 20` in the process list, but failed the first time")
 | 
			
		||||
	} else if !strings.Contains(out2, "sleep 20") {
 | 
			
		||||
		t.Fatal("top should've listed `sleep 20` in the process list, but failed the second itime")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logDone("top - sleep process should be listed in non privileged mode")
 | 
			
		||||
| 
						 | 
				
			
			@ -42,14 +50,22 @@ func TestTopPrivileged(t *testing.T) {
 | 
			
		|||
	out, _, err = runCommandWithOutput(topCmd)
 | 
			
		||||
	errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out, err))
 | 
			
		||||
 | 
			
		||||
	topCmd = exec.Command(dockerBinary, "top", cleanedContainerID)
 | 
			
		||||
	out2, _, err2 := runCommandWithOutput(topCmd)
 | 
			
		||||
	errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out2, err2))
 | 
			
		||||
 | 
			
		||||
	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
 | 
			
		||||
	_, err = runCommand(killCmd)
 | 
			
		||||
	errorOut(err, t, fmt.Sprintf("failed to kill container: %v", err))
 | 
			
		||||
 | 
			
		||||
	deleteContainer(cleanedContainerID)
 | 
			
		||||
 | 
			
		||||
	if !strings.Contains(out, "sleep 20") {
 | 
			
		||||
		t.Fatal("top should've listed sleep 20 in the process list")
 | 
			
		||||
	if !strings.Contains(out, "sleep 20") && !strings.Contains(out2, "sleep 20") {
 | 
			
		||||
		t.Fatal("top should've listed `sleep 20` in the process list, but failed twice")
 | 
			
		||||
	} else if !strings.Contains(out, "sleep 20") {
 | 
			
		||||
		t.Fatal("top should've listed `sleep 20` in the process list, but failed the first time")
 | 
			
		||||
	} else if !strings.Contains(out2, "sleep 20") {
 | 
			
		||||
		t.Fatal("top should've listed `sleep 20` in the process list, but failed the second itime")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logDone("top - sleep process should be listed in privileged mode")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue