| ... | ... |
@@ -30,6 +30,10 @@ func (s FakeBuildConfigStore) List() []interface{} {
|
| 30 | 30 |
return []interface{}{s.Build}
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 |
+func (s FakeBuildConfigStore) ListKeys() []string {
|
|
| 34 |
+ return []string{"config"}
|
|
| 35 |
+} |
|
| 36 |
+ |
|
| 33 | 37 |
func (s FakeBuildConfigStore) ContainedIDs() util.StringSet {
|
| 34 | 38 |
return util.NewStringSet() |
| 35 | 39 |
} |
| ... | ... |
@@ -30,6 +30,10 @@ func (s FakeBuildStore) List() []interface{} {
|
| 30 | 30 |
return []interface{}{s.Build}
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 |
+func (s FakeBuildStore) ListKeys() []string {
|
|
| 34 |
+ return []string{"build"}
|
|
| 35 |
+} |
|
| 36 |
+ |
|
| 33 | 37 |
func (s FakeBuildStore) ContainedIDs() util.StringSet {
|
| 34 | 38 |
return util.NewStringSet() |
| 35 | 39 |
} |
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 | 7 |
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
| 8 |
- kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client" |
|
| 8 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient" |
|
| 9 | 9 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl" |
| 10 | 10 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
| 11 |
- "github.com/openshift/origin/pkg/client" |
|
| 12 | 11 |
|
| 12 |
+ "github.com/openshift/origin/pkg/client" |
|
| 13 | 13 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 14 | 14 |
deployapitest "github.com/openshift/origin/pkg/deploy/api/test" |
| 15 | 15 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| ... | ... |
@@ -30,7 +30,7 @@ func TestDescribeFor(t *testing.T) {
|
| 30 | 30 |
"Route", "Project", |
| 31 | 31 |
} |
| 32 | 32 |
for _, o := range testTypesList {
|
| 33 |
- _, ok := DescriberFor(o, c, &kclient.Fake{}, "")
|
|
| 33 |
+ _, ok := DescriberFor(o, c, &testclient.Fake{}, "")
|
|
| 34 | 34 |
if !ok {
|
| 35 | 35 |
t.Errorf("Unable to obtain describer for %s", o)
|
| 36 | 36 |
} |
| ... | ... |
@@ -716,9 +716,12 @@ func expectedService(name string, port int, proto kapi.Protocol) map[string]kapi |
| 716 | 716 |
Name: name, |
| 717 | 717 |
}, |
| 718 | 718 |
Spec: kapi.ServiceSpec{
|
| 719 |
- Port: port, |
|
| 720 |
- Protocol: proto, |
|
| 721 |
- TargetPort: util.NewIntOrStringFromInt(port), |
|
| 719 |
+ Ports: []kapi.ServicePort{{
|
|
| 720 |
+ Name: fmt.Sprintf("%s-%s-%d", name, strings.ToLower(string(proto)), port),
|
|
| 721 |
+ Port: port, |
|
| 722 |
+ Protocol: proto, |
|
| 723 |
+ TargetPort: util.NewIntOrStringFromInt(port), |
|
| 724 |
+ }}, |
|
| 722 | 725 |
Selector: map[string]string{
|
| 723 | 726 |
"deploymentconfig": name, |
| 724 | 727 |
}, |
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
| 9 | 9 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" |
| 10 |
- "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" |
|
| 11 | 10 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/user" |
| 12 | 11 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields" |
| 13 | 12 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
| ... | ... |
@@ -15,6 +14,8 @@ import ( |
| 15 | 15 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools" |
| 16 | 16 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
| 17 | 17 |
"github.com/coreos/go-etcd/etcd" |
| 18 |
+ |
|
| 19 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 18 | 20 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
| 19 | 21 |
"github.com/openshift/origin/pkg/authorization/registry/subjectaccessreview" |
| 20 | 22 |
"github.com/openshift/origin/pkg/image/api" |
| ... | ... |
@@ -7,7 +7,7 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
| 9 | 9 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/user" |
| 10 |
- kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client" |
|
| 10 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient" |
|
| 11 | 11 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
| 12 | 12 |
"github.com/openshift/origin/pkg/client" |
| 13 | 13 |
) |
| ... | ... |
@@ -94,7 +94,7 @@ func TestSyncNamespace(t *testing.T) {
|
| 94 | 94 |
}, |
| 95 | 95 |
}, |
| 96 | 96 |
} |
| 97 |
- mockKubeClient := &kclient.Fake{NamespacesList: namespaceList}
|
|
| 97 |
+ mockKubeClient := testclient.NewSimpleFake(&namespaceList) |
|
| 98 | 98 |
mockOriginClient := &client.Fake{}
|
| 99 | 99 |
|
| 100 | 100 |
reviewer := &mockReviewer{
|
| ... | ... |
@@ -4,14 +4,14 @@ import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
| 7 |
- kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client" |
|
| 7 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient" |
|
| 8 | 8 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
| 9 | 9 |
osclient "github.com/openshift/origin/pkg/client" |
| 10 | 10 |
"github.com/openshift/origin/pkg/project/api" |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
func TestSyncNamespaceThatIsTerminating(t *testing.T) {
|
| 14 |
- mockKubeClient := &kclient.Fake{}
|
|
| 14 |
+ mockKubeClient := &testclient.Fake{}
|
|
| 15 | 15 |
mockOriginClient := &osclient.Fake{}
|
| 16 | 16 |
nm := NamespaceController{
|
| 17 | 17 |
KubeClient: mockKubeClient, |
| ... | ... |
@@ -61,7 +61,7 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) {
|
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 | 63 |
func TestSyncNamespaceThatIsActive(t *testing.T) {
|
| 64 |
- mockKubeClient := &kclient.Fake{}
|
|
| 64 |
+ mockKubeClient := &testclient.Fake{}
|
|
| 65 | 65 |
mockOriginClient := &osclient.Fake{}
|
| 66 | 66 |
nm := NamespaceController{
|
| 67 | 67 |
KubeClient: mockKubeClient, |
| ... | ... |
@@ -8,9 +8,10 @@ import ( |
| 8 | 8 |
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
| 9 | 9 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" |
| 10 | 10 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/user" |
| 11 |
- kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client" |
|
| 11 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient" |
|
| 12 | 12 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields" |
| 13 | 13 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
| 14 |
+ |
|
| 14 | 15 |
"github.com/openshift/origin/pkg/project/api" |
| 15 | 16 |
) |
| 16 | 17 |
|
| ... | ... |
@@ -31,9 +32,7 @@ func TestListProjects(t *testing.T) {
|
| 31 | 31 |
}, |
| 32 | 32 |
}, |
| 33 | 33 |
} |
| 34 |
- mockClient := &kclient.Fake{
|
|
| 35 |
- NamespacesList: namespaceList, |
|
| 36 |
- } |
|
| 34 |
+ mockClient := testclient.NewSimpleFake(&namespaceList) |
|
| 37 | 35 |
storage := REST{
|
| 38 | 36 |
client: mockClient.Namespaces(), |
| 39 | 37 |
lister: &mockLister{&namespaceList},
|
| ... | ... |
@@ -71,7 +70,7 @@ func TestCreateProjectBadObject(t *testing.T) {
|
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 | 73 |
func TestCreateInvalidProject(t *testing.T) {
|
| 74 |
- mockClient := &kclient.Fake{}
|
|
| 74 |
+ mockClient := &testclient.Fake{}
|
|
| 75 | 75 |
storage := NewREST(mockClient.Namespaces(), &mockLister{})
|
| 76 | 76 |
_, err := storage.Create(nil, &api.Project{
|
| 77 | 77 |
DisplayName: "h\t\ni", |
| ... | ... |
@@ -82,7 +81,7 @@ func TestCreateInvalidProject(t *testing.T) {
|
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 | 84 |
func TestCreateProjectOK(t *testing.T) {
|
| 85 |
- mockClient := &kclient.Fake{}
|
|
| 85 |
+ mockClient := &testclient.Fake{}
|
|
| 86 | 86 |
storage := NewREST(mockClient.Namespaces(), &mockLister{})
|
| 87 | 87 |
_, err := storage.Create(kapi.NewContext(), &api.Project{
|
| 88 | 88 |
ObjectMeta: kapi.ObjectMeta{Name: "foo"},
|
| ... | ... |
@@ -99,7 +98,7 @@ func TestCreateProjectOK(t *testing.T) {
|
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 | 101 |
func TestGetProjectOK(t *testing.T) {
|
| 102 |
- mockClient := &kclient.Fake{}
|
|
| 102 |
+ mockClient := testclient.NewSimpleFake(&kapi.Namespace{ObjectMeta: kapi.ObjectMeta{Name: "foo"}})
|
|
| 103 | 103 |
storage := NewREST(mockClient.Namespaces(), &mockLister{})
|
| 104 | 104 |
project, err := storage.Get(kapi.NewContext(), "foo") |
| 105 | 105 |
if project == nil {
|
| ... | ... |
@@ -114,7 +113,7 @@ func TestGetProjectOK(t *testing.T) {
|
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 | 116 |
func TestDeleteProject(t *testing.T) {
|
| 117 |
- mockClient := &kclient.Fake{}
|
|
| 117 |
+ mockClient := &testclient.Fake{}
|
|
| 118 | 118 |
storage := REST{
|
| 119 | 119 |
client: mockClient.Namespaces(), |
| 120 | 120 |
} |
| ... | ... |
@@ -5,11 +5,18 @@ import ( |
| 5 | 5 |
|
| 6 | 6 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
| 7 | 7 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" |
| 8 |
- "github.com/GoogleCloudPlatform/kubernetes/pkg/client" |
|
| 8 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient" |
|
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
func TestServiceResolverCacheEmpty(t *testing.T) {
|
| 12 |
- fakeClient := &client.Fake{}
|
|
| 12 |
+ fakeClient := testclient.NewSimpleFake(&api.Service{
|
|
| 13 |
+ ObjectMeta: api.ObjectMeta{
|
|
| 14 |
+ Name: "foo", |
|
| 15 |
+ }, |
|
| 16 |
+ Spec: api.ServiceSpec{
|
|
| 17 |
+ Ports: []api.ServicePort{{Port: 80}},
|
|
| 18 |
+ }, |
|
| 19 |
+ }) |
|
| 13 | 20 |
cache := NewServiceResolverCache(fakeClient.Services("default").Get)
|
| 14 | 21 |
if v, ok := cache.resolve("FOO_SERVICE_HOST"); v != "" || !ok {
|
| 15 | 22 |
t.Errorf("unexpected cache item")
|
| ... | ... |
@@ -49,7 +56,7 @@ func TestServiceResolverCache(t *testing.T) {
|
| 49 | 49 |
service: &api.Service{
|
| 50 | 50 |
Spec: api.ServiceSpec{
|
| 51 | 51 |
PortalIP: "127.0.0.1", |
| 52 |
- Port: 80, |
|
| 52 |
+ Ports: []api.ServicePort{{Port: 80}},
|
|
| 53 | 53 |
}, |
| 54 | 54 |
}, |
| 55 | 55 |
} |
| ... | ... |
@@ -69,8 +69,12 @@ func TestNewRESTTemplateLabels(t *testing.T) {
|
| 69 | 69 |
Name: "test-service", |
| 70 | 70 |
}, |
| 71 | 71 |
Spec: kapi.ServiceSpec{
|
| 72 |
- Port: 80, |
|
| 73 |
- Protocol: kapi.ProtocolTCP, |
|
| 72 |
+ Ports: []kapi.ServicePort{
|
|
| 73 |
+ {
|
|
| 74 |
+ Port: 80, |
|
| 75 |
+ Protocol: kapi.ProtocolTCP, |
|
| 76 |
+ }, |
|
| 77 |
+ }, |
|
| 74 | 78 |
SessionAffinity: kapi.AffinityTypeNone, |
| 75 | 79 |
}, |
| 76 | 80 |
}, |
| ... | ... |
@@ -5,10 +5,12 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"io/ioutil" |
| 7 | 7 |
"math/rand" |
| 8 |
+ "strings" |
|
| 8 | 9 |
"testing" |
| 9 | 10 |
|
| 10 | 11 |
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" |
| 11 |
- "github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors" |
|
| 12 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
|
| 13 |
+ |
|
| 12 | 14 |
"github.com/openshift/origin/pkg/api/latest" |
| 13 | 15 |
"github.com/openshift/origin/pkg/template/api" |
| 14 | 16 |
"github.com/openshift/origin/pkg/template/generator" |
| ... | ... |
@@ -104,7 +106,7 @@ func TestParameterGenerators(t *testing.T) {
|
| 104 | 104 |
} |
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 |
-func ExampleProcessTemplateParameters() {
|
|
| 107 |
+func TestProcessTemplateParameters(t *testing.T) {
|
|
| 108 | 108 |
var template api.Template |
| 109 | 109 |
jsonData, _ := ioutil.ReadFile("../../test/templates/fixtures/guestbook.json")
|
| 110 | 110 |
latest.Codec.DecodeInto(jsonData, &template) |
| ... | ... |
@@ -118,16 +120,24 @@ func ExampleProcessTemplateParameters() {
|
| 118 | 118 |
AddParameter(&template, makeParameter("CUSTOM_PARAM1", "1", ""))
|
| 119 | 119 |
|
| 120 | 120 |
// Transform the template config into the result config |
| 121 |
- config, err := processor.Process(&template) |
|
| 122 |
- fmt.Println(errors.NewAggregate(err)) |
|
| 123 |
- if config != nil {
|
|
| 124 |
- result, err := latest.Codec.Encode(config) |
|
| 125 |
- if err != nil {
|
|
| 126 |
- fmt.Printf("Unexpected error during encoding Config: %#v", err)
|
|
| 127 |
- } |
|
| 128 |
- fmt.Println(string(result)) |
|
| 121 |
+ config, errs := processor.Process(&template) |
|
| 122 |
+ if len(errs) > 0 {
|
|
| 123 |
+ t.Fatalf("unexpected error: %v", errs)
|
|
| 124 |
+ } |
|
| 125 |
+ result, err := latest.Codec.Encode(config) |
|
| 126 |
+ if err != nil {
|
|
| 127 |
+ t.Fatalf("unexpected error during encoding Config: %#v", err)
|
|
| 128 |
+ } |
|
| 129 |
+ expect := ` |
|
| 130 |
+{"kind":"Config","apiVersion":"v1beta1","metadata":{"creationTimestamp":null},"items":[{"kind":"Route","apiVersion":"v1beta1","metadata":{"name":"frontend-route","creationTimestamp":null},"host":"guestbook.example.com","serviceName":"frontend-service"},
|
|
| 131 |
+{"kind":"Service","id":"frontend-service","creationTimestamp":null,"apiVersion":"v1beta1","port":5432,"protocol":"TCP","containerPort":0,"selector":{"name":"frontend-service"},"sessionAffinity":"None","ports":[{"name":"","protocol":"TCP","port":5432,"containerPort":0}]},
|
|
| 132 |
+{"kind":"Service","id":"redis-master","creationTimestamp":null,"apiVersion":"v1beta1","port":10000,"protocol":"TCP","containerPort":0,"selector":{"name":"redis-master"},"sessionAffinity":"None","ports":[{"name":"","protocol":"TCP","port":10000,"containerPort":0}]},
|
|
| 133 |
+{"kind":"Service","id":"redis-slave","creationTimestamp":null,"apiVersion":"v1beta1","port":10001,"protocol":"TCP","containerPort":0,"selector":{"name":"redis-slave"},"sessionAffinity":"None","ports":[{"name":"","protocol":"TCP","port":10001,"containerPort":0}]},
|
|
| 134 |
+{"kind":"Pod","id":"redis-master","creationTimestamp":null,"apiVersion":"v1beta1","labels":{"name":"redis-master"},"desiredState":{"manifest":{"version":"v1beta2","id":"","volumes":null,"containers":[{"name":"master","image":"dockerfile/redis","ports":[{"containerPort":6379,"protocol":"TCP"}],"env":[{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"PullIfNotPresent","capabilities":{}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"}},"currentState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}},
|
|
| 135 |
+{"kind":"ReplicationController","id":"guestbook","creationTimestamp":null,"apiVersion":"v1beta1","desiredState":{"replicas":3,"replicaSelector":{"name":"frontend-service"},"podTemplate":{"desiredState":{"manifest":{"version":"v1beta2","id":"","volumes":null,"containers":[{"name":"php-redis","image":"brendanburns/php-redis","ports":[{"hostPort":8000,"containerPort":80,"protocol":"TCP"}],"env":[{"name":"ADMIN_USERNAME","key":"ADMIN_USERNAME","value":"adminQ3H"},{"name":"ADMIN_PASSWORD","key":"ADMIN_PASSWORD","value":"dwNJiJwW"},{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"PullIfNotPresent","capabilities":{}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"}},"labels":{"name":"frontend-service"}}},"currentState":{"replicas":0,"podTemplate":{"desiredState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}}}},
|
|
| 136 |
+{"kind":"ReplicationController","id":"redis-slave","creationTimestamp":null,"apiVersion":"v1beta1","desiredState":{"replicas":2,"replicaSelector":{"name":"redis-slave"},"podTemplate":{"desiredState":{"manifest":{"version":"v1beta2","id":"","volumes":null,"containers":[{"name":"slave","image":"brendanburns/redis-slave","ports":[{"hostPort":6380,"containerPort":6379,"protocol":"TCP"}],"env":[{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"PullIfNotPresent","capabilities":{}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"}},"labels":{"name":"redis-slave"}}},"currentState":{"replicas":0,"podTemplate":{"desiredState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}}}}]}`
|
|
| 137 |
+ expect = strings.Replace(expect, "\n", "", -1) |
|
| 138 |
+ if string(result) != expect {
|
|
| 139 |
+ t.Errorf("unexpected output: %s", util.StringDiff(expect, string(result)))
|
|
| 129 | 140 |
} |
| 130 |
- // Output: |
|
| 131 |
- //<nil> |
|
| 132 |
- //{"kind":"Config","apiVersion":"v1beta1","metadata":{"creationTimestamp":null},"items":[{"kind":"Route","apiVersion":"v1beta1","metadata":{"name":"frontend-route","creationTimestamp":null},"host":"guestbook.example.com","serviceName":"frontend-service"},{"kind":"Service","id":"frontend-service","creationTimestamp":null,"apiVersion":"v1beta1","port":5432,"protocol":"TCP","selector":{"name":"frontend-service"},"containerPort":0,"sessionAffinity":"None"},{"kind":"Service","id":"redis-master","creationTimestamp":null,"apiVersion":"v1beta1","port":10000,"protocol":"TCP","selector":{"name":"redis-master"},"containerPort":0,"sessionAffinity":"None"},{"kind":"Service","id":"redis-slave","creationTimestamp":null,"apiVersion":"v1beta1","port":10001,"protocol":"TCP","selector":{"name":"redis-slave"},"containerPort":0,"sessionAffinity":"None"},{"kind":"Pod","id":"redis-master","creationTimestamp":null,"apiVersion":"v1beta1","labels":{"name":"redis-master"},"desiredState":{"manifest":{"version":"v1beta2","id":"","volumes":null,"containers":[{"name":"master","image":"dockerfile/redis","ports":[{"containerPort":6379,"protocol":"TCP"}],"env":[{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"PullIfNotPresent","capabilities":{}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"}},"currentState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}},{"kind":"ReplicationController","id":"guestbook","creationTimestamp":null,"apiVersion":"v1beta1","desiredState":{"replicas":3,"replicaSelector":{"name":"frontend-service"},"podTemplate":{"desiredState":{"manifest":{"version":"v1beta2","id":"","volumes":null,"containers":[{"name":"php-redis","image":"brendanburns/php-redis","ports":[{"hostPort":8000,"containerPort":80,"protocol":"TCP"}],"env":[{"name":"ADMIN_USERNAME","key":"ADMIN_USERNAME","value":"adminQ3H"},{"name":"ADMIN_PASSWORD","key":"ADMIN_PASSWORD","value":"dwNJiJwW"},{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"PullIfNotPresent","capabilities":{}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"}},"labels":{"name":"frontend-service"}}},"currentState":{"replicas":0,"podTemplate":{"desiredState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}}}},{"kind":"ReplicationController","id":"redis-slave","creationTimestamp":null,"apiVersion":"v1beta1","desiredState":{"replicas":2,"replicaSelector":{"name":"redis-slave"},"podTemplate":{"desiredState":{"manifest":{"version":"v1beta2","id":"","volumes":null,"containers":[{"name":"slave","image":"brendanburns/redis-slave","ports":[{"hostPort":6380,"containerPort":6379,"protocol":"TCP"}],"env":[{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"PullIfNotPresent","capabilities":{}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"}},"labels":{"name":"redis-slave"}}},"currentState":{"replicas":0,"podTemplate":{"desiredState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}}}}]}
|
|
| 133 | 141 |
} |
| ... | ... |
@@ -25,8 +25,10 @@ func makeUser() *api.User {
|
| 25 | 25 |
func makeUserFromSequence(sequence int) *api.User {
|
| 26 | 26 |
userName := fmt.Sprintf("myuser-%d", sequence)
|
| 27 | 27 |
userUID := types.UID(fmt.Sprintf("useruid-%d", sequence))
|
| 28 |
+ userResourceVersion := fmt.Sprintf("%d", sequence+100)
|
|
| 29 |
+ |
|
| 28 | 30 |
return &api.User{
|
| 29 |
- ObjectMeta: kapi.ObjectMeta{Name: userName, UID: userUID},
|
|
| 31 |
+ ObjectMeta: kapi.ObjectMeta{Name: userName, UID: userUID, ResourceVersion: userResourceVersion},
|
|
| 30 | 32 |
} |
| 31 | 33 |
} |
| 32 | 34 |
|
| ... | ... |
@@ -40,9 +42,10 @@ func makeIdentityFromSequence(sequence int) *api.Identity {
|
| 40 | 40 |
providerUserName := fmt.Sprintf("providerusername-%d", sequence)
|
| 41 | 41 |
identityName := fmt.Sprintf("%s:%s", providerName, providerUserName)
|
| 42 | 42 |
identityUID := types.UID(fmt.Sprintf("identityuid-%d", sequence))
|
| 43 |
+ identityResourceVersion := fmt.Sprintf("%d", sequence+200)
|
|
| 43 | 44 |
|
| 44 | 45 |
return &api.Identity{
|
| 45 |
- ObjectMeta: kapi.ObjectMeta{Name: identityName, UID: identityUID},
|
|
| 46 |
+ ObjectMeta: kapi.ObjectMeta{Name: identityName, UID: identityUID, ResourceVersion: identityResourceVersion},
|
|
| 46 | 47 |
ProviderName: providerName, |
| 47 | 48 |
ProviderUserName: providerUserName, |
| 48 | 49 |
} |
| ... | ... |
@@ -398,8 +401,9 @@ func TestUpdate(t *testing.T) {
|
| 398 | 398 |
} |
| 399 | 399 |
|
| 400 | 400 |
mapping := &api.UserIdentityMapping{
|
| 401 |
- Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 402 |
- User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 401 |
+ ObjectMeta: kapi.ObjectMeta{ResourceVersion: unassociatedIdentity1.ResourceVersion},
|
|
| 402 |
+ Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 403 |
+ User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 403 | 404 |
} |
| 404 | 405 |
|
| 405 | 406 |
actions, _, _, rest := setupRegistries(associatedIdentity1User1, associatedUser1, unassociatedUser2) |
| ... | ... |
@@ -428,8 +432,9 @@ func TestUpdateMissingIdentity(t *testing.T) {
|
| 428 | 428 |
} |
| 429 | 429 |
|
| 430 | 430 |
mapping := &api.UserIdentityMapping{
|
| 431 |
- Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 432 |
- User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 431 |
+ ObjectMeta: kapi.ObjectMeta{ResourceVersion: unassociatedIdentity1.ResourceVersion},
|
|
| 432 |
+ Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 433 |
+ User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 433 | 434 |
} |
| 434 | 435 |
|
| 435 | 436 |
actions, _, _, rest := setupRegistries(nil, associatedUser1, unassociatedUser2) |
| ... | ... |
@@ -460,8 +465,9 @@ func TestUpdateMissingUser(t *testing.T) {
|
| 460 | 460 |
} |
| 461 | 461 |
|
| 462 | 462 |
mapping := &api.UserIdentityMapping{
|
| 463 |
- Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 464 |
- User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 463 |
+ ObjectMeta: kapi.ObjectMeta{ResourceVersion: unassociatedIdentity1.ResourceVersion},
|
|
| 464 |
+ Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 465 |
+ User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 465 | 466 |
} |
| 466 | 467 |
|
| 467 | 468 |
actions, _, _, rest := setupRegistries(associatedIdentity1User1, associatedUser1) |
| ... | ... |
@@ -486,8 +492,9 @@ func TestUpdateOldUserMatches(t *testing.T) {
|
| 486 | 486 |
} |
| 487 | 487 |
|
| 488 | 488 |
mapping := &api.UserIdentityMapping{
|
| 489 |
- Identity: kapi.ObjectReference{Name: identity.Name},
|
|
| 490 |
- User: kapi.ObjectReference{Name: user.Name},
|
|
| 489 |
+ ObjectMeta: kapi.ObjectMeta{ResourceVersion: identity.ResourceVersion},
|
|
| 490 |
+ Identity: kapi.ObjectReference{Name: identity.Name},
|
|
| 491 |
+ User: kapi.ObjectReference{Name: user.Name},
|
|
| 491 | 492 |
} |
| 492 | 493 |
|
| 493 | 494 |
actions, _, _, rest := setupRegistries(identity, user) |
| ... | ... |
@@ -503,52 +510,39 @@ func TestUpdateOldUserMatches(t *testing.T) {
|
| 503 | 503 |
verifyMapping(createdMapping, user, identity, t) |
| 504 | 504 |
} |
| 505 | 505 |
|
| 506 |
-func TestUpdateWithMatchingResourceVersion(t *testing.T) {
|
|
| 506 |
+func TestUpdateWithEmptyResourceVersion(t *testing.T) {
|
|
| 507 | 507 |
// Starting conditions |
| 508 | 508 |
associatedUser1, associatedIdentity1User1 := makeAssociated() |
| 509 |
- associatedIdentity1User1.ResourceVersion = "ver1" |
|
| 510 | 509 |
unassociatedUser2 := makeUser() |
| 511 | 510 |
// Finishing conditions |
| 512 |
- unassociatedUser1, unassociatedIdentity1 := disassociate(associatedUser1, associatedIdentity1User1) |
|
| 513 |
- associatedUser2, associatedIdentity1User2 := associate(unassociatedUser2, unassociatedIdentity1) |
|
| 511 |
+ _, unassociatedIdentity1 := disassociate(associatedUser1, associatedIdentity1User1) |
|
| 514 | 512 |
|
| 515 | 513 |
expectedActions := []test.Action{
|
| 516 | 514 |
// Existing mapping lookup |
| 517 | 515 |
{"GetIdentity", associatedIdentity1User1.Name},
|
| 518 | 516 |
{"GetUser", associatedUser1.Name},
|
| 519 |
- // New user lookup |
|
| 520 |
- {"GetUser", unassociatedUser2.Name},
|
|
| 521 |
- // New user update |
|
| 522 |
- {"UpdateUser", associatedUser2},
|
|
| 523 |
- // Identity update |
|
| 524 |
- {"UpdateIdentity", associatedIdentity1User2},
|
|
| 525 |
- // Old user cleanup |
|
| 526 |
- {"UpdateUser", unassociatedUser1},
|
|
| 527 | 517 |
} |
| 528 | 518 |
|
| 529 | 519 |
mapping := &api.UserIdentityMapping{
|
| 530 |
- ObjectMeta: kapi.ObjectMeta{ResourceVersion: "ver1"},
|
|
| 531 |
- Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 532 |
- User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 520 |
+ Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 521 |
+ User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 533 | 522 |
} |
| 534 | 523 |
|
| 535 | 524 |
actions, _, _, rest := setupRegistries(associatedIdentity1User1, associatedUser1, unassociatedUser2) |
| 536 |
- createdMapping, created, err := rest.Update(kapi.NewContext(), mapping) |
|
| 525 |
+ _, _, err := rest.Update(kapi.NewContext(), mapping) |
|
| 537 | 526 |
|
| 538 |
- if err != nil {
|
|
| 539 |
- t.Errorf("Unexpected error: %v", err)
|
|
| 527 |
+ if err == nil {
|
|
| 528 |
+ t.Errorf("Expected error")
|
|
| 540 | 529 |
} |
| 541 |
- if created {
|
|
| 542 |
- t.Errorf("Unexpected created")
|
|
| 530 |
+ if !kerrs.IsInvalid(err) {
|
|
| 531 |
+ t.Errorf("Unexpected error: %v", err)
|
|
| 543 | 532 |
} |
| 544 | 533 |
verifyActions(expectedActions, *actions, t) |
| 545 |
- verifyMapping(createdMapping, associatedUser2, associatedIdentity1User2, t) |
|
| 546 | 534 |
} |
| 547 | 535 |
|
| 548 | 536 |
func TestUpdateWithMismatchedResourceVersion(t *testing.T) {
|
| 549 | 537 |
// Starting conditions |
| 550 | 538 |
associatedUser1, associatedIdentity1User1 := makeAssociated() |
| 551 |
- associatedIdentity1User1.ResourceVersion = "ver1" |
|
| 552 | 539 |
unassociatedUser2 := makeUser() |
| 553 | 540 |
// Finishing conditions |
| 554 | 541 |
_, unassociatedIdentity1 := disassociate(associatedUser1, associatedIdentity1User1) |
| ... | ... |
@@ -560,7 +554,7 @@ func TestUpdateWithMismatchedResourceVersion(t *testing.T) {
|
| 560 | 560 |
} |
| 561 | 561 |
|
| 562 | 562 |
mapping := &api.UserIdentityMapping{
|
| 563 |
- ObjectMeta: kapi.ObjectMeta{ResourceVersion: "ver2"},
|
|
| 563 |
+ ObjectMeta: kapi.ObjectMeta{ResourceVersion: "123"},
|
|
| 564 | 564 |
Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
| 565 | 565 |
User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
| 566 | 566 |
} |
| ... | ... |
@@ -601,8 +595,9 @@ func TestUpdateOldUserUpdateError(t *testing.T) {
|
| 601 | 601 |
expectedErr := errors.New("Couldn't update old user")
|
| 602 | 602 |
|
| 603 | 603 |
mapping := &api.UserIdentityMapping{
|
| 604 |
- Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 605 |
- User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 604 |
+ ObjectMeta: kapi.ObjectMeta{ResourceVersion: unassociatedIdentity1.ResourceVersion},
|
|
| 605 |
+ Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 606 |
+ User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 606 | 607 |
} |
| 607 | 608 |
|
| 608 | 609 |
actions, userRegistry, _, rest := setupRegistries(associatedIdentity1User1, associatedUser1, unassociatedUser2) |
| ... | ... |
@@ -640,8 +635,9 @@ func TestUpdateUserUpdateError(t *testing.T) {
|
| 640 | 640 |
expectedErr := errors.New("Couldn't update new user")
|
| 641 | 641 |
|
| 642 | 642 |
mapping := &api.UserIdentityMapping{
|
| 643 |
- Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 644 |
- User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 643 |
+ ObjectMeta: kapi.ObjectMeta{ResourceVersion: unassociatedIdentity1.ResourceVersion},
|
|
| 644 |
+ Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 645 |
+ User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 645 | 646 |
} |
| 646 | 647 |
|
| 647 | 648 |
actions, userRegistry, _, rest := setupRegistries(associatedIdentity1User1, associatedUser1, unassociatedUser2) |
| ... | ... |
@@ -679,8 +675,9 @@ func TestUpdateIdentityUpdateError(t *testing.T) {
|
| 679 | 679 |
expectedErr := errors.New("Couldn't update identity")
|
| 680 | 680 |
|
| 681 | 681 |
mapping := &api.UserIdentityMapping{
|
| 682 |
- Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 683 |
- User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 682 |
+ ObjectMeta: kapi.ObjectMeta{ResourceVersion: unassociatedIdentity1.ResourceVersion},
|
|
| 683 |
+ Identity: kapi.ObjectReference{Name: unassociatedIdentity1.Name},
|
|
| 684 |
+ User: kapi.ObjectReference{Name: unassociatedUser2.Name},
|
|
| 684 | 685 |
} |
| 685 | 686 |
|
| 686 | 687 |
actions, _, identityRegistry, rest := setupRegistries(associatedIdentity1User1, associatedUser1, unassociatedUser2) |
| ... | ... |
@@ -119,7 +119,10 @@ func TestHandleEndpoints(t *testing.T) {
|
| 119 | 119 |
Namespace: "foo", |
| 120 | 120 |
Name: "test", //kapi.endpoints inherits the name of the service |
| 121 | 121 |
}, |
| 122 |
- Endpoints: []kapi.Endpoint{{IP: "1.1.1.1", Port: 345}}, //not specifying a port to force the port 80 assumption
|
|
| 122 |
+ Subsets: []kapi.EndpointSubset{{
|
|
| 123 |
+ Addresses: []kapi.EndpointAddress{{IP: "1.1.1.1"}},
|
|
| 124 |
+ Ports: []kapi.EndpointPort{{Port: 345}},
|
|
| 125 |
+ }}, //not specifying a port to force the port 80 assumption |
|
| 123 | 126 |
}, |
| 124 | 127 |
expectedServiceUnit: &ServiceUnit{
|
| 125 | 128 |
Name: "foo/test", //service name from kapi.endpoints object |
| ... | ... |
@@ -140,7 +143,10 @@ func TestHandleEndpoints(t *testing.T) {
|
| 140 | 140 |
Namespace: "foo", |
| 141 | 141 |
Name: "test", |
| 142 | 142 |
}, |
| 143 |
- Endpoints: []kapi.Endpoint{{IP: "2.2.2.2", Port: 8080}},
|
|
| 143 |
+ Subsets: []kapi.EndpointSubset{{
|
|
| 144 |
+ Addresses: []kapi.EndpointAddress{{IP: "2.2.2.2"}},
|
|
| 145 |
+ Ports: []kapi.EndpointPort{{Port: 8080}},
|
|
| 146 |
+ }}, |
|
| 144 | 147 |
}, |
| 145 | 148 |
expectedServiceUnit: &ServiceUnit{
|
| 146 | 149 |
Name: "foo/test", |
| ... | ... |
@@ -161,7 +167,10 @@ func TestHandleEndpoints(t *testing.T) {
|
| 161 | 161 |
Namespace: "foo", |
| 162 | 162 |
Name: "test", |
| 163 | 163 |
}, |
| 164 |
- Endpoints: []kapi.Endpoint{{IP: "3.3.3.3", Port: 0}},
|
|
| 164 |
+ Subsets: []kapi.EndpointSubset{{
|
|
| 165 |
+ Addresses: []kapi.EndpointAddress{{IP: "3.3.3.3"}},
|
|
| 166 |
+ Ports: []kapi.EndpointPort{{Port: 0}},
|
|
| 167 |
+ }}, |
|
| 165 | 168 |
}, |
| 166 | 169 |
expectedServiceUnit: &ServiceUnit{
|
| 167 | 170 |
Name: "foo/test", |
| ... | ... |
@@ -10,10 +10,10 @@ import ( |
| 10 | 10 |
"testing" |
| 11 | 11 |
|
| 12 | 12 |
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
| 13 |
- klatest "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" |
|
| 14 | 13 |
kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client" |
| 15 | 14 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/master" |
| 16 | 15 |
|
| 16 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 17 | 17 |
"github.com/openshift/origin/pkg/auth/authenticator/request/headerrequest" |
| 18 | 18 |
oauthhandlers "github.com/openshift/origin/pkg/auth/oauth/handlers" |
| 19 | 19 |
oauthregistry "github.com/openshift/origin/pkg/auth/oauth/registry" |
| ... | ... |
@@ -48,7 +48,7 @@ func TestFrontProxyOnAuthorize(t *testing.T) {
|
| 48 | 48 |
|
| 49 | 49 |
// setup |
| 50 | 50 |
etcdClient := testutil.NewEtcdClient() |
| 51 |
- etcdHelper, _ := master.NewEtcdHelper(etcdClient, klatest.Version) |
|
| 51 |
+ etcdHelper, _ := master.NewEtcdHelper(etcdClient, latest.Version) |
|
| 52 | 52 |
oauthEtcd := oauthetcd.New(etcdHelper) |
| 53 | 53 |
|
| 54 | 54 |
userStorage := useretcd.NewREST(etcdHelper) |
| ... | ... |
@@ -173,7 +173,7 @@ func NewTestBuildOpenshift(t *testing.T) *testBuildOpenshift {
|
| 173 | 173 |
openshift.lock.Lock() |
| 174 | 174 |
defer openshift.lock.Unlock() |
| 175 | 175 |
etcdClient := testutil.NewEtcdClient() |
| 176 |
- etcdHelper, _ := master.NewEtcdHelper(etcdClient, klatest.Version) |
|
| 176 |
+ etcdHelper, _ := master.NewEtcdHelper(etcdClient, latest.Version) |
|
| 177 | 177 |
|
| 178 | 178 |
osMux := http.NewServeMux() |
| 179 | 179 |
openshift.server = httptest.NewServer(osMux) |
| ... | ... |
@@ -240,9 +240,10 @@ func NewTestBuildOpenshift(t *testing.T) *testBuildOpenshift {
|
| 240 | 240 |
|
| 241 | 241 |
Mapper: latest.RESTMapper, |
| 242 | 242 |
|
| 243 |
- Creater: kapi.Scheme, |
|
| 244 |
- Typer: kapi.Scheme, |
|
| 245 |
- Linker: interfaces.MetadataAccessor, |
|
| 243 |
+ Creater: kapi.Scheme, |
|
| 244 |
+ Typer: kapi.Scheme, |
|
| 245 |
+ Convertor: kapi.Scheme, |
|
| 246 |
+ Linker: interfaces.MetadataAccessor, |
|
| 246 | 247 |
|
| 247 | 248 |
Admit: admit.NewAlwaysAdmit(), |
| 248 | 249 |
Context: kapi.NewRequestContextMapper(), |
| ... | ... |
@@ -11,10 +11,10 @@ import ( |
| 11 | 11 |
|
| 12 | 12 |
"github.com/spf13/pflag" |
| 13 | 13 |
|
| 14 |
- klatest "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" |
|
| 15 | 14 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/master" |
| 16 | 15 |
|
| 17 | 16 |
// for osinserver setup. |
| 17 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 18 | 18 |
"github.com/openshift/origin/pkg/auth/authenticator/challenger/passwordchallenger" |
| 19 | 19 |
"github.com/openshift/origin/pkg/auth/authenticator/password/allowanypassword" |
| 20 | 20 |
"github.com/openshift/origin/pkg/auth/authenticator/request/basicauthrequest" |
| ... | ... |
@@ -44,7 +44,7 @@ func TestGetToken(t *testing.T) {
|
| 44 | 44 |
|
| 45 | 45 |
// setup |
| 46 | 46 |
etcdClient := testutil.NewEtcdClient() |
| 47 |
- etcdHelper, _ := master.NewEtcdHelper(etcdClient, klatest.Version) |
|
| 47 |
+ etcdHelper, _ := master.NewEtcdHelper(etcdClient, latest.Version) |
|
| 48 | 48 |
oauthEtcd := oauthetcd.New(etcdHelper) |
| 49 | 49 |
|
| 50 | 50 |
userStorage := useretcd.NewREST(etcdHelper) |
| ... | ... |
@@ -60,7 +60,7 @@ func TestDNS(t *testing.T) {
|
| 60 | 60 |
}, |
| 61 | 61 |
Spec: kapi.ServiceSpec{
|
| 62 | 62 |
PortalIP: kapi.PortalIPNone, |
| 63 |
- Port: 443, |
|
| 63 |
+ Ports: []kapi.ServicePort{{Port: 443}},
|
|
| 64 | 64 |
}, |
| 65 | 65 |
}); err != nil {
|
| 66 | 66 |
t.Fatalf("unexpected error: %v", err)
|
| ... | ... |
@@ -69,12 +69,10 @@ func TestDNS(t *testing.T) {
|
| 69 | 69 |
ObjectMeta: kapi.ObjectMeta{
|
| 70 | 70 |
Name: "headless", |
| 71 | 71 |
}, |
| 72 |
- Endpoints: []kapi.Endpoint{
|
|
| 73 |
- {
|
|
| 74 |
- IP: "172.0.0.1", |
|
| 75 |
- Port: 2345, |
|
| 76 |
- }, |
|
| 77 |
- }, |
|
| 72 |
+ Subsets: []kapi.EndpointSubset{{
|
|
| 73 |
+ Addresses: []kapi.EndpointAddress{{IP: "172.0.0.1"}},
|
|
| 74 |
+ Ports: []kapi.EndpointPort{{Port: 2345}},
|
|
| 75 |
+ }}, |
|
| 78 | 76 |
}); err != nil {
|
| 79 | 77 |
t.Fatalf("unexpected error: %v", err)
|
| 80 | 78 |
} |
| ... | ... |
@@ -84,6 +82,7 @@ func TestDNS(t *testing.T) {
|
| 84 | 84 |
tests := []struct {
|
| 85 | 85 |
dnsQuestionName string |
| 86 | 86 |
recursionExpected bool |
| 87 |
+ retry bool |
|
| 87 | 88 |
expect *net.IP |
| 88 | 89 |
}{
|
| 89 | 90 |
{
|
| ... | ... |
@@ -99,6 +98,7 @@ func TestDNS(t *testing.T) {
|
| 99 | 99 |
{
|
| 100 | 100 |
dnsQuestionName: "headless.default.local.", |
| 101 | 101 |
recursionExpected: false, |
| 102 |
+ retry: true, |
|
| 102 | 103 |
expect: &headlessIP, |
| 103 | 104 |
}, |
| 104 | 105 |
{
|
| ... | ... |
@@ -106,31 +106,41 @@ func TestDNS(t *testing.T) {
|
| 106 | 106 |
recursionExpected: true, |
| 107 | 107 |
}, |
| 108 | 108 |
} |
| 109 |
- for _, tc := range tests {
|
|
| 110 |
- m1 := &dns.Msg{
|
|
| 111 |
- MsgHdr: dns.MsgHdr{Id: dns.Id(), RecursionDesired: true},
|
|
| 112 |
- Question: []dns.Question{{tc.dnsQuestionName, dns.TypeA, dns.ClassINET}},
|
|
| 113 |
- } |
|
| 114 |
- in, err := dns.Exchange(m1, masterConfig.DNSConfig.BindAddress) |
|
| 115 |
- if err != nil {
|
|
| 116 |
- t.Fatalf("unexpected error: %v", err)
|
|
| 117 |
- } |
|
| 118 |
- if !tc.recursionExpected && len(in.Answer) != 1 {
|
|
| 119 |
- t.Fatalf("did not resolve or unexpected forward resolution: %#v", in)
|
|
| 120 |
- } else if tc.recursionExpected && len(in.Answer) == 0 {
|
|
| 121 |
- t.Fatalf("expected forward resolution: %#v", in)
|
|
| 122 |
- } |
|
| 123 |
- if a, ok := in.Answer[0].(*dns.A); ok {
|
|
| 124 |
- if a.A == nil {
|
|
| 125 |
- t.Errorf("expected an A record with an IP: %#v", a)
|
|
| 126 |
- } else {
|
|
| 127 |
- if tc.expect != nil && tc.expect.String() != a.A.String() {
|
|
| 128 |
- t.Errorf("A record has a different IP than the test case: %v / %v", a.A, *tc.expect)
|
|
| 109 |
+ for i, tc := range tests {
|
|
| 110 |
+ stop := make(chan struct{})
|
|
| 111 |
+ util.Until(func() {
|
|
| 112 |
+ m1 := &dns.Msg{
|
|
| 113 |
+ MsgHdr: dns.MsgHdr{Id: dns.Id(), RecursionDesired: true},
|
|
| 114 |
+ Question: []dns.Question{{tc.dnsQuestionName, dns.TypeA, dns.ClassINET}},
|
|
| 115 |
+ } |
|
| 116 |
+ in, err := dns.Exchange(m1, masterConfig.DNSConfig.BindAddress) |
|
| 117 |
+ if err != nil {
|
|
| 118 |
+ t.Errorf("%d: unexpected error: %v", i, err)
|
|
| 119 |
+ return |
|
| 120 |
+ } |
|
| 121 |
+ if !tc.recursionExpected && len(in.Answer) != 1 {
|
|
| 122 |
+ if !tc.retry {
|
|
| 123 |
+ close(stop) |
|
| 124 |
+ t.Errorf("%d: did not resolve or unexpected forward resolution: %#v", i, in)
|
|
| 129 | 125 |
} |
| 126 |
+ return |
|
| 127 |
+ } else if tc.recursionExpected && len(in.Answer) == 0 {
|
|
| 128 |
+ t.Errorf("%d: expected forward resolution: %#v", i, in)
|
|
| 129 |
+ return |
|
| 130 | 130 |
} |
| 131 |
- } else {
|
|
| 132 |
- t.Errorf("expected an A record: %#v", in)
|
|
| 133 |
- } |
|
| 134 |
- t.Log(in) |
|
| 131 |
+ if a, ok := in.Answer[0].(*dns.A); ok {
|
|
| 132 |
+ if a.A == nil {
|
|
| 133 |
+ t.Errorf("expected an A record with an IP: %#v", a)
|
|
| 134 |
+ } else {
|
|
| 135 |
+ if tc.expect != nil && tc.expect.String() != a.A.String() {
|
|
| 136 |
+ t.Errorf("A record has a different IP than the test case: %v / %v", a.A, *tc.expect)
|
|
| 137 |
+ } |
|
| 138 |
+ } |
|
| 139 |
+ } else {
|
|
| 140 |
+ t.Errorf("expected an A record: %#v", in)
|
|
| 141 |
+ } |
|
| 142 |
+ t.Log(in) |
|
| 143 |
+ close(stop) |
|
| 144 |
+ }, 50*time.Millisecond, stop) |
|
| 135 | 145 |
} |
| 136 | 146 |
} |
| ... | ... |
@@ -59,9 +59,10 @@ func TestProjectIsNamespace(t *testing.T) {
|
| 59 | 59 |
|
| 60 | 60 |
Mapper: klatest.RESTMapper, |
| 61 | 61 |
|
| 62 |
- Creater: kapi.Scheme, |
|
| 63 |
- Typer: kapi.Scheme, |
|
| 64 |
- Linker: kubeInterfaces.MetadataAccessor, |
|
| 62 |
+ Creater: kapi.Scheme, |
|
| 63 |
+ Typer: kapi.Scheme, |
|
| 64 |
+ Convertor: kapi.Scheme, |
|
| 65 |
+ Linker: kubeInterfaces.MetadataAccessor, |
|
| 65 | 66 |
|
| 66 | 67 |
Admit: admit.NewAlwaysAdmit(), |
| 67 | 68 |
Context: kapi.NewRequestContextMapper(), |
| ... | ... |
@@ -70,7 +71,7 @@ func TestProjectIsNamespace(t *testing.T) {
|
| 70 | 70 |
t.Fatalf("unable to install REST: %v", err)
|
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 |
- kubeClient, err := kclient.New(&kclient.Config{Host: server.URL})
|
|
| 73 |
+ kubeClient, err := kclient.New(&kclient.Config{Host: server.URL, Version: "v1beta1"})
|
|
| 74 | 74 |
if err != nil {
|
| 75 | 75 |
t.Fatalf("Unexpected error: %v", err)
|
| 76 | 76 |
} |
| ... | ... |
@@ -89,9 +90,10 @@ func TestProjectIsNamespace(t *testing.T) {
|
| 89 | 89 |
|
| 90 | 90 |
Mapper: latest.RESTMapper, |
| 91 | 91 |
|
| 92 |
- Creater: kapi.Scheme, |
|
| 93 |
- Typer: kapi.Scheme, |
|
| 94 |
- Linker: originInterfaces.MetadataAccessor, |
|
| 92 |
+ Creater: kapi.Scheme, |
|
| 93 |
+ Typer: kapi.Scheme, |
|
| 94 |
+ Convertor: kapi.Scheme, |
|
| 95 |
+ Linker: originInterfaces.MetadataAccessor, |
|
| 95 | 96 |
|
| 96 | 97 |
Admit: admit.NewAlwaysAdmit(), |
| 97 | 98 |
Context: kapi.NewRequestContextMapper(), |
| ... | ... |
@@ -32,11 +32,12 @@ func TestWebhookGithubPush(t *testing.T) {
|
| 32 | 32 |
|
| 33 | 33 |
// create buildconfig |
| 34 | 34 |
buildConfig := mockBuildConfigParms("image", "repo", "tag")
|
| 35 |
- if _, err := openshift.Client.BuildConfigs(testutil.Namespace()).Create(buildConfig); err != nil {
|
|
| 35 |
+ bc, err := openshift.Client.BuildConfigs(testutil.Namespace()).Create(buildConfig) |
|
| 36 |
+ if err != nil {
|
|
| 36 | 37 |
t.Fatalf("Unexpected error: %v", err)
|
| 37 | 38 |
} |
| 38 | 39 |
|
| 39 |
- watch, err := openshift.Client.Builds(testutil.Namespace()).Watch(labels.Everything(), fields.Everything(), "0") |
|
| 40 |
+ watch, err := openshift.Client.Builds(testutil.Namespace()).Watch(labels.Everything(), fields.Everything(), bc.ResourceVersion) |
|
| 40 | 41 |
if err != nil {
|
| 41 | 42 |
t.Fatalf("Couldn't subscribe to builds: %v", err)
|
| 42 | 43 |
} |
| ... | ... |
@@ -69,9 +69,10 @@ func TestTemplateTransformationFromConfig(t *testing.T) {
|
| 69 | 69 |
Storage: storage, |
| 70 | 70 |
Codec: interfaces.Codec, |
| 71 | 71 |
|
| 72 |
- Creater: kapi.Scheme, |
|
| 73 |
- Typer: kapi.Scheme, |
|
| 74 |
- Linker: interfaces.MetadataAccessor, |
|
| 72 |
+ Creater: kapi.Scheme, |
|
| 73 |
+ Typer: kapi.Scheme, |
|
| 74 |
+ Convertor: kapi.Scheme, |
|
| 75 |
+ Linker: interfaces.MetadataAccessor, |
|
| 75 | 76 |
|
| 76 | 77 |
Admit: admit.NewAlwaysAdmit(), |
| 77 | 78 |
Context: kapi.NewRequestContextMapper(), |
| ... | ... |
@@ -55,15 +55,18 @@ func WaitForAddress(pod *kapi.Pod, service *kapi.Service, ns string) (string, er |
| 55 | 55 |
if eventEndpoint.Name != service.Name {
|
| 56 | 56 |
continue |
| 57 | 57 |
} |
| 58 |
- if len(eventEndpoint.Endpoints) == 0 {
|
|
| 58 |
+ if len(eventEndpoint.Subsets) == 0 {
|
|
| 59 | 59 |
fmt.Printf("Waiting for %s address\n", eventEndpoint.Name)
|
| 60 | 60 |
continue |
| 61 | 61 |
} |
| 62 |
- for i := range eventEndpoint.Endpoints {
|
|
| 63 |
- e := &eventEndpoint.Endpoints[i] |
|
| 64 |
- addr := net.JoinHostPort(e.IP, strconv.Itoa(e.Port)) |
|
| 65 |
- fmt.Printf("Discovered new %s endpoint: %s\n", service.Name, addr)
|
|
| 66 |
- return addr, nil |
|
| 62 |
+ for _, s := range eventEndpoint.Subsets {
|
|
| 63 |
+ for _, p := range s.Ports {
|
|
| 64 |
+ for _, a := range s.Addresses {
|
|
| 65 |
+ addr := net.JoinHostPort(a.IP, strconv.Itoa(p.Port)) |
|
| 66 |
+ fmt.Printf("Discovered new %s endpoint: %s\n", service.Name, addr)
|
|
| 67 |
+ return addr, nil |
|
| 68 |
+ } |
|
| 69 |
+ } |
|
| 67 | 70 |
} |
| 68 | 71 |
} |
| 69 | 72 |
return "", fmt.Errorf("Service does not get any endpoints")
|
| ... | ... |
@@ -114,9 +117,11 @@ func CreateServiceForPod(pod *kapi.Pod, ns string) *kapi.Service {
|
| 114 | 114 |
Name: ns, |
| 115 | 115 |
}, |
| 116 | 116 |
Spec: kapi.ServiceSpec{
|
| 117 |
- Selector: map[string]string{"name": ns},
|
|
| 118 |
- TargetPort: kubeutil.IntOrString{Kind: kubeutil.IntstrInt, IntVal: 8080},
|
|
| 119 |
- Port: 8080, |
|
| 117 |
+ Selector: map[string]string{"name": ns},
|
|
| 118 |
+ Ports: []kapi.ServicePort{{
|
|
| 119 |
+ Port: 8080, |
|
| 120 |
+ TargetPort: kubeutil.IntOrString{Kind: kubeutil.IntstrInt, IntVal: 8080},
|
|
| 121 |
+ }}, |
|
| 120 | 122 |
}, |
| 121 | 123 |
} |
| 122 | 124 |
if service, err := client.Services(ns).Create(service); err != nil {
|