Skip to content

Commit

Permalink
remove flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
ettec committed Nov 28, 2024
1 parent 936d9fd commit 0faa2a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 54 deletions.
2 changes: 2 additions & 0 deletions core/capabilities/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type Registry struct {
}

func (r *Registry) LocalNode(ctx context.Context) (capabilities.Node, error) {
r.mu.RLock()
defer r.mu.RUnlock()
if r.metadataRegistry == nil {
return capabilities.Node{}, errors.New("metadataRegistry information not available")
}
Expand Down
54 changes: 0 additions & 54 deletions core/capabilities/remote/executable/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,60 +63,6 @@ func Test_RemoteExecutableCapability_TransmissionSchedules(t *testing.T) {
testRemoteExecutableCapability(ctx, t, capability, 10, 9, timeOut, 10, 9, timeOut, method)
}

func Test_RemoteExecutionCapability_DonTopologies(t *testing.T) {
ctx := testutils.Context(t)

responseTest := func(t *testing.T, response commoncap.CapabilityResponse, responseError error) {
require.NoError(t, responseError)
mp, err := response.Value.Unwrap()
require.NoError(t, err)
assert.Equal(t, "aValue1", mp.(map[string]any)["response"].(string))
}

transmissionSchedule, err := values.NewMap(map[string]any{
"schedule": transmission.Schedule_OneAtATime,
"deltaStage": "10ms",
})
require.NoError(t, err)

timeOut := 10 * time.Minute

capability := &TestCapability{}

var methods []func(ctx context.Context, caller commoncap.ExecutableCapability)

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
executeCapability(ctx, t, caller, transmissionSchedule, responseTest)
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.NoError(t, responseError)
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.NoError(t, responseError)
})
})

for _, method := range methods {
// Test scenarios where the number of submissions is greater than or equal to F + 1
testRemoteExecutableCapability(ctx, t, capability, 1, 0, timeOut, 1, 0, timeOut, method)
testRemoteExecutableCapability(ctx, t, capability, 4, 3, timeOut, 1, 0, timeOut, method)
testRemoteExecutableCapability(ctx, t, capability, 10, 3, timeOut, 1, 0, timeOut, method)

testRemoteExecutableCapability(ctx, t, capability, 1, 0, timeOut, 1, 0, timeOut, method)
testRemoteExecutableCapability(ctx, t, capability, 1, 0, timeOut, 4, 3, timeOut, method)
testRemoteExecutableCapability(ctx, t, capability, 1, 0, timeOut, 10, 3, timeOut, method)

testRemoteExecutableCapability(ctx, t, capability, 4, 3, timeOut, 4, 3, timeOut, method)
testRemoteExecutableCapability(ctx, t, capability, 10, 3, timeOut, 10, 3, timeOut, method)
testRemoteExecutableCapability(ctx, t, capability, 10, 9, timeOut, 10, 9, timeOut, method)
}
}

func Test_RemoteExecutionCapability_CapabilityError(t *testing.T) {
ctx := testutils.Context(t)

Expand Down
13 changes: 13 additions & 0 deletions core/capabilities/remote/runlots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Number of times to run the command
x=50

# Command to run
command="go test ./... --race"

# Loop to run the command x times
for ((i=1; i<=x; i++))
do
$command
done

0 comments on commit 0faa2a5

Please sign in to comment.