Skip to content

Commit

Permalink
scaling ac tests: make the test pass with colima
Browse files Browse the repository at this point in the history
on darwin. However, I had to use sshfs which is the only filesystem that
supports mounted sockets with the following command:

`colima start --arch aarch64 --vm-type=vz --vz-rosetta --cpu 8 \
  --memory 8 --mount-type sshfs rosetta`

and link the colima socket to `/var/run/docker.sock` as explained in [1]
with:

`sudo ln -sf $HOME/.colima/rosetta/docker.sock /var/run/docker.sock`.

[1]: testcontainers/testcontainers-go#815 (comment)
  • Loading branch information
tricktron committed Dec 16, 2023
1 parent 68d451e commit a775411
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
8 changes: 8 additions & 0 deletions go-specs-greet/cmd/httpserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.21-alpine
WORKDIR /app
COPY go.mod ./
RUN go mod download
COPY . .
RUN go build -o svr go-specs-greet/cmd/httpserver/*.go
EXPOSE 8080
CMD [ "./svr" ]
2 changes: 1 addition & 1 deletion go-specs-greet/cmd/httpserver/greeter_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestGreeterServer(t *testing.T) {
req := testcontainers.ContainerRequest{
FromDockerfile: testcontainers.FromDockerfile{
Context: "../../..",
Dockerfile: "./cmd/httpserver/Dockerfile",
Dockerfile: "./go-specs-greet/cmd/httpserver/Dockerfile",
PrintBuildLog: true,
},
ExposedPorts: []string{"8080:8080"},
Expand Down
16 changes: 16 additions & 0 deletions go-specs-greet/cmd/httpserver/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
"log"
"net/http"
)

func main() {
handler := http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
fmt.Fprint(writer, "Hello world")
})
if err := http.ListenAndServe(":8080", handler); err != nil { //nolint:gosec
log.Fatal(err)
}
}
2 changes: 1 addition & 1 deletion go-specs-greet/specifications/greet.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func GreetSpecification(tb testing.TB, greeter Greeter) {

got, err := greeter.Greet()
assert.NoError(tb, err)
assert.Equal(tb, got, "Hello World")
assert.Equal(tb, got, "Hello world")
}

0 comments on commit a775411

Please sign in to comment.