mirror of
				https://github.com/docker/compose.git
				synced 2025-10-30 10:43:49 +01:00 
			
		
		
		
	Add moby backend e2e tests
This commit is contained in:
		
							parent
							
								
									2dd98e8a74
								
							
						
					
					
						commit
						1c3673c421
					
				
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @ -44,7 +44,7 @@ cli: ## Compile the cli | |||||||
| 	--target cli | 	--target cli | ||||||
| 
 | 
 | ||||||
| e2e-local: ## Run End to end local tests
 | e2e-local: ## Run End to end local tests
 | ||||||
| 	go test -v ./tests/e2e | 	go test -v ./tests/e2e ./moby/e2e | ||||||
| 
 | 
 | ||||||
| e2e-aci: ## Run End to end ACI tests (requires azure login)
 | e2e-aci: ## Run End to end ACI tests (requires azure login)
 | ||||||
| 	go test -v ./tests/aci-e2e | 	go test -v ./tests/aci-e2e | ||||||
|  | |||||||
| @ -3,7 +3,6 @@ package moby | |||||||
| import ( | import ( | ||||||
| 	"bufio" | 	"bufio" | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" |  | ||||||
| 	"io" | 	"io" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"time" | 	"time" | ||||||
| @ -108,8 +107,9 @@ func (ms *mobyService) Run(ctx context.Context, r containers.ContainerConfig) er | |||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
| 			scanner := bufio.NewScanner(io) | 			scanner := bufio.NewScanner(io) | ||||||
|  | 
 | ||||||
|  | 			// Read the whole body, otherwise the pulling stops | ||||||
| 			for scanner.Scan() { | 			for scanner.Scan() { | ||||||
| 				fmt.Println(string(scanner.Bytes())) |  | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if err = scanner.Err(); err != nil { | 			if err = scanner.Err(); err != nil { | ||||||
|  | |||||||
							
								
								
									
										56
									
								
								moby/e2e/backend_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								moby/e2e/backend_test.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | |||||||
|  | package e2e | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"strings" | ||||||
|  | 	"testing" | ||||||
|  | 
 | ||||||
|  | 	"github.com/stretchr/testify/assert" | ||||||
|  | 	"github.com/stretchr/testify/require" | ||||||
|  | 	"github.com/stretchr/testify/suite" | ||||||
|  | 
 | ||||||
|  | 	"github.com/docker/api/tests/framework" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | type MobyBackendTestSuite struct { | ||||||
|  | 	framework.Suite | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (m *MobyBackendTestSuite) BeforeTest(suiteName string, testName string) { | ||||||
|  | 	m.NewDockerCommand("context", "create", "test-context", "moby").ExecOrDie() | ||||||
|  | 	m.NewDockerCommand("context", "use", "test-context").ExecOrDie() | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (m *MobyBackendTestSuite) AfterTest(suiteName string, testName string) { | ||||||
|  | 	m.NewDockerCommand("context", "rm", "test-context").ExecOrDie() | ||||||
|  | 	m.NewDockerCommand("context", "use", "default").ExecOrDie() | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (m *MobyBackendTestSuite) TestPs() { | ||||||
|  | 	out := m.NewDockerCommand("ps").ExecOrDie() | ||||||
|  | 	require.Equal(m.T(), "CONTAINER ID        IMAGE               COMMAND             STATUS              PORTS\n", out) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (m *MobyBackendTestSuite) TestRun() { | ||||||
|  | 	_, err := m.NewDockerCommand("run", "--name", "nginx", "nginx").Exec() | ||||||
|  | 	require.Nil(m.T(), err) | ||||||
|  | 	out := m.NewDockerCommand("ps").ExecOrDie() | ||||||
|  | 	defer func() { | ||||||
|  | 		m.NewDockerCommand("rm", "-f", "nginx").ExecOrDie() | ||||||
|  | 	}() | ||||||
|  | 	lines := strings.Split(out, "\n") | ||||||
|  | 	assert.Equal(m.T(), 3, len(lines)) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (m *MobyBackendTestSuite) TestRunWithPorts() { | ||||||
|  | 	_, err := m.NewDockerCommand("run", "--name", "nginx", "-p", "8080:80", "nginx").Exec() | ||||||
|  | 	require.Nil(m.T(), err) | ||||||
|  | 	out := m.NewDockerCommand("ps").ExecOrDie() | ||||||
|  | 	defer func() { | ||||||
|  | 		m.NewDockerCommand("rm", "-f", "nginx").ExecOrDie() | ||||||
|  | 	}() | ||||||
|  | 	assert.Contains(m.T(), out, "8080") | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func TestMobyBackendTestSuite(t *testing.T) { | ||||||
|  | 	suite.Run(t, new(MobyBackendTestSuite)) | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user