Skip to content

Commit

Permalink
add resync test after reconnecting.
Browse files Browse the repository at this point in the history
Signed-off-by: morvencao <[email protected]>
  • Loading branch information
morvencao committed Jun 20, 2024
1 parent 521ff28 commit eec9217
Show file tree
Hide file tree
Showing 8 changed files with 549 additions and 217 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ e2e-test/teardown:
.PHONY: e2e-test/teardown

e2e-test: e2e-test/teardown e2e-test/setup
ginkgo --output-dir="${PWD}/test/e2e/report" --json-report=report.json --junit-report=report.xml \
ginkgo -v --output-dir="${PWD}/test/e2e/report" --json-report=report.json --junit-report=report.xml \
${PWD}/test/e2e/pkg -- -consumer_name=$(shell cat ${PWD}/test/e2e/.consumer_name) \
-api-server=https://$(shell cat ${PWD}/test/e2e/.external_host_ip):30080 \
-grpc-server=$(shell cat ${PWD}/test/e2e/.external_host_ip):30090 \
Expand Down
32 changes: 16 additions & 16 deletions test/e2e/pkg/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ var _ = Describe("GRPC", Ordered, Label("e2e-tests-grpc"), func() {
return fmt.Errorf("resource not Available")
}

availableReplicas, ok := resourceStatus.ContentStatus["availableReplicas"]
replicas, ok := resourceStatus.ContentStatus["replicas"]
if !ok {
return fmt.Errorf("available replicas not found in content status")
return fmt.Errorf("replicas not found in content status")
}

if availableReplicas.(float64) != float64(1) {
return fmt.Errorf("unexpected available replicas, expected 1, got %d", availableReplicas)
if replicas.(float64) != float64(1) {
return fmt.Errorf("unexpected replicas, expected 1, got %d", replicas)
}

return nil
Expand Down Expand Up @@ -192,13 +192,13 @@ var _ = Describe("GRPC", Ordered, Label("e2e-tests-grpc"), func() {
return fmt.Errorf("resource not Available")
}

availableReplicas, ok := resourceStatus.ContentStatus["availableReplicas"]
replicas, ok := resourceStatus.ContentStatus["replicas"]
if !ok {
return fmt.Errorf("available replicas not found in content status")
return fmt.Errorf("replicas not found in content status")
}

if availableReplicas.(float64) != float64(2) {
return fmt.Errorf("unexpected available replicas, expected 2, got %d", availableReplicas)
if replicas.(float64) != float64(2) {
return fmt.Errorf("unexpected replicas, expected 2, got %d", replicas)
}

return nil
Expand Down Expand Up @@ -376,13 +376,13 @@ var _ = Describe("GRPC", Ordered, Label("e2e-tests-grpc"), func() {
return fmt.Errorf("failed to convert status feedback value to content status: %v", err)
}

availableReplicas, ok := contentStatus["availableReplicas"]
replicas, ok := contentStatus["replicas"]
if !ok {
return fmt.Errorf("available replicas not found in content status")
return fmt.Errorf("replicas not found in content status")
}

if availableReplicas.(float64) != float64(1) {
return fmt.Errorf("unexpected available replicas, expected 1, got %d", availableReplicas)
if replicas.(float64) != float64(1) {
return fmt.Errorf("unexpected replicas, expected 1, got %d", replicas)
}

return nil
Expand Down Expand Up @@ -456,13 +456,13 @@ var _ = Describe("GRPC", Ordered, Label("e2e-tests-grpc"), func() {
return fmt.Errorf("failed to convert status feedback value to content status: %v", err)
}

availableReplicas, ok := contentStatus["availableReplicas"]
replicas, ok := contentStatus["replicas"]
if !ok {
return fmt.Errorf("available replicas not found in content status")
return fmt.Errorf("replicas not found in content status")
}

if availableReplicas.(float64) != float64(2) {
return fmt.Errorf("unexpected available replicas, expected 2, got %d", availableReplicas)
if replicas.(float64) != float64(2) {
return fmt.Errorf("unexpected replicas, expected 2, got %d", replicas)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/pkg/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ var _ = Describe("Resources", Ordered, Label("e2e-tests-resources"), func() {
}
}
return nil
}, 30*time.Second, 2*time.Second).ShouldNot(HaveOccurred())
}, 10*time.Second, 1*time.Second).ShouldNot(HaveOccurred())
})

It("delete the nginx deployment", func() {
Expand Down Expand Up @@ -199,7 +199,7 @@ var _ = Describe("Resources", Ordered, Label("e2e-tests-resources"), func() {
return fmt.Errorf("unexpected replicas, expected 1, got %d", *deploy.Spec.Replicas)
}
return nil
}, 30*time.Second, 2*time.Second).ShouldNot(HaveOccurred())
}, 10*time.Second, 1*time.Second).ShouldNot(HaveOccurred())
})

It("delete the nginx resource", func() {
Expand Down
22 changes: 9 additions & 13 deletions test/e2e/pkg/sourceclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/openshift-online/maestro/pkg/client/cloudevents/grpcsource"

"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand All @@ -20,9 +18,7 @@ import (

workv1 "open-cluster-management.io/api/work/v1"

"open-cluster-management.io/sdk-go/pkg/cloudevents/work"
"open-cluster-management.io/sdk-go/pkg/cloudevents/work/common"
"open-cluster-management.io/sdk-go/pkg/cloudevents/work/source/codec"
)

var _ = Describe("gRPC Source ManifestWork Client Test", func() {
Expand Down Expand Up @@ -61,18 +57,18 @@ var _ = Describe("gRPC Source ManifestWork Client Test", func() {
})

It("The work status should be watched", func() {
workClient, err := work.NewClientHolderBuilder(grpcOptions).
WithClientID(fmt.Sprintf("%s-client", sourceID)).
WithSourceID(sourceID).
WithCodecs(codec.NewManifestBundleCodec()).
WithWorkClientWatcherStore(grpcsource.NewRESTFullAPIWatcherStore(apiClient, sourceID)).
WithResyncEnabled(false).
NewSourceClientHolder(ctx)
Expect(err).ShouldNot(HaveOccurred())
// workClient, err := work.NewClientHolderBuilder(grpcOptions).
// WithClientID(fmt.Sprintf("%s-client", sourceID)).
// WithSourceID(sourceID).
// WithCodecs(codec.NewManifestBundleCodec()).
// WithWorkClientWatcherStore(grpcsource.NewRESTFullAPIWatcherStore(apiClient, sourceID)).
// WithResyncEnabled(false).
// NewSourceClientHolder(ctx)
// Expect(err).ShouldNot(HaveOccurred())

By("create a work")
workName := "work-" + rand.String(5)
_, err = workClient.ManifestWorks(consumer_name).Create(ctx, NewManifestWork(workName), metav1.CreateOptions{})
_, err := workClient.ManifestWorks(consumer_name).Create(ctx, NewManifestWork(workName), metav1.CreateOptions{})
Expect(err).ShouldNot(HaveOccurred())

// wait for few seconds to ensure the creation is finished
Expand Down
Loading

0 comments on commit eec9217

Please sign in to comment.