Skip to content

Commit f13a0b1

Browse files
committed
Migrate end-to-end test to latest cloud SDKs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
1 parent 2fdbde7 commit f13a0b1

File tree

4 files changed

+68
-118
lines changed

4 files changed

+68
-118
lines changed

tests/integration/azure_test.go

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ package integration
1919
import (
2020
"context"
2121
"fmt"
22+
"log"
2223
"os"
2324

24-
eventhub "github.com/Azure/azure-event-hubs-go/v3"
25+
azeventhubs "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/v2"
2526
"github.com/fluxcd/pkg/git"
2627
"github.com/fluxcd/test-infra/tftestenv"
2728
tfjson "github.com/hashicorp/terraform-json"
@@ -148,27 +149,45 @@ func registryLoginACR(ctx context.Context, output map[string]*tfjson.StateOutput
148149
}
149150

150151
func setupEventHubHandler(ctx context.Context, c chan []byte, eventHubSas string) (func(), error) {
151-
hub, err := eventhub.NewHubFromConnectionString(eventHubSas)
152+
consumerClient, err := azeventhubs.NewConsumerClientFromConnectionString(eventHubSas, "", azeventhubs.DefaultConsumerGroup, nil)
152153
if err != nil {
153154
return nil, err
154155
}
155156

156-
handler := func(ctx context.Context, event *eventhub.Event) error {
157-
c <- event.Data
158-
return nil
159-
}
160-
runtimeInfo, err := hub.GetRuntimeInformation(ctx)
157+
props, err := consumerClient.GetEventHubProperties(ctx, nil)
161158
if err != nil {
159+
consumerClient.Close(ctx)
162160
return nil, err
163161
}
164-
listenerHandler, err := hub.Receive(ctx, runtimeInfo.PartitionIDs[0], handler, eventhub.ReceiveWithLatestOffset())
162+
163+
latest := true
164+
partitionClient, err := consumerClient.NewPartitionClient(props.PartitionIDs[0], &azeventhubs.PartitionClientOptions{
165+
StartPosition: azeventhubs.StartPosition{Latest: &latest},
166+
})
165167
if err != nil {
168+
consumerClient.Close(ctx)
166169
return nil, err
167170
}
168171

172+
go func() {
173+
for {
174+
events, err := partitionClient.ReceiveEvents(ctx, 1, nil)
175+
if err != nil {
176+
if ctx.Err() != nil {
177+
return
178+
}
179+
log.Printf("error receiving event hub events: %s\n", err)
180+
return
181+
}
182+
for _, event := range events {
183+
c <- event.Body
184+
}
185+
}
186+
}()
187+
169188
closefn := func() {
170-
listenerHandler.Close(ctx)
171-
hub.Close(ctx)
189+
partitionClient.Close(ctx)
190+
consumerClient.Close(ctx)
172191
}
173192

174193
return closefn, nil

tests/integration/gcp_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"os"
2525
"strings"
2626

27-
"cloud.google.com/go/pubsub"
27+
"cloud.google.com/go/pubsub/v2"
2828
tfjson "github.com/hashicorp/terraform-json"
2929
"google.golang.org/grpc/codes"
3030
"google.golang.org/grpc/status"
@@ -159,7 +159,7 @@ func setupPubSubReceiver(ctx context.Context, c chan []byte, projectID string, t
159159
return nil, fmt.Errorf("error creating pubsub client: %s", err)
160160
}
161161

162-
sub := pubsubClient.Subscription(topicID)
162+
sub := pubsubClient.Subscriber(topicID)
163163
go func() {
164164
err = sub.Receive(ctx, func(ctx context.Context, message *pubsub.Message) {
165165
c <- message.Data

tests/integration/go.mod

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/fluxcd/flux2/tests/integration
33
go 1.26.0
44

55
require (
6-
cloud.google.com/go/pubsub v1.50.1
7-
github.com/Azure/azure-event-hubs-go/v3 v3.6.2
6+
cloud.google.com/go/pubsub/v2 v2.0.0
7+
github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/v2 v2.0.2
88
github.com/chainguard-dev/git-urls v1.0.2
99
github.com/fluxcd/helm-controller/api v1.4.5
1010
github.com/fluxcd/image-automation-controller/api v1.0.4
@@ -36,19 +36,10 @@ require (
3636
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
3737
cloud.google.com/go/compute/metadata v0.9.0 // indirect
3838
cloud.google.com/go/iam v1.5.2 // indirect
39-
cloud.google.com/go/pubsub/v2 v2.0.0 // indirect
4039
dario.cat/mergo v1.0.1 // indirect
41-
github.com/Azure/azure-amqp-common-go/v4 v4.2.0 // indirect
42-
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
43-
github.com/Azure/go-amqp v1.4.0 // indirect
44-
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
45-
github.com/Azure/go-autorest/autorest v0.11.30 // indirect
46-
github.com/Azure/go-autorest/autorest/adal v0.9.24 // indirect
47-
github.com/Azure/go-autorest/autorest/date v0.3.1 // indirect
48-
github.com/Azure/go-autorest/autorest/to v0.4.1 // indirect
49-
github.com/Azure/go-autorest/autorest/validation v0.3.2 // indirect
50-
github.com/Azure/go-autorest/logger v0.2.2 // indirect
51-
github.com/Azure/go-autorest/tracing v0.6.1 // indirect
40+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 // indirect
41+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect
42+
github.com/Azure/go-amqp v1.5.0 // indirect
5243
github.com/Masterminds/semver/v3 v3.4.0 // indirect
5344
github.com/Microsoft/go-winio v0.6.2 // indirect
5445
github.com/ProtonMail/go-crypto v1.3.0 // indirect
@@ -58,7 +49,6 @@ require (
5849
github.com/containerd/stargz-snapshotter/estargz v0.18.1 // indirect
5950
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
6051
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
61-
github.com/devigned/tab v0.1.1 // indirect
6252
github.com/docker/cli v29.2.0+incompatible // indirect
6353
github.com/docker/distribution v2.8.3+incompatible // indirect
6454
github.com/docker/docker-credential-helpers v0.9.3 // indirect
@@ -78,7 +68,6 @@ require (
7868
github.com/go-openapi/jsonpointer v0.21.1 // indirect
7969
github.com/go-openapi/jsonreference v0.21.0 // indirect
8070
github.com/go-openapi/swag v0.23.1 // indirect
81-
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
8271
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
8372
github.com/google/gnostic-models v0.7.0 // indirect
8473
github.com/google/go-cmp v0.7.0 // indirect
@@ -95,13 +84,11 @@ require (
9584
github.com/hashicorp/hc-install v0.9.2 // indirect
9685
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
9786
github.com/josharian/intern v1.0.0 // indirect
98-
github.com/jpillora/backoff v1.0.0 // indirect
9987
github.com/json-iterator/go v1.1.12 // indirect
10088
github.com/kevinburke/ssh_config v1.2.0 // indirect
10189
github.com/klauspost/compress v1.18.1 // indirect
10290
github.com/mailru/easyjson v0.9.0 // indirect
10391
github.com/mitchellh/go-homedir v1.1.0 // indirect
104-
github.com/mitchellh/mapstructure v1.5.0 // indirect
10592
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
10693
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
10794
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
@@ -117,6 +104,7 @@ require (
117104
github.com/x448/float16 v0.8.4 // indirect
118105
github.com/xanzy/ssh-agent v0.3.3 // indirect
119106
github.com/zclconf/go-cty v1.16.4 // indirect
107+
go.einride.tech/aip v0.73.0 // indirect
120108
go.opencensus.io v0.24.0 // indirect
121109
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
122110
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
@@ -144,6 +132,7 @@ require (
144132
gopkg.in/inf.v0 v0.9.1 // indirect
145133
gopkg.in/warnings.v0 v0.1.2 // indirect
146134
gopkg.in/yaml.v3 v3.0.1 // indirect
135+
gotest.tools/v3 v3.5.2 // indirect
147136
k8s.io/apiextensions-apiserver v0.35.2 // indirect
148137
k8s.io/klog/v2 v2.130.1 // indirect
149138
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect

0 commit comments

Comments
 (0)