Skip to content

Commit 4eb97cc

Browse files
committed
fix api7 etest
1 parent c06817f commit 4eb97cc

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

internal/adc/client/client.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"os"
2525
"slices"
2626
"strings"
27+
"sync"
2728
"time"
2829

2930
"github.com/api7/gopkg/pkg/log"
@@ -37,6 +38,7 @@ import (
3738
)
3839

3940
type Client struct {
41+
mu sync.Mutex
4042
*cache.Store
4143

4244
executor ADCExecutor
@@ -60,6 +62,8 @@ type Task struct {
6062
}
6163

6264
func (d *Client) Insert(ctx context.Context, args Task) error {
65+
d.mu.Lock()
66+
defer d.mu.Unlock()
6367
for _, config := range args.Configs {
6468
if err := d.Store.Insert(config.Name, args.ResourceTypes, args.Resources, args.Labels); err != nil {
6569
log.Errorw("failed to insert resources into store",
@@ -73,6 +77,8 @@ func (d *Client) Insert(ctx context.Context, args Task) error {
7377
}
7478

7579
func (d *Client) Remove(ctx context.Context, args Task) error {
80+
d.mu.Lock()
81+
defer d.mu.Unlock()
7682
for _, config := range args.Configs {
7783
if err := d.Delete(config.Name, args.ResourceTypes, args.Labels); err != nil {
7884
log.Errorw("failed to delete resources from store",
@@ -86,10 +92,14 @@ func (d *Client) Remove(ctx context.Context, args Task) error {
8692
}
8793

8894
func (d *Client) Update(ctx context.Context, args Task) error {
95+
d.mu.Lock()
96+
defer d.mu.Unlock()
8997
return d.sync(ctx, args)
9098
}
9199

92100
func (c *Client) Sync(ctx context.Context, cfg map[string]adctypes.Config) (map[string]types.ADCExecutionErrors, error) {
101+
c.mu.Lock()
102+
defer c.mu.Unlock()
93103
log.Debug("syncing all resources")
94104

95105
if len(cfg) == 0 {

internal/provider/api7ee/provider.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (d *api7eeProvider) Update(ctx context.Context, tctx *provider.TranslateCon
160160
Configs: deleteConfigs,
161161
})
162162

163-
d.client.Insert(ctx, adcclient.Task{
163+
task := adcclient.Task{
164164
Name: obj.GetName(),
165165
Labels: label.GenLabel(obj),
166166
Configs: configs,
@@ -172,9 +172,10 @@ func (d *api7eeProvider) Update(ctx context.Context, tctx *provider.TranslateCon
172172
SSLs: result.SSL,
173173
Consumers: result.Consumers,
174174
},
175-
})
176-
d.syncNotify()
177-
return nil
175+
}
176+
177+
d.client.Insert(ctx, task)
178+
return d.client.Update(ctx, task)
178179
}
179180

180181
func (d *api7eeProvider) Delete(ctx context.Context, obj client.Object) error {
@@ -220,18 +221,12 @@ func (d *api7eeProvider) Delete(ctx context.Context, obj client.Object) error {
220221
})
221222

222223
log.Debugw("successfully deleted resources from store", zap.Any("object", obj))
223-
// Full synchronization is performed on a gateway by gateway basis
224-
// and it is not possible to perform scheduled synchronization
225-
// on deleted gateway level resources
226-
if len(resourceTypes) == 0 {
227-
return d.client.Update(ctx, adcclient.Task{
228-
Name: obj.GetName(),
229-
Configs: configs,
230-
})
231-
} else {
232-
d.syncNotify()
233-
}
234-
return nil
224+
return d.client.Update(ctx, adcclient.Task{
225+
Name: obj.GetName(),
226+
Labels: labels,
227+
ResourceTypes: resourceTypes,
228+
Configs: configs,
229+
})
235230
}
236231

237232
func (d *api7eeProvider) Start(ctx context.Context) error {

test/e2e/crds/v1alpha1/consumer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
. "github.com/onsi/ginkgo/v2"
2525
. "github.com/onsi/gomega"
2626

27-
"github.com/apache/apisix-ingress-controller/internal/provider/adc"
2827
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
2928
)
3029

@@ -600,7 +599,7 @@ spec:
600599
})
601600

602601
It("Should sync Consumer during startup", func() {
603-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
602+
if s.Deployer.Name() == "api7ee" {
604603
Skip("skipping test in API7EE mode")
605604
}
606605
Expect(s.CreateResourceFromString(consumer2)).NotTo(HaveOccurred(), "creating unused consumer")

test/e2e/crds/v2/route.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ spec:
7272

7373
Context("Test ApisixRoute", func() {
7474

75-
It("Basic tests", func() {
75+
FIt("Basic tests", func() {
7676
const apisixRouteSpec = `
7777
apiVersion: apisix.apache.org/v2
7878
kind: ApisixRoute
@@ -726,7 +726,7 @@ spec:
726726
servicePort: 80
727727
`
728728
It("Should sync ApisixRoute during startup", func() {
729-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
729+
if s.Deployer.Name() == "api7ee" {
730730
Skip("skipping test in API7EE mode")
731731
}
732732
By("apply ApisixRoute")

test/e2e/scaffold/k8s.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import (
3939
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
4040
"sigs.k8s.io/gateway-api/apis/v1alpha2"
4141

42-
"github.com/apache/apisix-ingress-controller/internal/provider/adc"
4342
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
4443
)
4544

@@ -310,7 +309,7 @@ spec:
310309
value: "%s"
311310
`
312311

313-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
312+
if s.Deployer.Name() == "api7ee" {
314313
return fmt.Sprintf(gatewayProxyYamlAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey())
315314
}
316315
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())

0 commit comments

Comments
 (0)