conformance: normalize the test names

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.

This change also updates conformance.txt with normalized names.
pull/8/head
Yu-Ju Hong 2018-05-21 20:14:17 -07:00
parent 2a989c60ff
commit 1816d4eca4
3 changed files with 139 additions and 104 deletions

View File

@ -1,4 +1,4 @@
test/e2e/apimachinery/custom_resource_definition.go: "creating/deleting custom resource definition objects works " test/e2e/apimachinery/custom_resource_definition.go: "creating/deleting custom resource definition objects works"
test/e2e/apimachinery/garbage_collector.go: "should delete pods created by rc when not orphaning" test/e2e/apimachinery/garbage_collector.go: "should delete pods created by rc when not orphaning"
test/e2e/apimachinery/garbage_collector.go: "should orphan pods created by rc if delete options say so" test/e2e/apimachinery/garbage_collector.go: "should orphan pods created by rc if delete options say so"
test/e2e/apimachinery/garbage_collector.go: "should delete RS created by deployment when not orphaning" test/e2e/apimachinery/garbage_collector.go: "should delete RS created by deployment when not orphaning"
@ -11,53 +11,53 @@ test/e2e/apps/daemon_set.go: "should run and stop complex daemon"
test/e2e/apps/daemon_set.go: "should retry creating failed daemon pods" test/e2e/apps/daemon_set.go: "should retry creating failed daemon pods"
test/e2e/apps/daemon_set.go: "should update pod when spec was updated and update strategy is RollingUpdate" test/e2e/apps/daemon_set.go: "should update pod when spec was updated and update strategy is RollingUpdate"
test/e2e/apps/daemon_set.go: "should rollback without unnecessary restarts" test/e2e/apps/daemon_set.go: "should rollback without unnecessary restarts"
test/e2e/apps/rc.go: "should serve a basic image on each replica with a public image " test/e2e/apps/rc.go: "should serve a basic image on each replica with a public image"
test/e2e/apps/replica_set.go: "should serve a basic image on each replica with a public image " test/e2e/apps/replica_set.go: "should serve a basic image on each replica with a public image"
test/e2e/apps/statefulset.go: "should perform rolling updates and roll backs of template modifications" test/e2e/apps/statefulset.go: "should perform rolling updates and roll backs of template modifications"
test/e2e/apps/statefulset.go: "should perform canary updates and phased rolling updates of template modifications" test/e2e/apps/statefulset.go: "should perform canary updates and phased rolling updates of template modifications"
test/e2e/apps/statefulset.go: "Scaling should happen in predictable order and halt if any stateful pod is unhealthy" test/e2e/apps/statefulset.go: "Scaling should happen in predictable order and halt if any stateful pod is unhealthy"
test/e2e/apps/statefulset.go: "Burst scaling should run to completion even with unhealthy pods" test/e2e/apps/statefulset.go: "Burst scaling should run to completion even with unhealthy pods"
test/e2e/apps/statefulset.go: "Should recreate evicted statefulset" test/e2e/apps/statefulset.go: "Should recreate evicted statefulset"
test/e2e/auth/service_accounts.go: "should mount an API token into pods " test/e2e/auth/service_accounts.go: "should mount an API token into pods"
test/e2e/auth/service_accounts.go: "should allow opting out of API token automount " test/e2e/auth/service_accounts.go: "should allow opting out of API token automount"
test/e2e/common/configmap.go: "should be consumable via environment variable " test/e2e/common/configmap.go: "should be consumable via environment variable"
test/e2e/common/configmap.go: "should be consumable via the environment " test/e2e/common/configmap.go: "should be consumable via the environment"
test/e2e/common/configmap_volume.go: "should be consumable from pods in volume " test/e2e/common/configmap_volume.go: "should be consumable from pods in volume"
test/e2e/common/configmap_volume.go: "should be consumable from pods in volume with defaultMode set " test/e2e/common/configmap_volume.go: "should be consumable from pods in volume with defaultMode set"
test/e2e/common/configmap_volume.go: "should be consumable from pods in volume as non-root " test/e2e/common/configmap_volume.go: "should be consumable from pods in volume as non-root"
test/e2e/common/configmap_volume.go: "should be consumable from pods in volume with mappings " test/e2e/common/configmap_volume.go: "should be consumable from pods in volume with mappings"
test/e2e/common/configmap_volume.go: "should be consumable from pods in volume with mappings and Item mode set" test/e2e/common/configmap_volume.go: "should be consumable from pods in volume with mappings and Item mode set"
test/e2e/common/configmap_volume.go: "should be consumable from pods in volume with mappings as non-root " test/e2e/common/configmap_volume.go: "should be consumable from pods in volume with mappings as non-root"
test/e2e/common/configmap_volume.go: "updates should be reflected in volume " test/e2e/common/configmap_volume.go: "updates should be reflected in volume"
test/e2e/common/configmap_volume.go: "optional updates should be reflected in volume " test/e2e/common/configmap_volume.go: "optional updates should be reflected in volume"
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)"
test/e2e/common/docker_containers.go: "should be able to override the image's default command (docker entrypoint) " test/e2e/common/docker_containers.go: "should be able to override the image's default command (docker entrypoint)"
test/e2e/common/docker_containers.go: "should be able to override the image's default command and arguments " test/e2e/common/docker_containers.go: "should be able to override the image's default command and arguments"
test/e2e/common/downward_api.go: "should provide pod name, namespace and IP address as env vars " test/e2e/common/downward_api.go: "should provide pod name, namespace and IP address as env vars"
test/e2e/common/downward_api.go: "should provide host IP as an env var " test/e2e/common/downward_api.go: "should provide host IP as an env var"
test/e2e/common/downward_api.go: "should provide container's limits.cpu/memory and requests.cpu/memory as env vars " test/e2e/common/downward_api.go: "should provide container's limits.cpu/memory and requests.cpu/memory as env vars"
test/e2e/common/downward_api.go: "should provide default limits.cpu/memory from node allocatable " test/e2e/common/downward_api.go: "should provide default limits.cpu/memory from node allocatable"
test/e2e/common/downward_api.go: "should provide pod UID as env vars " test/e2e/common/downward_api.go: "should provide pod UID as env vars"
test/e2e/common/downwardapi_volume.go: "should provide podname only " test/e2e/common/downwardapi_volume.go: "should provide podname only"
test/e2e/common/downwardapi_volume.go: "should set DefaultMode on files " test/e2e/common/downwardapi_volume.go: "should set DefaultMode on files"
test/e2e/common/downwardapi_volume.go: "should set mode on item file " test/e2e/common/downwardapi_volume.go: "should set mode on item file"
test/e2e/common/downwardapi_volume.go: "should update labels on modification " test/e2e/common/downwardapi_volume.go: "should update labels on modification"
test/e2e/common/downwardapi_volume.go: "should update annotations on modification " test/e2e/common/downwardapi_volume.go: "should update annotations on modification"
test/e2e/common/downwardapi_volume.go: "should provide container's cpu limit " test/e2e/common/downwardapi_volume.go: "should provide container's cpu limit"
test/e2e/common/downwardapi_volume.go: "should provide container's memory limit " test/e2e/common/downwardapi_volume.go: "should provide container's memory limit"
test/e2e/common/downwardapi_volume.go: "should provide container's cpu request " test/e2e/common/downwardapi_volume.go: "should provide container's cpu request"
test/e2e/common/downwardapi_volume.go: "should provide container's memory request " test/e2e/common/downwardapi_volume.go: "should provide container's memory request"
test/e2e/common/downwardapi_volume.go: "should provide node allocatable (cpu) as default cpu limit if the limit is not set " test/e2e/common/downwardapi_volume.go: "should provide node allocatable (cpu) as default cpu limit if the limit is not set"
test/e2e/common/downwardapi_volume.go: "should provide node allocatable (memory) as default memory limit if the limit is not set " test/e2e/common/downwardapi_volume.go: "should provide node allocatable (memory) as default memory limit if the limit is not set"
test/e2e/common/empty_dir.go: "volume on tmpfs should have the correct mode" test/e2e/common/empty_dir.go: "volume on tmpfs should have the correct mode"
test/e2e/common/empty_dir.go: "should support (root,0644,tmpfs)" test/e2e/common/empty_dir.go: "should support (root,0644,tmpfs)"
test/e2e/common/empty_dir.go: "should support (root,0666,tmpfs)" test/e2e/common/empty_dir.go: "should support (root,0666,tmpfs)"
@ -72,20 +72,20 @@ test/e2e/common/empty_dir.go: "should support (root,0777,default)"
test/e2e/common/empty_dir.go: "should support (non-root,0644,default)" test/e2e/common/empty_dir.go: "should support (non-root,0644,default)"
test/e2e/common/empty_dir.go: "should support (non-root,0666,default)" test/e2e/common/empty_dir.go: "should support (non-root,0666,default)"
test/e2e/common/empty_dir.go: "should support (non-root,0777,default)" test/e2e/common/empty_dir.go: "should support (non-root,0777,default)"
test/e2e/common/expansion.go: "should allow composing env vars into new env vars " test/e2e/common/expansion.go: "should allow composing env vars into new env vars"
test/e2e/common/expansion.go: "should allow substituting values in a container's command " test/e2e/common/expansion.go: "should allow substituting values in a container's command"
test/e2e/common/expansion.go: "should allow substituting values in a container's args " test/e2e/common/expansion.go: "should allow substituting values in a container's args"
test/e2e/common/host_path.go: "should give a volume the correct mode" test/e2e/common/host_path.go: "should give a volume the correct mode"
test/e2e/common/kubelet_etc_hosts.go: "should test kubelet managed /etc/hosts file " test/e2e/common/kubelet_etc_hosts.go: "should test kubelet managed /etc/hosts file"
test/e2e/common/networking.go: "should function for intra-pod communication: http " test/e2e/common/networking.go: "should function for intra-pod communication: http"
test/e2e/common/networking.go: "should function for intra-pod communication: udp " test/e2e/common/networking.go: "should function for intra-pod communication: udp"
test/e2e/common/networking.go: "should function for node-pod communication: http " test/e2e/common/networking.go: "should function for node-pod communication: http"
test/e2e/common/networking.go: "should function for node-pod communication: udp " test/e2e/common/networking.go: "should function for node-pod communication: udp"
test/e2e/common/pods.go: "should get a host IP " test/e2e/common/pods.go: "should get a host IP"
test/e2e/common/pods.go: "should be submitted and removed " test/e2e/common/pods.go: "should be submitted and removed"
test/e2e/common/pods.go: "should be updated " test/e2e/common/pods.go: "should be updated"
test/e2e/common/pods.go: "should allow activeDeadlineSeconds to be updated " test/e2e/common/pods.go: "should allow activeDeadlineSeconds to be updated"
test/e2e/common/pods.go: "should contain environment variables for services " test/e2e/common/pods.go: "should contain environment variables for services"
test/e2e/common/projected.go: "should be consumable from pods in volume" test/e2e/common/projected.go: "should be consumable from pods in volume"
test/e2e/common/projected.go: "should be consumable from pods in volume with defaultMode set" test/e2e/common/projected.go: "should be consumable from pods in volume with defaultMode set"
test/e2e/common/projected.go: "should be consumable from pods in volume as non-root with defaultMode and fsGroup set" test/e2e/common/projected.go: "should be consumable from pods in volume as non-root with defaultMode and fsGroup set"
@ -113,54 +113,54 @@ 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"
test/e2e/common/secrets_volume.go: "should be consumable from pods in volume with defaultMode set " test/e2e/common/secrets_volume.go: "should be consumable from pods in volume with defaultMode set"
test/e2e/common/secrets_volume.go: "should be consumable from pods in volume as non-root with defaultMode and fsGroup set " test/e2e/common/secrets_volume.go: "should be consumable from pods in volume as non-root with defaultMode and fsGroup set"
test/e2e/common/secrets_volume.go: "should be consumable from pods in volume with mappings " test/e2e/common/secrets_volume.go: "should be consumable from pods in volume with mappings"
test/e2e/common/secrets_volume.go: "should be consumable from pods in volume with mappings and Item Mode set " test/e2e/common/secrets_volume.go: "should be consumable from pods in volume with mappings and Item Mode set"
test/e2e/common/secrets_volume.go: "should be consumable in multiple volumes in a pod " test/e2e/common/secrets_volume.go: "should be consumable in multiple volumes in a pod"
test/e2e/common/secrets_volume.go: "optional updates should be reflected in volume " test/e2e/common/secrets_volume.go: "optional updates should be reflected in volume"
test/e2e/kubectl/kubectl.go: "should create and stop a replication controller " test/e2e/kubectl/kubectl.go: "should create and stop a replication controller"
test/e2e/kubectl/kubectl.go: "should scale a replication controller " test/e2e/kubectl/kubectl.go: "should scale a replication controller"
test/e2e/kubectl/kubectl.go: "should do a rolling update of a replication controller " test/e2e/kubectl/kubectl.go: "should do a rolling update of a replication controller"
test/e2e/kubectl/kubectl.go: "should create and stop a working application " test/e2e/kubectl/kubectl.go: "should create and stop a working application"
test/e2e/kubectl/kubectl.go: "should check if v1 is in available api versions " test/e2e/kubectl/kubectl.go: "should check if v1 is in available api versions"
test/e2e/kubectl/kubectl.go: "should check if Kubernetes master services is included in cluster-info " test/e2e/kubectl/kubectl.go: "should check if Kubernetes master services is included in cluster-info"
test/e2e/kubectl/kubectl.go: "should check if kubectl describe prints relevant information for rc and pods " test/e2e/kubectl/kubectl.go: "should check if kubectl describe prints relevant information for rc and pods"
test/e2e/kubectl/kubectl.go: "should create services for rc " test/e2e/kubectl/kubectl.go: "should create services for rc"
test/e2e/kubectl/kubectl.go: "should update the label on a resource " test/e2e/kubectl/kubectl.go: "should update the label on a resource"
test/e2e/kubectl/kubectl.go: "should be able to retrieve and filter logs " test/e2e/kubectl/kubectl.go: "should be able to retrieve and filter logs"
test/e2e/kubectl/kubectl.go: "should add annotations for pods in rc " test/e2e/kubectl/kubectl.go: "should add annotations for pods in rc"
test/e2e/kubectl/kubectl.go: "should check is all data is printed " test/e2e/kubectl/kubectl.go: "should check is all data is printed"
test/e2e/kubectl/kubectl.go: "should create an rc or deployment from an image " test/e2e/kubectl/kubectl.go: "should create an rc or deployment from an image"
test/e2e/kubectl/kubectl.go: "should create an rc from an image " test/e2e/kubectl/kubectl.go: "should create an rc from an image"
test/e2e/kubectl/kubectl.go: "should support rolling-update to same image " test/e2e/kubectl/kubectl.go: "should support rolling-update to same image"
test/e2e/kubectl/kubectl.go: "should create a deployment from an image " test/e2e/kubectl/kubectl.go: "should create a deployment from an image"
test/e2e/kubectl/kubectl.go: "should create a job from an image when restart is OnFailure " test/e2e/kubectl/kubectl.go: "should create a job from an image when restart is OnFailure"
test/e2e/kubectl/kubectl.go: "should create a pod from an image when restart is Never " test/e2e/kubectl/kubectl.go: "should create a pod from an image when restart is Never"
test/e2e/kubectl/kubectl.go: "should update a single-container pod's image " test/e2e/kubectl/kubectl.go: "should update a single-container pod's image"
test/e2e/kubectl/kubectl.go: "should create a job from an image, then delete the job " test/e2e/kubectl/kubectl.go: "should create a job from an image, then delete the job"
test/e2e/kubectl/kubectl.go: "should support proxy with --port 0 " test/e2e/kubectl/kubectl.go: "should support proxy with --port 0"
test/e2e/kubectl/kubectl.go: "should support --unix-socket=/path " test/e2e/kubectl/kubectl.go: "should support --unix-socket=/path"
test/e2e/network/dns.go: "should provide DNS for the cluster " test/e2e/network/dns.go: "should provide DNS for the cluster"
test/e2e/network/dns.go: "should provide DNS for services " test/e2e/network/dns.go: "should provide DNS for services"
test/e2e/network/proxy.go: "should proxy logs on node with explicit kubelet port using proxy subresource " test/e2e/network/proxy.go: "should proxy logs on node with explicit kubelet port using proxy subresource"
test/e2e/network/proxy.go: "should proxy logs on node using proxy subresource " test/e2e/network/proxy.go: "should proxy logs on node using proxy subresource"
test/e2e/network/proxy.go: "should proxy through a service and a pod " test/e2e/network/proxy.go: "should proxy through a service and a pod"
test/e2e/network/service.go: "should provide secure master service " test/e2e/network/service.go: "should provide secure master service"
test/e2e/network/service.go: "should serve a basic endpoint from pods " 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"
test/e2e/scheduling/predicates.go: "validates that NodeSelector is respected if not matching " test/e2e/scheduling/predicates.go: "validates that NodeSelector is respected if not matching"
test/e2e/scheduling/predicates.go: "validates that NodeSelector is respected if matching " test/e2e/scheduling/predicates.go: "validates that NodeSelector is respected if matching"
test/e2e_node/kubelet_test.go: "it should print the output to logs" test/e2e_node/kubelet_test.go: "it should print the output to logs"
test/e2e_node/kubelet_test.go: "it should not write to root filesystem" test/e2e_node/kubelet_test.go: "it should not write to root filesystem"
test/e2e_node/lifecycle_hook_test.go: "should execute poststart exec hook properly" test/e2e_node/lifecycle_hook_test.go: "should execute poststart exec hook properly"

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)
}
}
}