Exemplo n.º 1
0
func init() {
	capabilities.SetForTests(capabilities.Capabilities{
		AllowPrivileged: true,
	})
	flag.Set("v", "5")
	capnslog.SetGlobalLogLevel(capnslog.DEBUG)
	capnslog.SetFormatter(capnslog.NewGlogFormatter(os.Stderr))
}
Exemplo n.º 2
0
func init() {
	capabilities.SetForTests(capabilities.Capabilities{
		AllowPrivileged: true,
	})
	flag.Set("v", "5")
	if len(os.Getenv("OS_TEST_VERBOSE_ETCD")) > 0 {
		capnslog.SetGlobalLogLevel(capnslog.DEBUG)
		capnslog.SetFormatter(capnslog.NewGlogFormatter(os.Stderr))
	} else {
		capnslog.SetGlobalLogLevel(capnslog.INFO)
		capnslog.SetFormatter(capnslog.NewGlogFormatter(os.Stderr))
	}
}
Exemplo n.º 3
0
func TestExampleObjectSchemas(t *testing.T) {
	cases := map[string]map[string]runtime.Object{
		"../cmd/integration": {
			"v1-controller": &api.ReplicationController{},
		},
		"../examples/guestbook": {
			"frontend-controller":     &api.ReplicationController{},
			"redis-slave-controller":  &api.ReplicationController{},
			"redis-master-controller": &api.ReplicationController{},
			"frontend-service":        &api.Service{},
			"redis-master-service":    &api.Service{},
			"redis-slave-service":     &api.Service{},
		},
		"../examples/guestbook-go": {
			"guestbook-controller":    &api.ReplicationController{},
			"redis-slave-controller":  &api.ReplicationController{},
			"redis-master-controller": &api.ReplicationController{},
			"guestbook-service":       &api.Service{},
			"redis-master-service":    &api.Service{},
			"redis-slave-service":     &api.Service{},
		},
		"../docs/user-guide/walkthrough": {
			"pod-nginx":                 &api.Pod{},
			"pod-nginx-with-label":      &api.Pod{},
			"pod-redis":                 &api.Pod{},
			"pod-with-http-healthcheck": &api.Pod{},
			"service":                   &api.Service{},
			"replication-controller":    &api.ReplicationController{},
			"podtemplate":               &api.PodTemplate{},
		},
		"../docs/user-guide/update-demo": {
			"kitten-rc":   &api.ReplicationController{},
			"nautilus-rc": &api.ReplicationController{},
		},
		"../docs/user-guide/persistent-volumes/volumes": {
			"local-01": &api.PersistentVolume{},
			"local-02": &api.PersistentVolume{},
			"gce":      &api.PersistentVolume{},
			"nfs":      &api.PersistentVolume{},
		},
		"../docs/user-guide/persistent-volumes/claims": {
			"claim-01": &api.PersistentVolumeClaim{},
			"claim-02": &api.PersistentVolumeClaim{},
			"claim-03": &api.PersistentVolumeClaim{},
		},
		"../docs/user-guide/persistent-volumes/simpletest": {
			"namespace": &api.Namespace{},
			"pod":       &api.Pod{},
			"service":   &api.Service{},
		},
		"../examples/iscsi": {
			"iscsi": &api.Pod{},
		},
		"../examples/glusterfs": {
			"glusterfs-pod":       &api.Pod{},
			"glusterfs-endpoints": &api.Endpoints{},
			"glusterfs-service":   &api.Service{},
		},
		"../docs/user-guide/liveness": {
			"exec-liveness": &api.Pod{},
			"http-liveness": &api.Pod{},
		},
		"../docs/user-guide": {
			"multi-pod":            nil,
			"pod":                  &api.Pod{},
			"job":                  &extensions.Job{},
			"ingress":              &extensions.Ingress{},
			"nginx-deployment":     &extensions.Deployment{},
			"new-nginx-deployment": &extensions.Deployment{},
		},
		"../docs/admin": {
			"daemon": &extensions.DaemonSet{},
		},
		"../examples": {
			"scheduler-policy-config":               &schedulerapi.Policy{},
			"scheduler-policy-config-with-extender": &schedulerapi.Policy{},
		},
		"../examples/rbd/secret": {
			"ceph-secret": &api.Secret{},
		},
		"../examples/rbd": {
			"rbd":             &api.Pod{},
			"rbd-with-secret": &api.Pod{},
		},
		"../examples/cassandra": {
			"cassandra-daemonset":  &extensions.DaemonSet{},
			"cassandra-controller": &api.ReplicationController{},
			"cassandra-service":    &api.Service{},
			"cassandra":            &api.Pod{},
		},
		"../examples/celery-rabbitmq": {
			"celery-controller":   &api.ReplicationController{},
			"flower-controller":   &api.ReplicationController{},
			"flower-service":      &api.Service{},
			"rabbitmq-controller": &api.ReplicationController{},
			"rabbitmq-service":    &api.Service{},
		},
		"../examples/cluster-dns": {
			"dns-backend-rc":      &api.ReplicationController{},
			"dns-backend-service": &api.Service{},
			"dns-frontend-pod":    &api.Pod{},
			"namespace-dev":       &api.Namespace{},
			"namespace-prod":      &api.Namespace{},
		},
		"../docs/user-guide/downward-api": {
			"dapi-pod": &api.Pod{},
		},
		"../docs/user-guide/downward-api/volume/": {
			"dapi-volume": &api.Pod{},
		},
		"../examples/elasticsearch": {
			"es-rc":           &api.ReplicationController{},
			"es-svc":          &api.Service{},
			"service-account": nil,
		},
		"../examples/explorer": {
			"pod": &api.Pod{},
		},
		"../examples/hazelcast": {
			"hazelcast-controller": &api.ReplicationController{},
			"hazelcast-service":    &api.Service{},
		},
		"../docs/admin/namespaces": {
			"namespace-dev":  &api.Namespace{},
			"namespace-prod": &api.Namespace{},
		},
		"../docs/admin/limitrange": {
			"invalid-pod": &api.Pod{},
			"limits":      &api.LimitRange{},
			"namespace":   &api.Namespace{},
			"valid-pod":   &api.Pod{},
		},
		"../docs/user-guide/logging-demo": {
			"synthetic_0_25lps": &api.Pod{},
			"synthetic_10lps":   &api.Pod{},
		},
		"../examples/meteor": {
			"meteor-controller": &api.ReplicationController{},
			"meteor-service":    &api.Service{},
			"mongo-pod":         &api.Pod{},
			"mongo-service":     &api.Service{},
		},
		"../examples/mysql-wordpress-pd": {
			"mysql-service":     &api.Service{},
			"mysql":             &api.Pod{},
			"wordpress-service": &api.Service{},
			"wordpress":         &api.Pod{},
		},
		"../examples/nfs": {
			"nfs-busybox-rc":     &api.ReplicationController{},
			"nfs-server-rc":      &api.ReplicationController{},
			"nfs-server-service": &api.Service{},
			"nfs-pv":             &api.PersistentVolume{},
			"nfs-pvc":            &api.PersistentVolumeClaim{},
			"nfs-web-rc":         &api.ReplicationController{},
			"nfs-web-service":    &api.Service{},
		},
		"../docs/user-guide/node-selection": {
			"pod": &api.Pod{},
			"pod-with-node-affinity": &api.Pod{},
		},
		"../examples/openshift-origin": {
			"openshift-origin-namespace": &api.Namespace{},
			"openshift-controller":       &api.ReplicationController{},
			"openshift-service":          &api.Service{},
			"etcd-controller":            &api.ReplicationController{},
			"etcd-service":               &api.Service{},
			"etcd-discovery-controller":  &api.ReplicationController{},
			"etcd-discovery-service":     &api.Service{},
			"secret":                     nil,
		},
		"../examples/phabricator": {
			"phabricator-controller": &api.ReplicationController{},
			"phabricator-service":    &api.Service{},
		},
		"../examples/redis": {
			"redis-controller":          &api.ReplicationController{},
			"redis-master":              &api.Pod{},
			"redis-proxy":               &api.Pod{},
			"redis-sentinel-controller": &api.ReplicationController{},
			"redis-sentinel-service":    &api.Service{},
		},
		"../docs/admin/resourcequota": {
			"namespace": &api.Namespace{},
			"limits":    &api.LimitRange{},
			"quota":     &api.ResourceQuota{},
		},
		"../examples/rethinkdb": {
			"admin-pod":      &api.Pod{},
			"admin-service":  &api.Service{},
			"driver-service": &api.Service{},
			"rc":             &api.ReplicationController{},
		},
		"../docs/user-guide/secrets": {
			"secret-pod":     &api.Pod{},
			"secret":         &api.Secret{},
			"secret-env-pod": &api.Pod{},
		},
		"../examples/spark": {
			"spark-master-controller": &api.ReplicationController{},
			"spark-master-service":    &api.Service{},
			"spark-webui":             &api.Service{},
			"spark-worker-controller": &api.ReplicationController{},
			"zeppelin-controller":     &api.ReplicationController{},
			"zeppelin-service":        &api.Service{},
		},
		"../examples/spark/spark-gluster": {
			"spark-master-service":    &api.Service{},
			"spark-master-controller": &api.ReplicationController{},
			"spark-worker-controller": &api.ReplicationController{},
			"glusterfs-endpoints":     &api.Endpoints{},
		},
		"../examples/storm": {
			"storm-nimbus-service":    &api.Service{},
			"storm-nimbus":            &api.Pod{},
			"storm-worker-controller": &api.ReplicationController{},
			"zookeeper-service":       &api.Service{},
			"zookeeper":               &api.Pod{},
		},
		"../examples/cephfs/": {
			"cephfs":             &api.Pod{},
			"cephfs-with-secret": &api.Pod{},
		},
		"../examples/fibre_channel": {
			"fc": &api.Pod{},
		},
		"../examples/extensions": {
			"deployment": &extensions.Deployment{},
		},
		"../examples/javaweb-tomcat-sidecar": {
			"javaweb":   &api.Pod{},
			"javaweb-2": &api.Pod{},
		},
		"../examples/job/work-queue-1": {
			"job": &extensions.Job{},
		},
		"../examples/job/work-queue-2": {
			"redis-pod":     &api.Pod{},
			"redis-service": &api.Service{},
			"job":           &extensions.Job{},
		},
	}

	capabilities.SetForTests(capabilities.Capabilities{
		AllowPrivileged: true,
	})

	for path, expected := range cases {
		tested := 0
		err := walkJSONFiles(path, func(name, path string, data []byte) {
			expectedType, found := expected[name]
			if !found {
				t.Errorf("%s: %s does not have a test case defined", path, name)
				return
			}
			tested++
			if expectedType == nil {
				t.Logf("skipping : %s/%s\n", path, name)
				return
			}
			if strings.Contains(name, "scheduler-policy-config") {
				if err := runtime.DecodeInto(schedulerapilatest.Codec, data, expectedType); err != nil {
					t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
					return
				}
				//TODO: Add validate method for &schedulerapi.Policy
			} else {
				codec, err := testapi.GetCodecForObject(expectedType)
				if err != nil {
					t.Errorf("Could not get codec for %s: %s", expectedType, err)
				}
				if err := runtime.DecodeInto(codec, data, expectedType); err != nil {
					t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
					return
				}
				if errors := validateObject(expectedType); len(errors) > 0 {
					t.Errorf("%s did not validate correctly: %v", path, errors)
				}
			}
		})
		if err != nil {
			t.Errorf("Expected no error, Got %v", err)
		}
		if tested != len(expected) {
			t.Errorf("Directory %v: Expected %d examples, Got %d", path, len(expected), tested)
		}
	}
}
Exemplo n.º 4
0
func TestExampleObjectSchemas(t *testing.T) {
	cases := map[string]map[string]runtime.Object{
		"../examples/guestbook": {
			"frontend-deployment":     &extensions.Deployment{},
			"redis-slave-deployment":  &extensions.Deployment{},
			"redis-master-deployment": &extensions.Deployment{},
			"frontend-service":        &api.Service{},
			"redis-master-service":    &api.Service{},
			"redis-slave-service":     &api.Service{},
		},
		"../examples/guestbook/legacy": {
			"frontend-controller":     &api.ReplicationController{},
			"redis-slave-controller":  &api.ReplicationController{},
			"redis-master-controller": &api.ReplicationController{},
		},
		"../examples/guestbook-go": {
			"guestbook-controller":    &api.ReplicationController{},
			"redis-slave-controller":  &api.ReplicationController{},
			"redis-master-controller": &api.ReplicationController{},
			"guestbook-service":       &api.Service{},
			"redis-master-service":    &api.Service{},
			"redis-slave-service":     &api.Service{},
		},
		"../examples/volumes/iscsi": {
			"iscsi": &api.Pod{},
		},
		"../examples/volumes/glusterfs": {
			"glusterfs-pod":       &api.Pod{},
			"glusterfs-endpoints": &api.Endpoints{},
			"glusterfs-service":   &api.Service{},
		},
		"../examples": {
			"scheduler-policy-config":               &schedulerapi.Policy{},
			"scheduler-policy-config-with-extender": &schedulerapi.Policy{},
		},
		"../examples/volumes/rbd/secret": {
			"ceph-secret": &api.Secret{},
		},
		"../examples/volumes/rbd": {
			"rbd":             &api.Pod{},
			"rbd-with-secret": &api.Pod{},
		},
		"../examples/storage/cassandra": {
			"cassandra-daemonset":  &extensions.DaemonSet{},
			"cassandra-controller": &api.ReplicationController{},
			"cassandra-service":    &api.Service{},
			"cassandra-petset":     &apps.PetSet{},
		},
		"../examples/cluster-dns": {
			"dns-backend-rc":      &api.ReplicationController{},
			"dns-backend-service": &api.Service{},
			"dns-frontend-pod":    &api.Pod{},
			"namespace-dev":       &api.Namespace{},
			"namespace-prod":      &api.Namespace{},
		},
		"../examples/elasticsearch": {
			"es-rc":           &api.ReplicationController{},
			"es-svc":          &api.Service{},
			"service-account": nil,
		},
		"../examples/explorer": {
			"pod": &api.Pod{},
		},
		"../examples/storage/hazelcast": {
			"hazelcast-controller": &api.ReplicationController{},
			"hazelcast-service":    &api.Service{},
		},
		"../examples/meteor": {
			"meteor-controller": &api.ReplicationController{},
			"meteor-service":    &api.Service{},
			"mongo-pod":         &api.Pod{},
			"mongo-service":     &api.Service{},
		},
		"../examples/mysql-wordpress-pd": {
			"gce-volumes":          &api.PersistentVolume{},
			"local-volumes":        &api.PersistentVolume{},
			"mysql-deployment":     &api.Service{},
			"wordpress-deployment": &api.Service{},
		},
		"../examples/volumes/nfs": {
			"nfs-busybox-rc":     &api.ReplicationController{},
			"nfs-server-rc":      &api.ReplicationController{},
			"nfs-server-service": &api.Service{},
			"nfs-pv":             &api.PersistentVolume{},
			"nfs-pvc":            &api.PersistentVolumeClaim{},
			"nfs-web-rc":         &api.ReplicationController{},
			"nfs-web-service":    &api.Service{},
		},
		"../examples/openshift-origin": {
			"openshift-origin-namespace": &api.Namespace{},
			"openshift-controller":       &api.ReplicationController{},
			"openshift-service":          &api.Service{},
			"etcd-controller":            &api.ReplicationController{},
			"etcd-service":               &api.Service{},
			"etcd-discovery-controller":  &api.ReplicationController{},
			"etcd-discovery-service":     &api.Service{},
			"secret":                     nil,
		},
		"../examples/phabricator": {
			"phabricator-controller": &api.ReplicationController{},
			"phabricator-service":    &api.Service{},
		},
		"../examples/storage/redis": {
			"redis-controller":          &api.ReplicationController{},
			"redis-master":              &api.Pod{},
			"redis-proxy":               &api.Pod{},
			"redis-sentinel-controller": &api.ReplicationController{},
			"redis-sentinel-service":    &api.Service{},
		},
		"../examples/storage/rethinkdb": {
			"admin-pod":      &api.Pod{},
			"admin-service":  &api.Service{},
			"driver-service": &api.Service{},
			"rc":             &api.ReplicationController{},
		},
		"../examples/spark": {
			"namespace-spark-cluster": &api.Namespace{},
			"spark-master-controller": &api.ReplicationController{},
			"spark-master-service":    &api.Service{},
			"spark-webui":             &api.Service{},
			"spark-worker-controller": &api.ReplicationController{},
			"zeppelin-controller":     &api.ReplicationController{},
			"zeppelin-service":        &api.Service{},
		},
		"../examples/spark/spark-gluster": {
			"spark-master-service":    &api.Service{},
			"spark-master-controller": &api.ReplicationController{},
			"spark-worker-controller": &api.ReplicationController{},
			"glusterfs-endpoints":     &api.Endpoints{},
		},
		"../examples/storm": {
			"storm-nimbus-service":    &api.Service{},
			"storm-nimbus":            &api.Pod{},
			"storm-worker-controller": &api.ReplicationController{},
			"zookeeper-service":       &api.Service{},
			"zookeeper":               &api.Pod{},
		},
		"../examples/volumes/cephfs/": {
			"cephfs":             &api.Pod{},
			"cephfs-with-secret": &api.Pod{},
		},
		"../examples/volumes/fibre_channel": {
			"fc": &api.Pod{},
		},
		"../examples/javaweb-tomcat-sidecar": {
			"javaweb":   &api.Pod{},
			"javaweb-2": &api.Pod{},
		},
		"../examples/volumes/azure_file": {
			"azure": &api.Pod{},
		},
		"../examples/volumes/azure_disk": {
			"azure": &api.Pod{},
		},
	}

	capabilities.SetForTests(capabilities.Capabilities{
		AllowPrivileged: true,
	})

	for path, expected := range cases {
		tested := 0
		err := walkJSONFiles(path, func(name, path string, data []byte) {
			expectedType, found := expected[name]
			if !found {
				t.Errorf("%s: %s does not have a test case defined", path, name)
				return
			}
			tested++
			if expectedType == nil {
				t.Logf("skipping : %s/%s\n", path, name)
				return
			}
			if strings.Contains(name, "scheduler-policy-config") {
				if err := runtime.DecodeInto(schedulerapilatest.Codec, data, expectedType); err != nil {
					t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
					return
				}
				//TODO: Add validate method for &schedulerapi.Policy
			} else {
				codec, err := testapi.GetCodecForObject(expectedType)
				if err != nil {
					t.Errorf("Could not get codec for %s: %s", expectedType, err)
				}
				if err := runtime.DecodeInto(codec, data, expectedType); err != nil {
					t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
					return
				}
				if errors := validateObject(expectedType); len(errors) > 0 {
					t.Errorf("%s did not validate correctly: %v", path, errors)
				}
			}
		})
		if err != nil {
			t.Errorf("Expected no error, Got %v", err)
		}
		if tested != len(expected) {
			t.Errorf("Directory %v: Expected %d examples, Got %d", path, len(expected), tested)
		}
	}
}
Exemplo n.º 5
0
func init() {
	capabilities.SetForTests(capabilities.Capabilities{
		AllowPrivileged: true,
	})
	flag.Set("v", "5")
}
func TestExampleObjectSchemas(t *testing.T) {
	cases := map[string]map[string][]runtime.Object{
		"../docs/user-guide/walkthrough": {
			"deployment":                {&extensions.Deployment{}},
			"deployment-update":         {&extensions.Deployment{}},
			"pod-nginx":                 {&api.Pod{}},
			"pod-nginx-with-label":      {&api.Pod{}},
			"pod-redis":                 {&api.Pod{}},
			"pod-with-http-healthcheck": {&api.Pod{}},
			"podtemplate":               {&api.PodTemplate{}},
			"service":                   {&api.Service{}},
		},
		"../docs/user-guide/update-demo": {
			"kitten-rc":   {&api.ReplicationController{}},
			"nautilus-rc": {&api.ReplicationController{}},
		},
		"../docs/user-guide/persistent-volumes/volumes": {
			"local-01": {&api.PersistentVolume{}},
			"local-02": {&api.PersistentVolume{}},
			"gce":      {&api.PersistentVolume{}},
			"nfs":      {&api.PersistentVolume{}},
		},
		"../docs/user-guide/persistent-volumes/claims": {
			"claim-01": {&api.PersistentVolumeClaim{}},
			"claim-02": {&api.PersistentVolumeClaim{}},
			"claim-03": {&api.PersistentVolumeClaim{}},
		},
		"../docs/user-guide/persistent-volumes/simpletest": {
			"namespace": {&api.Namespace{}},
			"pod":       {&api.Pod{}},
			"service":   {&api.Service{}},
		},
		"../docs/user-guide/liveness": {
			"exec-liveness":            {&api.Pod{}},
			"http-liveness":            {&api.Pod{}},
			"http-liveness-named-port": {&api.Pod{}},
		},
		"../docs/user-guide/jobs/work-queue-1": {
			"job": {&batch.Job{}},
		},
		"../docs/user-guide/jobs/work-queue-2": {
			"job":           {&batch.Job{}},
			"redis-pod":     {&api.Pod{}},
			"redis-service": {&api.Service{}},
		},
		"../docs/user-guide": {
			"bad-nginx-deployment":       {&extensions.Deployment{}},
			"counter-pod":                {&api.Pod{}},
			"curlpod":                    {&extensions.Deployment{}},
			"deployment":                 {&extensions.Deployment{}},
			"ingress":                    {&extensions.Ingress{}},
			"job":                        {&batch.Job{}},
			"multi-pod":                  {&api.Pod{}, &api.Pod{}},
			"new-nginx-deployment":       {&extensions.Deployment{}},
			"nginx-app":                  {&api.Service{}, &extensions.Deployment{}},
			"nginx-deployment":           {&extensions.Deployment{}},
			"nginx-init-containers":      {&api.Pod{}},
			"nginx-lifecycle-deployment": {&extensions.Deployment{}},
			"nginx-probe-deployment":     {&extensions.Deployment{}},
			"nginx-secure-app":           {&api.Service{}, &extensions.Deployment{}},
			"nginx-svc":                  {&api.Service{}},
			"petset":                     {&api.Service{}, nil},
			"pod":                        {&api.Pod{}},
			"pod-w-message":              {&api.Pod{}},
			"redis-deployment":           {&extensions.Deployment{}},
			"redis-resource-deployment":  {&extensions.Deployment{}},
			"redis-secret-deployment":    {&extensions.Deployment{}},
			"run-my-nginx":               {&extensions.Deployment{}},
			"cronjob":                    {&batch.CronJob{}},
		},
		"../docs/admin": {
			"daemon": {&extensions.DaemonSet{}},
		},
		"../docs/user-guide/downward-api": {
			"dapi-pod":                 {&api.Pod{}},
			"dapi-container-resources": {&api.Pod{}},
		},
		"../docs/user-guide/downward-api/volume/": {
			"dapi-volume":           {&api.Pod{}},
			"dapi-volume-resources": {&api.Pod{}},
		},
		"../docs/admin/namespaces": {
			"namespace-dev":  {&api.Namespace{}},
			"namespace-prod": {&api.Namespace{}},
		},
		"../docs/admin/limitrange": {
			"invalid-pod": {&api.Pod{}},
			"limits":      {&api.LimitRange{}},
			"namespace":   {&api.Namespace{}},
			"valid-pod":   {&api.Pod{}},
		},
		"../docs/user-guide/logging-demo": {
			"synthetic_0_25lps": {&api.Pod{}},
			"synthetic_10lps":   {&api.Pod{}},
		},
		"../docs/user-guide/node-selection": {
			"pod": {&api.Pod{}},
			"pod-with-node-affinity": {&api.Pod{}},
			"pod-with-pod-affinity":  {&api.Pod{}},
		},
		"../docs/admin/resourcequota": {
			"best-effort":       {&api.ResourceQuota{}},
			"compute-resources": {&api.ResourceQuota{}},
			"limits":            {&api.LimitRange{}},
			"namespace":         {&api.Namespace{}},
			"not-best-effort":   {&api.ResourceQuota{}},
			"object-counts":     {&api.ResourceQuota{}},
		},
		"../docs/user-guide/secrets": {
			"secret-pod":     {&api.Pod{}},
			"secret":         {&api.Secret{}},
			"secret-env-pod": {&api.Pod{}},
		},
		"../docs/tutorials/stateful-application": {
			"gce-volume":        {&api.PersistentVolume{}},
			"mysql-deployment":  {&api.Service{}, &api.PersistentVolumeClaim{}, &extensions.Deployment{}},
			"mysql-services":    {&api.Service{}, &api.Service{}},
			"mysql-configmap":   {&api.ConfigMap{}},
			"mysql-statefulset": {&apps.StatefulSet{}},
			"web":               {&api.Service{}, &apps.StatefulSet{}},
			"zookeeper":         {&api.Service{}, &api.ConfigMap{}, &policy.PodDisruptionBudget{}, &apps.StatefulSet{}},
		},
	}

	capabilities.SetForTests(capabilities.Capabilities{
		AllowPrivileged: true,
	})

	for path, expected := range cases {
		tested := 0
		numExpected := 0
		err := walkConfigFiles(path, func(name, path string, docs [][]byte) {
			expectedTypes, found := expected[name]
			if !found {
				t.Errorf("%s: %s does not have a test case defined", path, name)
				return
			}
			numExpected += len(expectedTypes)
			if len(expectedTypes) != len(docs) {
				t.Errorf("%s: number of expected types (%v) doesn't match number of docs in YAML (%v)", path, len(expectedTypes), len(docs))
				return
			}
			for i, data := range docs {
				expectedType := expectedTypes[i]
				tested++
				if expectedType == nil {
					t.Logf("skipping : %s/%s\n", path, name)
					return
				}
				if strings.Contains(name, "scheduler-policy-config") {
					if err := runtime.DecodeInto(schedulerapilatest.Codec, data, expectedType); err != nil {
						t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
						return
					}
					// TODO: Add validate method for
					// &schedulerapi.Policy, and remove this
					// special case
				} else {
					codec, err := testapi.GetCodecForObject(expectedType)
					if err != nil {
						t.Errorf("Could not get codec for %s: %s", expectedType, err)
					}
					if err := runtime.DecodeInto(codec, data, expectedType); err != nil {
						t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
						return
					}
					if errors := validateObject(expectedType); len(errors) > 0 {
						t.Errorf("%s did not validate correctly: %v", path, errors)
					}
				}
			}
		})
		if err != nil {
			t.Errorf("Expected no error, Got %v on Path %v", err, path)
		}
		if tested != numExpected {
			t.Errorf("Directory %v: Expected %d examples, Got %d", path, len(expected), tested)
		}
	}
}