mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	readContainerFileWithExec for links tests
Shout out to @estesp for the idea. Some use cases of `readContainerFile` can be replaced with `docker exec $id cat $file`. This helper method can eliminate the requirement that host/cli should be on the same machine. TestRunMutableNetworkFiles and TestRunResolvconfUpdater still need to access the docker host filesystem as they modify the file directly from there assuming cli and daemon are on the same machine. This fixes TestLinksUpdateOnRestart and TestLinksHostsFilesInject for Windows CI. Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
This commit is contained in:
		
							parent
							
								
									b062ef05e5
								
							
						
					
					
						commit
						6bbb456138
					
				
					 2 changed files with 9 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -251,12 +251,12 @@ func TestLinksHostsFilesInject(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
	time.Sleep(1 * time.Second)
 | 
			
		||||
 | 
			
		||||
	contentOne, err := readContainerFile(idOne, "hosts")
 | 
			
		||||
	contentOne, err := readContainerFileWithExec(idOne, "/etc/hosts")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err, string(contentOne))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	contentTwo, err := readContainerFile(idTwo, "hosts")
 | 
			
		||||
	contentTwo, err := readContainerFileWithExec(idTwo, "/etc/hosts")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err, string(contentTwo))
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -302,7 +302,7 @@ func TestLinksUpdateOnRestart(t *testing.T) {
 | 
			
		|||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	content, err := readContainerFile(id, "hosts")
 | 
			
		||||
	content, err := readContainerFileWithExec(id, "/etc/hosts")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err, string(content))
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -327,7 +327,7 @@ func TestLinksUpdateOnRestart(t *testing.T) {
 | 
			
		|||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	content, err = readContainerFile(id, "hosts")
 | 
			
		||||
	content, err = readContainerFileWithExec(id, "/etc/hosts")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err, string(content))
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -895,6 +895,11 @@ func readContainerFile(containerId, filename string) ([]byte, error) {
 | 
			
		|||
	return content, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func readContainerFileWithExec(containerId, filename string) ([]byte, error) {
 | 
			
		||||
	out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "exec", containerId, "cat", filename))
 | 
			
		||||
	return []byte(out), err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func setupRegistry(t *testing.T) func() {
 | 
			
		||||
	reg, err := newTestRegistryV2(t)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue