Skip to content

Commit

Permalink
pass ut
Browse files Browse the repository at this point in the history
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
  • Loading branch information
YaoZengzeng committed Nov 14, 2024
1 parent 970c95b commit b67b286
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions config/kmesh_marcos_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* and sidecar containers. The bpf_sk_original_addr auxiliary function is
* used to obtain the original destination address.
*/
#define MDA_NAT_ACCEL 1
#define MDA_NAT_ACCEL 0

/* supports acceleration function filtering based on GID and UID.
* That is, the GID or UID corresponding to the process to be accelerated
* is configured in the configuration file. The bpf_get_sockops_uid_gid
* auxiliary function is used to obtain the GID and UID of the current
* process.
*/
#define MDA_GID_UID_FILTER 1
#define MDA_GID_UID_FILTER 0

/*
* openEuler-23.03 is an innovative version of openEuler, in the early time, we
Expand Down Expand Up @@ -50,7 +50,7 @@
* in kernel 6.x version, add the new iter type ITER_UBUF, and we need add code
* for the corresponding scenarios.
*/
#define ITER_TYPE_IS_UBUF 0
#define ITER_TYPE_IS_UBUF 1

/*
* Kmesh’s Layer 7 acceleration proxy capability relies on kernel enhancements.
Expand All @@ -67,4 +67,4 @@
* the libbpf version in the current environment, and the code in the project
* is enabled accordingly.
* */
#define LIBBPF_HIGHER_0_6_0_VERSION 0
#define LIBBPF_HIGHER_0_6_0_VERSION 1
Empty file added config/linux-bpf.h
Empty file.
2 changes: 1 addition & 1 deletion mk/api-v2-c.pc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prefix=
prefix=/kmesh/

Name: api-v2-c
Description: api-v2-c
Expand Down
2 changes: 1 addition & 1 deletion mk/bpf.pc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prefix=
prefix=/kmesh/
Name: bpf
Description: bpf
Version:
Expand Down
8 changes: 6 additions & 2 deletions pkg/controller/workload/cache/waypoint_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ func (w *waypointCache) DeleteService(resourceName string) {
// This service has waypoint.
if waypoint, ok := w.serviceToWaypoint[resourceName]; ok {
delete(w.serviceToWaypoint, resourceName)
w.waypointAssociatedObjects[waypoint].deleteService(resourceName)
if associate, ok := w.waypointAssociatedObjects[waypoint]; ok {
associate.deleteService(resourceName)
}
}

// This may be a waypoint service.
Expand Down Expand Up @@ -205,7 +207,9 @@ func (w *waypointCache) DeleteWorkload(uid string) {

if waypoint, ok := w.workloadToWaypoint[uid]; ok {
delete(w.workloadToWaypoint, uid)
w.waypointAssociatedObjects[waypoint].deleteWorkload(uid)
if associated, ok := w.waypointAssociatedObjects[waypoint]; ok {
associated.deleteWorkload(uid)
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/workload/cache/waypoint_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestBasic(t *testing.T) {
assert.Equal(t, isHostnameTypeWaypoint(associated.workloads[wl4.ResourceName()].Waypoint), false)

// Delete all svcs and workloads.
for _, svc := range []*workloadapi.Service{svc1, svc2, svc3, svc4} {
for _, svc := range []*workloadapi.Service{svc1, svc2, svc3, svc4, waypointsvc} {
cache.DeleteService(svc.ResourceName())
}
for _, wl := range []*workloadapi.Workload{wl1, wl2, wl3, wl4} {
Expand All @@ -107,6 +107,7 @@ func TestBasic(t *testing.T) {

assert.Equal(t, len(cache.serviceToWaypoint), 0)
assert.Equal(t, len(cache.workloadToWaypoint), 0)
assert.Equal(t, len(cache.waypointAssociatedObjects), 0)
}

// NOTE: All utility functions are simplified for the waypoint cache related tests and omit irrelevant fields.
Expand Down

0 comments on commit b67b286

Please sign in to comment.