Auto-update dependencies (#144)

Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg`
/assign n3wscott
This commit is contained in:
Matt Moore 2019-12-02 08:38:34 -08:00 committed by Knative Prow Robot
parent 3feb9f69e8
commit 4f108c7677
11 changed files with 183 additions and 19 deletions

4
Gopkg.lock generated
View File

@ -933,7 +933,7 @@
[[projects]]
branch = "master"
digest = "1:02bb033254628cebfbb92810a742f7a60e51ec685c7e2987c04ff4b97e1de058"
digest = "1:09a00f21eaeeae387d973fd3f82cf06a8627f88566b4e6811ba97003dd207eac"
name = "knative.dev/pkg"
packages = [
"apis",
@ -952,7 +952,7 @@
"metrics/metricskey",
]
pruneopts = "T"
revision = "06d6b25dd6e10d1c02f31ecb7d953d98481715cf"
revision = "944655d6cc17ceb861b0764046c56a465fe5bb75"
[[projects]]
branch = "master"

2
vendor/knative.dev/pkg/Gopkg.lock generated vendored
View File

@ -1303,7 +1303,7 @@
"tools/dep-collector",
]
pruneopts = "UT"
revision = "fad831028edbe066665977ea7bf366c3d5c0a2d1"
revision = "2c4cd9df33c648a86d95bdd4119386cba04cde56"
[[projects]]
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"

View File

@ -109,3 +109,20 @@ func (u *URL) URL() *url.URL {
url := url.URL(*u)
return &url
}
// ResolveReference calls the underlying ResolveReference method
// and returns an apis.URL
func (u *URL) ResolveReference(ref *URL) *URL {
if ref == nil {
return u
}
// Turn both u / ref to url.URL
uRef := url.URL(*ref)
uu := url.URL(*u)
newU := uu.ResolveReference(&uRef)
// Turn new back to apis.URL
ret := URL(*newU)
return &ret
}

View File

@ -0,0 +1,19 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package client

View File

@ -0,0 +1,19 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake

View File

@ -0,0 +1,19 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package factory

View File

@ -0,0 +1,19 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by injection-gen. DO NOT EDIT.
package fake

View File

@ -92,13 +92,30 @@ type TableRow struct {
// PostConditions allows custom assertions to be made after reconciliation
PostConditions []func(*testing.T, *TableRow)
// Reconciler holds the controller.Reconciler that was used to evaluate this row.
// It is populated here to make it accessible to PostConditions.
Reconciler controller.Reconciler
}
func objKey(o runtime.Object) string {
on := o.(kmeta.Accessor)
var typeOf string
if gvk := on.GroupVersionKind(); gvk.Group != "" {
// This must be populated if we're dealing with unstructured.Unstructured.
typeOf = gvk.String()
} else if or, ok := on.(kmeta.OwnerRefable); ok {
// This is typically implemented by Knative resources.
typeOf = or.GetGroupVersionKind().String()
} else {
// Worst case, fallback on a non-GVK string.
typeOf = reflect.TypeOf(o).String()
}
// namespace + name is not unique, and the tests don't populate k8s kind
// information, so use GoLang's type name as part of the key.
return path.Join(reflect.TypeOf(o).String(), on.GetNamespace(), on.GetName())
return path.Join(typeOf, on.GetNamespace(), on.GetName())
}
// Factory returns a Reconciler.Interface to perform reconciliation in table test,
@ -111,6 +128,9 @@ func (r *TableRow) Test(t *testing.T, factory Factory) {
t.Helper()
c, recorderList, eventList, statsReporter := factory(t, r)
// Set the Reconciler for PostConditions to access it post-Reconcile()
r.Reconciler = c
// Set context to not be nil.
ctx := r.Ctx
if ctx == nil {

View File

@ -61,9 +61,7 @@ func NewURIResolver(ctx context.Context, callback func(types.NamespacedName)) *U
// URIFromDestination resolves a v1beta1.Destination into a URI string.
func (r *URIResolver) URIFromDestination(dest duckv1beta1.Destination, parent interface{}) (string, error) {
var deprecatedObjectReference *corev1.ObjectReference
if dest.DeprecatedAPIVersion == "" && dest.DeprecatedKind == "" && dest.DeprecatedName == "" && dest.DeprecatedNamespace == "" {
deprecatedObjectReference = nil
} else {
if !(dest.DeprecatedAPIVersion == "" && dest.DeprecatedKind == "" && dest.DeprecatedName == "" && dest.DeprecatedNamespace == "") {
deprecatedObjectReference = &corev1.ObjectReference{
Kind: dest.DeprecatedKind,
APIVersion: dest.DeprecatedAPIVersion,
@ -89,7 +87,7 @@ func (r *URIResolver) URIFromDestination(dest duckv1beta1.Destination, parent in
if dest.URI.URL().IsAbs() {
return "", errors.New("absolute URI is not allowed when Ref or [apiVersion, kind, name] exists")
}
return url.URL().ResolveReference(dest.URI.URL()).String(), nil
return url.ResolveReference(dest.URI).String(), nil
}
return url.URL().String(), nil
}
@ -97,7 +95,7 @@ func (r *URIResolver) URIFromDestination(dest duckv1beta1.Destination, parent in
if dest.URI != nil {
// IsAbs check whether the URL has a non-empty scheme. Besides the non non-empty scheme, we also require dest.URI has a non-empty host
if !dest.URI.URL().IsAbs() || dest.URI.Host == "" {
return "", fmt.Errorf("URI is not absolute(both scheme and host should be non-empty): %v", dest.URI.String())
return "", fmt.Errorf("URI is not absolute (both scheme and host should be non-empty): %q", dest.URI.String())
}
return dest.URI.String(), nil
}
@ -105,31 +103,31 @@ func (r *URIResolver) URIFromDestination(dest duckv1beta1.Destination, parent in
return "", errors.New("destination missing Ref, [apiVersion, kind, name] and URI, expected at least one")
}
// URIFromDestinationV1 resolves a v1.Destination into a URI string.
func (r *URIResolver) URIFromDestinationV1(dest duckv1.Destination, parent interface{}) (string, error) {
// URIFromDestinationV1 resolves a v1.Destination into a URL.
func (r *URIResolver) URIFromDestinationV1(dest duckv1.Destination, parent interface{}) (*apis.URL, error) {
if dest.Ref != nil {
url, err := r.URIFromObjectReference(dest.Ref, parent)
if err != nil {
return "", err
return nil, err
}
if dest.URI != nil {
if dest.URI.URL().IsAbs() {
return "", errors.New("absolute URI is not allowed when Ref or [apiVersion, kind, name] exists")
return nil, errors.New("absolute URI is not allowed when Ref or [apiVersion, kind, name] exists")
}
return url.URL().ResolveReference(dest.URI.URL()).String(), nil
return url.ResolveReference(dest.URI), nil
}
return url.URL().String(), nil
return url, nil
}
if dest.URI != nil {
// IsAbs check whether the URL has a non-empty scheme. Besides the non non-empty scheme, we also require dest.URI has a non-empty host
if !dest.URI.URL().IsAbs() || dest.URI.Host == "" {
return "", fmt.Errorf("URI is not absolute(both scheme and host should be non-empty): %v", dest.URI.String())
return nil, fmt.Errorf("URI is not absolute(both scheme and host should be non-empty): %q", dest.URI.String())
}
return dest.URI.String(), nil
return dest.URI, nil
}
return "", errors.New("destination missing Ref and URI, expected at least one")
return nil, errors.New("destination missing Ref and URI, expected at least one")
}
// URIFromObjectReference resolves an ObjectReference to a URI string.
@ -167,7 +165,7 @@ func (r *URIResolver) URIFromObjectReference(ref *corev1.ObjectReference, parent
addressable, ok := obj.(*duckv1.AddressableType)
if !ok {
return nil, fmt.Errorf("%+v is not an AddressableType", ref)
return nil, fmt.Errorf("%+v (%T) is not an AddressableType", ref, ref)
}
if addressable.Status.Address == nil {
return nil, fmt.Errorf("address not set for %+v", ref)

View File

@ -75,6 +75,52 @@ func WaitForPodListState(client *KubeClient, inState func(p *corev1.PodList) (bo
})
}
// WaitForPodState polls the status of the specified Pod
// from client every interval until inState returns `true` indicating it
// is done, returns an error or timeout. desc will be used to name the metric
// that is emitted to track how long it took to get into the state checked by inState.
func WaitForPodState(client *KubeClient, inState func(p *corev1.Pod) (bool, error), name string, namespace string) error {
p := client.Kube.CoreV1().Pods(namespace)
span := logging.GetEmitableSpan(context.Background(), "WaitForPodState/"+name)
defer span.End()
return wait.PollImmediate(interval, podTimeout, func() (bool, error) {
p, err := p.Get(name, metav1.GetOptions{})
if err != nil {
return false, err
}
return inState(p)
})
}
// WaitForServiceHasAtLeastOneEndpoint polls the status of the specified Service
// from client every interval until number of service endpoints = numOfEndpoints
func WaitForServiceEndpoints(client *KubeClient, svcName string, svcNamespace string, numOfEndpoints int) error {
endpointsService := client.Kube.CoreV1().Endpoints(svcNamespace)
span := logging.GetEmitableSpan(context.Background(), "WaitForServiceHasAtLeastOneEndpoint/"+svcName)
defer span.End()
return wait.PollImmediate(interval, podTimeout, func() (bool, error) {
endpoint, err := endpointsService.Get(svcName, metav1.GetOptions{})
if err != nil {
return false, err
}
return countEndpointsNum(endpoint) == numOfEndpoints, nil
})
}
func countEndpointsNum(e *corev1.Endpoints) int {
if e == nil || e.Subsets == nil {
return 0
}
num := 0
for _, sub := range e.Subsets {
num += len(sub.Addresses)
}
return num
}
// GetConfigMap gets the configmaps for a given namespace
func GetConfigMap(client *KubeClient, namespace string) k8styped.ConfigMapInterface {
return client.Kube.CoreV1().ConfigMaps(namespace)

View File

@ -32,12 +32,14 @@ import (
fakeistioclientset "knative.dev/pkg/client/istio/clientset/versioned/fake"
istiolisters "knative.dev/pkg/client/istio/listers/networking/v1alpha3"
"knative.dev/pkg/reconciler/testing"
pkgtesting "knative.dev/pkg/testing"
)
var clientSetSchemes = []func(*runtime.Scheme) error{
fakekubeclientset.AddToScheme,
fakeistioclientset.AddToScheme,
autoscalingv2beta1.AddToScheme,
pkgtesting.AddToScheme,
}
// Listers is used to synthesize informer-style Listers from fixed lists of resources in tests.
@ -88,6 +90,11 @@ func (l *Listers) GetIstioObjects() []runtime.Object {
return l.sorter.ObjectsForSchemeFunc(fakeistioclientset.AddToScheme)
}
// GetTestObjects filters the Lister's initial list of objects to types defined in knative/pkg/testing
func (l *Listers) GetTestObjects() []runtime.Object {
return l.sorter.ObjectsForSchemeFunc(pkgtesting.AddToScheme)
}
// GetHorizontalPodAutoscalerLister gets lister for HorizontalPodAutoscaler resources.
func (l *Listers) GetHorizontalPodAutoscalerLister() autoscalingv2beta1listers.HorizontalPodAutoscalerLister {
return autoscalingv2beta1listers.NewHorizontalPodAutoscalerLister(l.IndexerFor(&autoscalingv2beta1.HorizontalPodAutoscaler{}))