Skip to content

Commit

Permalink
Fix MTLS handling. (#707)
Browse files Browse the repository at this point in the history
We were using the wrong component name when setting up group data
structures for MTLS (because of Go's funny loop variable capture
semantics). Fixed this.

Added a test that uses multi deployer with MTLS (disabled on Github due to its slowness).

Increased timeout for the test from 4s to 10s.
  • Loading branch information
ghemawat authored Jan 9, 2024
1 parent 73c0043 commit ac3a856
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions examples/collatz/weaver_mtls.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[serviceweaver]
binary = "./collatz"
rollout = "5m"

[multi]
listeners.collatz = {address = "localhost:9000"}
mtls = true # For extra testing of MTLS handling
14 changes: 12 additions & 2 deletions examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,29 @@ func TestExamples(t *testing.T) {
})

// "weaver multi deploy" the application.
t.Run("weaver-multi", func(t *testing.T) {
t.Run("weaver-multi-nomtls", func(t *testing.T) {
cmd := startCmd(ctx, t, nil, "../../cmd/weaver/weaver", "multi", "deploy", "weaver.toml")
t.Cleanup(terminateCmdAndWait(t, cmd))
run(t, test)
})

// "weaver multi deploy" the application with MTLS.
t.Run("weaver-multi-mtls", func(t *testing.T) {
if os.Getenv("GITHUB_RUN_ID") != "" {
t.Skip("test takes too long (over 30s) on github")
}
cmd := startCmd(ctx, t, nil, "../../cmd/weaver/weaver", "multi", "deploy", "weaver_mtls.toml")
t.Cleanup(terminateCmdAndWait(t, cmd))
run(t, test)
})

// TODO: other deployers?
})
}
}

func run(t *testing.T, test test) {
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
t.Cleanup(cancel)

// Send a GET request to the endpoint, retrying on error.
Expand Down
1 change: 1 addition & 0 deletions internal/weaver/remoteweavelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func NewRemoteWeavelet(ctx context.Context, regs []*codegen.Registration, bootst

// Initialize the component structs.
for _, reg := range regs {
reg := reg
c := &component{reg: reg}
w.componentsByName[reg.Name] = c
w.componentsByIntf[reg.Iface] = c
Expand Down

0 comments on commit ac3a856

Please sign in to comment.