-
Notifications
You must be signed in to change notification settings - Fork 373
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
Conversation
Thanks for your PR. The following commands are available:
|
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/test-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
test/e2e/framework.go
Outdated
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) | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
a1e55ed
to
85574e6
Compare
/test-all |
/test-networkpolicy |
test/e2e/framework.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated.
85574e6
to
3ba1d58
Compare
There was a problem hiding this 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.
test/e2e/framework.go
Outdated
} | ||
rawFeatureGateMap, ok := cfg.(map[interface{}]interface{})["featureGates"] | ||
if !ok || rawFeatureGateMap == nil { | ||
return featureGate, err |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
3ba1d58
to
a8c43db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/skip-all |
/test-e2e |
Read feature gate status instead of indirect checking to
determine whether a feature is enabled.
Signed-off-by: Weiqiang Tang weiqiangt@vmware.com