本文整理汇总了Golang中k8s/io/kubernetes/pkg/api/testapi.TestGroup类的典型用法代码示例。如果您正苦于以下问题:Golang TestGroup类的具体用法?Golang TestGroup怎么用?Golang TestGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestGroup类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: roundTripSame
// roundTripSame verifies the same source object is tested in all API versions
// yielded by codecsToTest
func roundTripSame(t *testing.T, group testapi.TestGroup, item runtime.Object, except ...string) {
set := sets.NewString(except...)
seed := rand.Int63()
fuzzInternalObject(t, group.InternalGroupVersion(), item, seed)
version := *group.GroupVersion()
codecs := []runtime.Codec{}
for _, fn := range codecsToTest {
codec, ok, err := fn(version, item)
if err != nil {
t.Errorf("unable to get codec: %v", err)
return
}
if !ok {
continue
}
codecs = append(codecs, codec)
}
if !set.Has(version.String()) {
fuzzInternalObject(t, version, item, seed)
for _, codec := range codecs {
roundTrip(t, codec, item)
}
}
}
开发者ID:kubernetes,项目名称:kubernetes,代码行数:28,代码来源:serialization_test.go
示例2: testListJob
func testListJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceAll
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: group.ResourcePath(getJobsResourceName(), ns, ""),
},
Response: simple.Response{StatusCode: 200,
Body: &extensions.JobList{
Items: []extensions.Job{
{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: extensions.JobSpec{
Template: api.PodTemplateSpec{},
},
},
},
},
},
ResourceGroup: resourceGroup,
}
receivedJobList, err := getJobClient(t, c, ns, resourceGroup).List(api.ListOptions{})
defer c.Close()
c.Validate(t, receivedJobList, err)
}
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:31,代码来源:jobs_test.go
示例3: testGetJob
func testGetJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: group.ResourcePath(getJobsResourceName(), ns, "foo"),
Query: simple.BuildQueryValues(nil),
},
Response: simple.Response{
StatusCode: 200,
Body: &extensions.Job{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: extensions.JobSpec{
Template: api.PodTemplateSpec{},
},
},
},
ResourceGroup: resourceGroup,
}
receivedJob, err := getJobClient(t, c, ns, resourceGroup).Get("foo")
defer c.Close()
c.Validate(t, receivedJob, err)
}
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:29,代码来源:jobs_test.go
示例4: testHorizontalPodAutoscalerList
func testHorizontalPodAutoscalerList(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
horizontalPodAutoscalerList := &extensions.HorizontalPodAutoscalerList{
Items: []extensions.HorizontalPodAutoscaler{
{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: ns,
},
},
},
}
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: group.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
Query: simple.BuildQueryValues(nil),
Body: nil,
},
Response: simple.Response{StatusCode: 200, Body: horizontalPodAutoscalerList},
ResourceGroup: resourceGroup,
}
response, err := getHPAClient(t, c, ns, resourceGroup).List(api.ListOptions{})
defer c.Close()
c.Validate(t, response, err)
}
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:26,代码来源:horizontalpodautoscaler_test.go
示例5: testHorizontalPodAutoscalerCreate
func testHorizontalPodAutoscalerCreate(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
horizontalPodAutoscaler := extensions.HorizontalPodAutoscaler{
ObjectMeta: api.ObjectMeta{
Name: "abc",
Namespace: ns,
},
}
c := &simple.Client{
Request: simple.Request{
Method: "POST",
Path: group.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
Query: simple.BuildQueryValues(nil),
Body: &horizontalPodAutoscaler,
},
Response: simple.Response{StatusCode: 200, Body: &horizontalPodAutoscaler},
ResourceGroup: resourceGroup,
}
response, err := getHPAClient(t, c, ns, resourceGroup).Create(&horizontalPodAutoscaler)
defer c.Close()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
c.Validate(t, response, err)
}
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:26,代码来源:horizontalpodautoscaler_test.go
示例6: testHorizontalPodAutoscalerDelete
func testHorizontalPodAutoscalerDelete(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
c := &simple.Client{
Request: simple.Request{Method: "DELETE", Path: group.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200},
ResourceGroup: resourceGroup,
}
err := getHPAClient(t, c, ns, resourceGroup).Delete("foo", nil)
defer c.Close()
c.Validate(t, nil, err)
}
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:11,代码来源:horizontalpodautoscaler_test.go
示例7: testHorizontalPodAutoscalerWatch
func testHorizontalPodAutoscalerWatch(t *testing.T, group testapi.TestGroup, resourceGroup string) {
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: group.ResourcePathWithPrefix("watch", getHorizontalPodAutoscalersResoureName(), "", ""),
Query: url.Values{"resourceVersion": []string{}}},
Response: simple.Response{StatusCode: 200},
ResourceGroup: resourceGroup,
}
_, err := getHPAClient(t, c, api.NamespaceAll, resourceGroup).Watch(api.ListOptions{})
defer c.Close()
c.Validate(t, nil, err)
}
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:13,代码来源:horizontalpodautoscaler_test.go
示例8: doRoundTripTest
func doRoundTripTest(group testapi.TestGroup, kind string, t *testing.T) {
item, err := api.Scheme.New(group.InternalGroupVersion().WithKind(kind))
if err != nil {
t.Fatalf("Couldn't make a %v? %v", kind, err)
}
if _, err := meta.TypeAccessor(item); err != nil {
t.Fatalf("%q is not a TypeMeta and cannot be tested - add it to nonRoundTrippableTypes: %v", kind, err)
}
if api.Scheme.Recognizes(group.GroupVersion().WithKind(kind)) {
roundTripSame(t, group, item, nonRoundTrippableTypesByVersion[kind]...)
}
if !nonInternalRoundTrippableTypes.Has(kind) && api.Scheme.Recognizes(group.GroupVersion().WithKind(kind)) {
roundTrip(t, group.Codec(), fuzzInternalObject(t, group.InternalGroupVersion(), item, rand.Int63()))
}
}
开发者ID:xiaohui,项目名称:kubernetes,代码行数:15,代码来源:serialization_test.go
示例9: testHorizontalPodAutoscalerUpdateStatus
func testHorizontalPodAutoscalerUpdateStatus(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
horizontalPodAutoscaler := &extensions.HorizontalPodAutoscaler{
ObjectMeta: api.ObjectMeta{
Name: "abc",
Namespace: ns,
ResourceVersion: "1",
},
}
c := &simple.Client{
Request: simple.Request{Method: "PUT", Path: group.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "abc") + "/status", Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200, Body: horizontalPodAutoscaler},
ResourceGroup: resourceGroup,
}
response, err := getHPAClient(t, c, ns, resourceGroup).UpdateStatus(horizontalPodAutoscaler)
defer c.Close()
c.Validate(t, response, err)
}
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:18,代码来源:horizontalpodautoscaler_test.go
示例10: testCreateJob
func testCreateJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
requestJob := &extensions.Job{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: ns,
},
}
c := &simple.Client{
Request: simple.Request{
Method: "POST",
Path: group.ResourcePath(getJobsResourceName(), ns, ""),
Body: requestJob,
Query: simple.BuildQueryValues(nil),
},
Response: simple.Response{
StatusCode: 200,
Body: &extensions.Job{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: extensions.JobSpec{
Template: api.PodTemplateSpec{},
},
},
},
ResourceGroup: resourceGroup,
}
receivedJob, err := getJobClient(t, c, ns, resourceGroup).Create(requestJob)
defer c.Close()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
c.Validate(t, receivedJob, err)
}
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:39,代码来源:jobs_test.go
示例11: testUpdateJobStatus
func testUpdateJobStatus(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
requestJob := &batch.Job{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: ns,
ResourceVersion: "1",
},
}
c := &simple.Client{
Request: simple.Request{
Method: "PUT",
Path: group.ResourcePath(getJobsResourceName(), ns, "foo") + "/status",
Query: simple.BuildQueryValues(nil),
},
Response: simple.Response{
StatusCode: 200,
Body: &batch.Job{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: batch.JobSpec{
Template: api.PodTemplateSpec{},
},
Status: batch.JobStatus{
Active: 1,
},
},
},
ResourceGroup: resourceGroup,
}
receivedJob, err := getJobClient(t, c, ns, resourceGroup).UpdateStatus(requestJob)
defer c.Close()
c.Validate(t, receivedJob, err)
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:39,代码来源:jobs_test.go
示例12: readSwaggerApiFile
func readSwaggerApiFile(group testapi.TestGroup) ([]byte, error) {
// TODO: Figure out a better way of finding these files
var pathToSwaggerSpec string
if group.GroupVersion().Group == "" {
pathToSwaggerSpec = "../../../api/swagger-spec/" + group.GroupVersion().Version + ".json"
} else {
pathToSwaggerSpec = "../../../api/swagger-spec/" + group.GroupVersion().Group + "_" + group.GroupVersion().Version + ".json"
}
return ioutil.ReadFile(pathToSwaggerSpec)
}
开发者ID:RyanBinfeng,项目名称:kubernetes,代码行数:11,代码来源:schema_test.go
示例13: doRoundTrip
func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) {
// We do fuzzing on the internal version of the object, and only then
// convert to the external version. This is because custom fuzzing
// function are only supported for internal objects.
internalObj, err := api.Scheme.New(group.InternalGroupVersion().WithKind(kind))
if err != nil {
t.Fatalf("Couldn't create internal object %v: %v", kind, err)
}
seed := rand.Int63()
apitesting.FuzzerFor(t, group.InternalGroupVersion(), rand.NewSource(seed)).
// We are explicitly overwriting custom fuzzing functions, to ensure
// that InitContainers and their statuses are not generated. This is
// because in thise test we are simply doing json operations, in which
// those disappear.
Funcs(
func(s *api.PodSpec, c fuzz.Continue) {
c.FuzzNoCustom(s)
s.InitContainers = nil
},
func(s *api.PodStatus, c fuzz.Continue) {
c.FuzzNoCustom(s)
s.InitContainerStatuses = nil
},
).Fuzz(internalObj)
item, err := api.Scheme.New(group.GroupVersion().WithKind(kind))
if err != nil {
t.Fatalf("Couldn't create external object %v: %v", kind, err)
}
if err := api.Scheme.Convert(internalObj, item, nil); err != nil {
t.Fatalf("Conversion for %v failed: %v", kind, err)
}
data, err := json.Marshal(item)
if err != nil {
t.Errorf("Error when marshaling object: %v", err)
return
}
unstr := make(map[string]interface{})
err = json.Unmarshal(data, &unstr)
if err != nil {
t.Errorf("Error when unmarshaling to unstructured: %v", err)
return
}
data, err = json.Marshal(unstr)
if err != nil {
t.Errorf("Error when marshaling unstructured: %v", err)
return
}
unmarshalledObj := reflect.New(reflect.TypeOf(item).Elem()).Interface()
err = json.Unmarshal(data, &unmarshalledObj)
if err != nil {
t.Errorf("Error when unmarshaling to object: %v", err)
return
}
if !api.Semantic.DeepEqual(item, unmarshalledObj) {
t.Errorf("Object changed during JSON operations, diff: %v", diff.ObjectReflectDiff(item, unmarshalledObj))
return
}
// TODO; Enable the following part of test once to/from unstructured
// format conversions are implemented.
/*
newUnstr := make(map[string]interface{})
err = unstructured.NewConverter().ToUnstructured(item, &newUnstr)
if err != nil {
t.Errorf("ToUnstructured failed: %v", err)
return
}
newObj := reflect.New(reflect.TypeOf(item).Elem()).Interface().(runtime.Object)
err = unstructured.NewConverter().FromUnstructured(newUnstr, newObj)
if err != nil {
t.Errorf("FromUnstructured failed: %v", err)
return
}
if !api.Semantic.DeepEqual(item, newObj) {
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(item, newObj))
}
*/
}
开发者ID:kubernetes,项目名称:kubernetes,代码行数:83,代码来源:unstructured_test.go
注:本文中的k8s/io/kubernetes/pkg/api/testapi.TestGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论