Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve featuregate status in e2e tests #1387

Merged
merged 1 commit into from
Oct 20, 2020

Conversation

weiqiangt
Copy link
Contributor

Read feature gate status instead of indirect checking to
determine whether a feature is enabled.

Signed-off-by: Weiqiang Tang weiqiangt@vmware.com

@antrea-bot
Copy link
Collaborator

Thanks for your PR.
Unit tests and code linters are run automatically every time the PR is updated.
E2e, conformance and network policy tests can only be triggered by a member of the vmware-tanzu organization. Regular contributors to the project should join the org.

The following commands are available:

  • /test-e2e: to trigger e2e tests.
  • /skip-e2e: to skip e2e tests.
  • /test-conformance: to trigger conformance tests.
  • /skip-conformance: to skip conformance tests.
  • /test-whole-conformance: to trigger all conformance tests on linux.
  • /skip-whole-conformance: to skip all conformance tests on linux.
  • /test-networkpolicy: to trigger networkpolicy tests.
  • /skip-networkpolicy: to skip networkpolicy tests.
  • /test-windows-conformance: to trigger windows conformance tests.
  • /skip-windows-conformance: to skip windows conformance tests.
  • /test-windows-networkpolicy: to trigger windows networkpolicy tests.
  • /skip-windows-networkpolicy: to skip windows networkpolicy tests.
  • /test-hw-offload: to trigger ovs hardware offload test.
  • /skip-hw-offload: to skip ovs hardware offload test.
  • /test-all: to trigger all tests (except whole conformance).
  • /skip-all: to skip all tests (except whole conformance).

@codecov-io
Copy link

codecov-io commented Oct 15, 2020

Codecov Report

Merging #1387 into master will decrease coverage by 0.09%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1387      +/-   ##
==========================================
- Coverage   64.41%   64.31%   -0.10%     
==========================================
  Files         159      159              
  Lines       12664    12664              
==========================================
- Hits         8157     8145      -12     
- Misses       3650     3658       +8     
- Partials      857      861       +4     
Flag Coverage Δ
#integration-tests 44.95% <ø> (-0.08%) ⬇️
#kind-e2e-tests 50.25% <ø> (-0.23%) ⬇️
#unit-tests 42.07% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ver/registry/controlplane/nodestatssummary/rest.go 50.00% <0.00%> (-50.00%) ⬇️
pkg/agent/stats/collector.go 91.95% <0.00%> (-5.75%) ⬇️
pkg/ovs/openflow/ofctrl_bridge.go 70.35% <0.00%> (-1.59%) ⬇️
...ntroller/networkpolicy/networkpolicy_controller.go 80.56% <0.00%> (-0.27%) ⬇️
...kg/controller/networkpolicy/store/networkpolicy.go 81.35% <0.00%> (+3.38%) ⬆️

@weiqiangt
Copy link
Contributor Author

/test-all

antoninbas
antoninbas previously approved these changes Oct 15, 2020
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 1160 to 1168
var agentCfg interface{}
if err := yaml.Unmarshal([]byte(cfgMap.Data[confName]), &agentCfg); err != nil {
return nil, err
}
rawFeatureGateMap, ok := agentCfg.(map[interface{}]interface{})["featureGates"]
if !ok || rawFeatureGateMap == nil {
return featureGate, err
}
featureGateMap := make(map[string]bool)
for k, v := range rawFeatureGateMap.(map[interface{}]interface{}) {
featureGateMap[k.(string)] = v.(bool)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too bad there isn't a more direct way to do that... at least not without being able to import the AgentConfig struct

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can be alleviated once #723 is fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One good thing is that I found the variable name is not good in this block. Let me fix it first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can be alleviated once #723 is fixed?

The configmap update will take 1min to take effect on the mounted file, I think this behavior will slow tests down.

Dyanngg
Dyanngg previously approved these changes Oct 15, 2020
@weiqiangt weiqiangt dismissed stale reviews from Dyanngg and antoninbas via 85574e6 October 16, 2020 03:42
@weiqiangt
Copy link
Contributor Author

/test-all

@weiqiangt
Copy link
Contributor Author

/test-networkpolicy

@@ -1142,6 +1148,41 @@ func (data *TestData) GetEncapMode() (config.TrafficEncapModeType, error) {
return config.TrafficEncapModeInvalid, fmt.Errorf("antrea-conf config map is not found")
}

func (data *TestData) getFeatures(confName string, antreaNamespace string) (featuregate.FeatureGate, error) {
featureGate := featuregate.NewFeatureGate()
if err := featureGate.Add(features.DefaultAntreaFeatureGates); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using DefaultMutableFeatureGate which is for mutating FeatureGate? I think DefaultAntreaFeatureGates doesn't need to be public in that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it may be not good to reuse a global variable. I also have an idea that uses a function to copy the defaultAntreaFeatureGates without returning it directly to keep it read-only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. Then perhaps you could just use DefaultMutableFeatureGate.DeepCopy() to avoid constructing the featuregate from scratch again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one nit-picking.

}
rawFeatureGateMap, ok := cfg.(map[interface{}]interface{})["featureGates"]
if !ok || rawFeatureGateMap == nil {
return featureGate, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: err is from yaml.Unmarshal and might be confusing here, it should return nil explicitly?
and do we need to check both of ok and rawFeatureGateMap to go this branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.
If no feature is enabled, the map would be nil and then we don't need further application. And the ok only indicates whether the key exists or not.

Read featuregate status instead of indirect checking to
determine whether a feature is enabled.

Signed-off-by: Weiqiang Tang <weiqiangt@vmware.com>
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@weiqiangt
Copy link
Contributor Author

/skip-all

@weiqiangt
Copy link
Contributor Author

/test-e2e

@weiqiangt weiqiangt merged commit b189ee6 into antrea-io:master Oct 20, 2020
@weiqiangt weiqiangt deleted the e2e-featuregate branch October 20, 2020 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants