Regional PD documentation; edited validation for Volumes page (#8714)
This commit is contained in:
+30
-22
@@ -421,15 +421,15 @@ func TestExampleObjectSchemas(t *testing.T) {
|
||||
"tcp-liveness-readiness": {&api.Pod{}},
|
||||
},
|
||||
"docs/tasks/debug-application-cluster": {
|
||||
"counter-pod": {&api.Pod{}},
|
||||
"event-exporter-deploy": {&api.ServiceAccount{}, &rbac.ClusterRoleBinding{}, &extensions.Deployment{}},
|
||||
"fluentd-gcp-configmap": {&api.ConfigMap{}},
|
||||
"fluentd-gcp-ds": {&extensions.DaemonSet{}},
|
||||
"nginx-dep": {&extensions.Deployment{}},
|
||||
"node-problem-detector": {&extensions.DaemonSet{}},
|
||||
"node-problem-detector-configmap": {&extensions.DaemonSet{}},
|
||||
"shell-demo": {&api.Pod{}},
|
||||
"termination": {&api.Pod{}},
|
||||
"counter-pod": {&api.Pod{}},
|
||||
"event-exporter-deploy": {&api.ServiceAccount{}, &rbac.ClusterRoleBinding{}, &extensions.Deployment{}},
|
||||
"fluentd-gcp-configmap": {&api.ConfigMap{}},
|
||||
"fluentd-gcp-ds": {&extensions.DaemonSet{}},
|
||||
"nginx-dep": {&extensions.Deployment{}},
|
||||
"node-problem-detector": {&extensions.DaemonSet{}},
|
||||
"node-problem-detector-configmap": {&extensions.DaemonSet{}},
|
||||
"shell-demo": {&api.Pod{}},
|
||||
"termination": {&api.Pod{}},
|
||||
},
|
||||
// TODO: decide whether federation examples should be added
|
||||
"docs/tasks/inject-data-application": {
|
||||
@@ -456,8 +456,8 @@ func TestExampleObjectSchemas(t *testing.T) {
|
||||
"secret-pod": {&api.Pod{}},
|
||||
},
|
||||
"docs/tasks/job": {
|
||||
"cronjob": {&batch.CronJob{}},
|
||||
"job": {&batch.Job{}},
|
||||
"cronjob": {&batch.CronJob{}},
|
||||
"job": {&batch.Job{}},
|
||||
},
|
||||
"docs/tasks/job/coarse-parallel-processing-work-queue": {
|
||||
"job": {&batch.Job{}},
|
||||
@@ -620,12 +620,19 @@ func TestExampleObjectSchemas(t *testing.T) {
|
||||
var sampleRegexp = regexp.MustCompile("(?ms)^```(?:(?P<type>yaml)\\w*\\n(?P<content>.+?)|\\w*\\n(?P<content>\\{.+?\\}))\\n^```")
|
||||
var subsetRegexp = regexp.MustCompile("(?ms)\\.{3}")
|
||||
|
||||
// Validates examples embedded in Markdown files.
|
||||
func TestReadme(t *testing.T) {
|
||||
// BlockVolume required for local volume example
|
||||
utilfeature.DefaultFeatureGate.Set("BlockVolume=true")
|
||||
|
||||
paths := []struct {
|
||||
file string
|
||||
expectedType []runtime.Object
|
||||
expectedType []runtime.Object // List of all valid types for the whole doc
|
||||
}{
|
||||
{"../content/en/docs/concepts/storage/volumes.md", []runtime.Object{&api.Pod{}}},
|
||||
{"../content/en/docs/concepts/storage/volumes.md", []runtime.Object{
|
||||
&api.Pod{},
|
||||
&api.PersistentVolume{},
|
||||
}},
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
@@ -639,7 +646,6 @@ func TestReadme(t *testing.T) {
|
||||
if matches == nil {
|
||||
continue
|
||||
}
|
||||
ix := 0
|
||||
for _, match := range matches {
|
||||
var content, subtype string
|
||||
for i, name := range sampleRegexp.SubexpNames() {
|
||||
@@ -655,21 +661,23 @@ func TestReadme(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
var expectedType runtime.Object
|
||||
if len(path.expectedType) == 1 {
|
||||
expectedType = path.expectedType[0]
|
||||
} else {
|
||||
expectedType = path.expectedType[ix]
|
||||
ix++
|
||||
}
|
||||
json, err := yaml.ToJSON([]byte(content))
|
||||
if err != nil {
|
||||
t.Errorf("%s could not be converted to JSON: %v\n%s", path, err, string(content))
|
||||
}
|
||||
if err := runtime.DecodeInto(testapi.Default.Codec(), json, expectedType); err != nil {
|
||||
|
||||
var expectedType runtime.Object
|
||||
for _, expectedType = range path.expectedType {
|
||||
err = runtime.DecodeInto(testapi.Default.Codec(), json, expectedType)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(content))
|
||||
continue
|
||||
}
|
||||
|
||||
if errors := validateObject(expectedType); len(errors) > 0 {
|
||||
t.Errorf("%s did not validate correctly: %v", path, errors)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user