mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Get "run" test back to main function
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
70bcdca2c2
commit
762f462d80
@ -78,7 +78,38 @@ func main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("runs nginx on port 80", func() {
|
It("runs nginx on port 80", func() {
|
||||||
runTest(subscriptionID)
|
aciContext := store.AciContext{
|
||||||
|
SubscriptionID: subscriptionID,
|
||||||
|
Location: location,
|
||||||
|
ResourceGroup: resourceGroupName,
|
||||||
|
}
|
||||||
|
createStorageAccount(aciContext, testStorageAccountName)
|
||||||
|
defer deleteStorageAccount(aciContext)
|
||||||
|
keys := getStorageKeys(aciContext, testStorageAccountName)
|
||||||
|
firstKey := *keys[0].Value
|
||||||
|
credential, u := createFileShare(firstKey, testShareName)
|
||||||
|
uploadFile(credential, u.String(), testFileName, testFileContent)
|
||||||
|
|
||||||
|
mountTarget := "/usr/share/nginx/html"
|
||||||
|
output := NewDockerCommand("run", "nginx",
|
||||||
|
"-v", fmt.Sprintf("%s:%s@%s:%s",
|
||||||
|
testStorageAccountName, firstKey, testShareName, mountTarget),
|
||||||
|
"-p", "80:80",
|
||||||
|
"--name", testContainerName).ExecOrDie()
|
||||||
|
Expect(output).To(Equal(testContainerName + "\n"))
|
||||||
|
output = NewDockerCommand("ps").ExecOrDie()
|
||||||
|
lines := Lines(output)
|
||||||
|
Expect(len(lines)).To(Equal(2))
|
||||||
|
|
||||||
|
containerFields := Columns(lines[1])
|
||||||
|
Expect(containerFields[1]).To(Equal("nginx"))
|
||||||
|
Expect(containerFields[2]).To(Equal("Running"))
|
||||||
|
exposedIP := containerFields[3]
|
||||||
|
Expect(exposedIP).To(ContainSubstring(":80->80/tcp"))
|
||||||
|
|
||||||
|
publishedURL := strings.ReplaceAll(exposedIP, "->80/tcp", "")
|
||||||
|
output = NewCommand("curl", publishedURL).ExecOrDie()
|
||||||
|
Expect(output).To(ContainSubstring(testFileContent))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("removes container nginx", func() {
|
It("removes container nginx", func() {
|
||||||
@ -181,41 +212,6 @@ func uploadFile(credential azfile.SharedKeyCredential, baseURL, fileName, fileCo
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTest(subscriptionID string) {
|
|
||||||
aciContext := store.AciContext{
|
|
||||||
SubscriptionID: subscriptionID,
|
|
||||||
Location: location,
|
|
||||||
ResourceGroup: resourceGroupName,
|
|
||||||
}
|
|
||||||
createStorageAccount(aciContext, testStorageAccountName)
|
|
||||||
defer deleteStorageAccount(aciContext)
|
|
||||||
keys := getStorageKeys(aciContext, testStorageAccountName)
|
|
||||||
firstKey := *keys[0].Value
|
|
||||||
credential, u := createFileShare(firstKey, testShareName)
|
|
||||||
uploadFile(credential, u.String(), testFileName, testFileContent)
|
|
||||||
|
|
||||||
mountTarget := "/usr/share/nginx/html"
|
|
||||||
output := NewDockerCommand("run", "nginx",
|
|
||||||
"-v", fmt.Sprintf("%s:%s@%s:%s",
|
|
||||||
testStorageAccountName, firstKey, testShareName, mountTarget),
|
|
||||||
"-p", "80:80",
|
|
||||||
"--name", testContainerName).ExecOrDie()
|
|
||||||
Expect(output).To(Equal(testContainerName + "\n"))
|
|
||||||
output = NewDockerCommand("ps").ExecOrDie()
|
|
||||||
lines := Lines(output)
|
|
||||||
Expect(len(lines)).To(Equal(2))
|
|
||||||
|
|
||||||
containerFields := Columns(lines[1])
|
|
||||||
Expect(containerFields[1]).To(Equal("nginx"))
|
|
||||||
Expect(containerFields[2]).To(Equal("Running"))
|
|
||||||
exposedIP := containerFields[3]
|
|
||||||
Expect(exposedIP).To(ContainSubstring(":80->80/tcp"))
|
|
||||||
|
|
||||||
publishedURL := strings.ReplaceAll(exposedIP, "->80/tcp", "")
|
|
||||||
output = NewCommand("curl", publishedURL).ExecOrDie()
|
|
||||||
Expect(output).To(ContainSubstring(testFileContent))
|
|
||||||
}
|
|
||||||
|
|
||||||
func setupTestResourceGroup(groupName string) {
|
func setupTestResourceGroup(groupName string) {
|
||||||
log.Println("Creating resource group " + resourceGroupName)
|
log.Println("Creating resource group " + resourceGroupName)
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user