Skip to content

Commit

Permalink
add v6 CNS state file test
Browse files Browse the repository at this point in the history
  • Loading branch information
rjdenney committed Dec 15, 2023
1 parent c861f02 commit 97ea91d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/validate/linux_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var linuxChecksMap = map[string][]check{
{"azure dualstackoverlay", azureVnetStateIps, privilegedLabelSelector, privilegedNamespace, azureVnetStateFileCmd},
},
"cilium_dualstack": {
{"cns", cnsManagedStateFileIps, cnsLabelSelector, privilegedNamespace, cnsManagedStateFileCmd}, // cns configmap "ManageEndpointState": true, | Endpoints managed in CNS State File
{"cns", cnsManagedStateFileDualStackIps, cnsLabelSelector, privilegedNamespace, cnsManagedStateFileCmd}, // cns configmap "ManageEndpointState": true, | Endpoints managed in CNS State File
{"cilium", ciliumStateFileIps, ciliumLabelSelector, privilegedNamespace, ciliumStateFileCmd},
{"cns cache", cnsCacheStateFileIps, cnsLabelSelector, privilegedNamespace, cnsLocalCacheCmd},
},
Expand Down Expand Up @@ -72,7 +72,7 @@ type NetworkingAddressing struct {
}

type Address struct {
Addr string `json:"ipv4"`
Addr string `json:"ip"`
}

// parse azure-vnet.json
Expand Down Expand Up @@ -143,6 +143,25 @@ func cnsManagedStateFileIps(result []byte) (map[string]string, error) {
return cnsPodIps, nil
}

func cnsManagedStateFileDualStackIps(result []byte) (map[string]string, error) {
var cnsResult CnsManagedState
err := json.Unmarshal(result, &cnsResult)
if err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal cns endpoint list")
}

cnsPodIps := make(map[string]string)
for _, v := range cnsResult.Endpoints {
for ifName, ip := range v.IfnameToIPMap {
if ifName == "eth0" {
cnsPodIps[ip.IPv4[0].IP.String()] = v.PodName
cnsPodIps[ip.IPv6[0].IP.String()] = v.PodName
}
}
}
return cnsPodIps, nil
}

func ciliumStateFileIps(result []byte) (map[string]string, error) {
var ciliumResult []CiliumEndpointStatus
err := json.Unmarshal(result, &ciliumResult)
Expand Down

0 comments on commit 97ea91d

Please sign in to comment.