Skip to content

Commit 7666115

Browse files
[azservicebus] Do a sleep in our azidentity test if it initially reports that we don't have Send claims (Azure#19647)
Adding in a workaround for the annoying "send claims" bug that manifests in CI. Fixes Azure#19609
1 parent 8971249 commit 7666115

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

sdk/messaging/azservicebus/client_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ package azservicebus
55

66
import (
77
"context"
8-
"fmt"
98
"net"
109
"net/http"
1110
"os"
11+
"strings"
1212
"testing"
1313
"time"
1414

@@ -38,7 +38,7 @@ func TestNewClientWithAzureIdentity(t *testing.T) {
3838
envCred, err := azidentity.NewEnvironmentCredential(nil)
3939

4040
if err == nil {
41-
fmt.Printf("Env cred works, being added to our chained token credential")
41+
t.Logf("Env cred works, being added to our chained token credential")
4242
credsToAdd = append(credsToAdd, envCred)
4343
}
4444

@@ -58,6 +58,19 @@ func TestNewClientWithAzureIdentity(t *testing.T) {
5858
require.NoError(t, err)
5959

6060
err = sender.SendMessage(context.TODO(), &Message{Body: []byte("hello - authenticating with a TokenCredential")}, nil)
61+
62+
if err != nil && strings.Contains(err.Error(), "'Send' claim(s) are required to perform this operation") {
63+
const sleepDuration = time.Minute
64+
// it's possible we're just dealing with a propagation delay for our
65+
// configured identity and the newly created resource. We'll sleep
66+
// a bit to give it some time and try again.
67+
t.Logf("Enacting CI workaround to deal with RBAC propagation delays. Sleeping for %s...", sleepDuration)
68+
time.Sleep(sleepDuration)
69+
t.Logf("Done sleeping for %s", sleepDuration)
70+
71+
err = sender.SendMessage(context.TODO(), &Message{Body: []byte("hello - authenticating with a TokenCredential")}, nil)
72+
}
73+
6174
require.NoError(t, err)
6275

6376
receiver, err := client.NewReceiverForQueue(queue, nil)

0 commit comments

Comments
 (0)