Merge pull request #64128 from yujuhong/conformance-txt

Automatic merge from submit-queue (batch tested with PRs 63417, 64249, 64242, 64128, 64275). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

 conformance testdata: remove tags and trim spaces

**What this PR does / why we need it**:
To detect whether conformance tests have been changed, the test
argument with the `ConformanceIt` is recorded to conformance.txt.
This change remove additional tags (e.g., [Feature:]) and trim spaces,
so that the detection is less-prone to noise.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2018-05-24 20:49:18 -07:00 committed by GitHub
commit 5fa945a16f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 139 additions and 104 deletions

View File

@ -33,10 +33,10 @@ test/e2e/common/configmap_volume.go: "optional updates should be reflected in vo
test/e2e/common/configmap_volume.go: "should be consumable in multiple volumes in the same pod" test/e2e/common/configmap_volume.go: "should be consumable in multiple volumes in the same pod"
test/e2e/common/container_probe.go: "with readiness probe should not be ready before initial delay and never restart" test/e2e/common/container_probe.go: "with readiness probe should not be ready before initial delay and never restart"
test/e2e/common/container_probe.go: "with readiness probe that fails should never be ready and never restart" test/e2e/common/container_probe.go: "with readiness probe that fails should never be ready and never restart"
test/e2e/common/container_probe.go: "should be restarted with a exec \"cat /tmp/health\" liveness probe" test/e2e/common/container_probe.go: "should be restarted with a exec \\\"cat /tmp/health\\\" liveness probe"
test/e2e/common/container_probe.go: "should *not* be restarted with a exec \"cat /tmp/health\" liveness probe" test/e2e/common/container_probe.go: "should *not* be restarted with a exec \\\"cat /tmp/health\\\" liveness probe"
test/e2e/common/container_probe.go: "should be restarted with a /healthz http liveness probe" test/e2e/common/container_probe.go: "should be restarted with a /healthz http liveness probe"
test/e2e/common/container_probe.go: "should have monotonically increasing restart count [Slow]" test/e2e/common/container_probe.go: "should have monotonically increasing restart count"
test/e2e/common/container_probe.go: "should *not* be restarted with a /healthz http liveness probe" test/e2e/common/container_probe.go: "should *not* be restarted with a /healthz http liveness probe"
test/e2e/common/docker_containers.go: "should use the image defaults if command and args are blank" test/e2e/common/docker_containers.go: "should use the image defaults if command and args are blank"
test/e2e/common/docker_containers.go: "should be able to override the image's default arguments (docker cmd)" test/e2e/common/docker_containers.go: "should be able to override the image's default arguments (docker cmd)"
@ -113,7 +113,7 @@ test/e2e/common/projected.go: "should provide container's cpu request"
test/e2e/common/projected.go: "should provide container's memory request" test/e2e/common/projected.go: "should provide container's memory request"
test/e2e/common/projected.go: "should provide node allocatable (cpu) as default cpu limit if the limit is not set" test/e2e/common/projected.go: "should provide node allocatable (cpu) as default cpu limit if the limit is not set"
test/e2e/common/projected.go: "should provide node allocatable (memory) as default memory limit if the limit is not set" test/e2e/common/projected.go: "should provide node allocatable (memory) as default memory limit if the limit is not set"
test/e2e/common/projected.go: "should project all components that make up the projection API [Projection]" test/e2e/common/projected.go: "should project all components that make up the projection API"
test/e2e/common/secrets.go: "should be consumable from pods in env vars" test/e2e/common/secrets.go: "should be consumable from pods in env vars"
test/e2e/common/secrets.go: "should be consumable via the environment" test/e2e/common/secrets.go: "should be consumable via the environment"
test/e2e/common/secrets_volume.go: "should be consumable from pods in volume" test/e2e/common/secrets_volume.go: "should be consumable from pods in volume"
@ -155,7 +155,7 @@ test/e2e/network/service.go: "should serve a basic endpoint from pods "
test/e2e/network/service.go: "should serve multiport endpoints from pods" test/e2e/network/service.go: "should serve multiport endpoints from pods"
test/e2e/network/service_latency.go: "should not be very high" test/e2e/network/service_latency.go: "should not be very high"
test/e2e/node/events.go: "should be sent by kubelets and the scheduler about pods scheduling and running" test/e2e/node/events.go: "should be sent by kubelets and the scheduler about pods scheduling and running"
test/e2e/node/pods.go: "should be submitted and removed [Flaky]" test/e2e/node/pods.go: "should be submitted and removed"
test/e2e/node/pods.go: "should be submitted and removed" test/e2e/node/pods.go: "should be submitted and removed"
test/e2e/node/pre_stop.go: "should call prestop when killing a pod" test/e2e/node/pre_stop.go: "should call prestop when killing a pod"
test/e2e/scheduling/predicates.go: "validates resource limits of pods that are allowed to run" test/e2e/scheduling/predicates.go: "validates resource limits of pods that are allowed to run"

View File

@ -176,10 +176,11 @@ func (v *visitor) emit(arg ast.Expr) {
return return
} }
at.Value = normalizeTestName(at.Value)
if *confDoc { if *confDoc {
v.convertToConformanceData(at) v.convertToConformanceData(at)
} else { } else {
fmt.Printf("%s: %s\n", v.FileSet.Position(at.Pos()).Filename, at.Value) fmt.Printf("%s: %q\n", v.FileSet.Position(at.Pos()).Filename, at.Value)
} }
default: default:
v.failf(at, "framework.ConformanceIt() called with non-literal argument") v.failf(at, "framework.ConformanceIt() called with non-literal argument")
@ -197,6 +198,18 @@ func (v *visitor) getDescription(value string) string {
" " + strings.Trim(value, "\"") " " + strings.Trim(value, "\"")
} }
var (
regexTag = regexp.MustCompile(`(\[[a-zA-Z0-9:-]+\])`)
)
// normalizeTestName removes tags (e.g., [Feature:Foo]), double quotes and trim
// the spaces to normalize the test name.
func normalizeTestName(s string) string {
r := regexTag.ReplaceAllString(s, "")
r = strings.Trim(r, "\"")
return strings.TrimSpace(r)
}
// funcName converts a selectorExpr with two idents into a string, // funcName converts a selectorExpr with two idents into a string,
// x.y -> "x.y" // x.y -> "x.y"
func funcName(n ast.Expr) string { func funcName(n ast.Expr) string {

View File

@ -93,3 +93,25 @@ func TestConformance(t *testing.T) {
} }
} }
} }
func TestNormalizeTestNames(t *testing.T) {
testCases := []struct {
rawName string
normalizedName string
}{
{
"should have monotonically increasing restart count [Slow]",
"should have monotonically increasing restart count",
},
{
" should check is all data is printed ",
"should check is all data is printed",
},
}
for i, tc := range testCases {
actualName := normalizeTestName(tc.rawName)
if actualName != tc.normalizedName {
t.Errorf("test case[%d]: expected normalized name %q, got %q", i, tc.normalizedName, actualName)
}
}
}