Skip to content

Commit

Permalink
Get the right traffic mode in e2e tests (#2019)
Browse files Browse the repository at this point in the history
Fix e2e test framework to get the right Antrea ConfigMap for retrieving
the traffic encap mode, when there are multiple Antrea ConfigMaps
created in the test Cluster.
Add information about building Antrea Ubuntu image to CONTRIBUTING.md,
and generating Antrea manifest to test/e2e/README.md.
  • Loading branch information
jianjuns authored Apr 4, 2021
1 parent 780cae0 commit 3b294ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ To develop locally, you can follow these steps:
2. Checkout your feature branch and `cd` into it.
3. To build all Go files and install them under `bin`, run `make bin`
4. To run all Go unit tests, run `make test-unit`
5. To build the Antrea Ubuntu Docker image separately with the binaries generated in step 2, run `make ubuntu`

### CI testing

Expand Down
4 changes: 4 additions & 0 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ manifest to the control-plane Docker container:
go test -v github.com/vmware-tanzu/antrea/test/e2e -provider=kind
```

`generate-manifest.sh` supports generating the Antrea manifest with different
Antrea configurations. Run `./hack/generate-manifest.sh --help` to see the
supported config options.

As part of code development, if you want to run the tests with local changes,
then make the code changes on the local repo and
[build the image](../../CONTRIBUTING.md#building-and-testing-your-change).
Expand Down
25 changes: 8 additions & 17 deletions test/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -1536,28 +1536,19 @@ func (data *TestData) doesOVSPortExist(antreaPodName string, portName string) (b
}

func (data *TestData) GetEncapMode() (config.TrafficEncapModeType, error) {
mapList, err := data.clientset.CoreV1().ConfigMaps(antreaNamespace).List(context.TODO(), metav1.ListOptions{})
configMap, err := data.GetAntreaConfigMap(antreaNamespace)
if err != nil {
return config.TrafficEncapModeInvalid, err
return config.TrafficEncapModeInvalid, fmt.Errorf("failed to get Antrea ConfigMap: %v", err)
}
for _, m := range mapList.Items {
if strings.HasPrefix(m.Name, "antrea-config") {
configMap, err := data.clientset.CoreV1().ConfigMaps(antreaNamespace).Get(context.TODO(), m.Name, metav1.GetOptions{})
if err != nil {
return config.TrafficEncapModeInvalid, err
}
for _, antreaConfig := range configMap.Data {
for _, mode := range config.GetTrafficEncapModes() {
searchStr := fmt.Sprintf("trafficEncapMode: %s", mode)
if strings.Index(strings.ToLower(antreaConfig), strings.ToLower(searchStr)) != -1 {
return mode, nil
}
}
for _, antreaConfig := range configMap.Data {
for _, mode := range config.GetTrafficEncapModes() {
searchStr := fmt.Sprintf("trafficEncapMode: %s", mode)
if strings.Index(strings.ToLower(antreaConfig), strings.ToLower(searchStr)) != -1 {
return mode, nil
}
return config.TrafficEncapModeEncap, nil
}
}
return config.TrafficEncapModeInvalid, fmt.Errorf("antrea-conf config map is not found")
return config.TrafficEncapModeEncap, nil
}

func (data *TestData) getFeatures(confName string, antreaNamespace string) (featuregate.FeatureGate, error) {
Expand Down

0 comments on commit 3b294ea

Please sign in to comment.