本文整理汇总了Golang中github.com/openshift/origin/pkg/deploy/api/test.OkPodTemplate函数的典型用法代码示例。如果您正苦于以下问题:Golang OkPodTemplate函数的具体用法?Golang OkPodTemplate怎么用?Golang OkPodTemplate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OkPodTemplate函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestValidateSelectorMatchesPodTemplateLabels
func TestValidateSelectorMatchesPodTemplateLabels(t *testing.T) {
tests := map[string]struct {
spec api.DeploymentConfigSpec
expectedErr bool
errorType field.ErrorType
field string
}{
"valid template labels": {
spec: api.DeploymentConfigSpec{
Selector: test.OkSelector(),
Strategy: test.OkStrategy(),
Template: test.OkPodTemplate(),
},
},
"invalid template labels": {
spec: api.DeploymentConfigSpec{
Selector: test.OkSelector(),
Strategy: test.OkStrategy(),
Template: test.OkPodTemplate(),
},
expectedErr: true,
errorType: field.ErrorTypeInvalid,
field: "spec.template.metadata.labels",
},
}
for name, test := range tests {
if test.expectedErr {
test.spec.Template.Labels["a"] = "c"
}
errs := ValidateDeploymentConfigSpec(test.spec)
if len(errs) == 0 && test.expectedErr {
t.Errorf("%s: expected failure", name)
continue
}
if !test.expectedErr {
continue
}
if len(errs) != 1 {
t.Errorf("%s: expected one error, got %d", name, len(errs))
continue
}
err := errs[0]
if err.Type != test.errorType {
t.Errorf("%s: expected error to have type %q, got %q", name, test.errorType, err.Type)
}
if err.Field != test.field {
t.Errorf("%s: expected error to have field %q, got %q", name, test.field, err.Field)
}
}
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:51,代码来源:validation_test.go
示例2: TestValidateDeploymentConfigDefaultImageStreamKind
func TestValidateDeploymentConfigDefaultImageStreamKind(t *testing.T) {
config := &api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar"},
Spec: api.DeploymentConfigSpec{
Replicas: 1,
Triggers: []api.DeploymentTriggerPolicy{
{
Type: api.DeploymentTriggerOnImageChange,
ImageChangeParams: &api.DeploymentTriggerImageChangeParams{
From: kapi.ObjectReference{
Kind: "ImageStreamTag",
Name: "name:v1",
},
ContainerNames: []string{"foo"},
},
},
},
Selector: test.OkSelector(),
Template: test.OkPodTemplate(),
Strategy: test.OkStrategy(),
},
}
if errs := ValidateDeploymentConfig(config); len(errs) > 0 {
t.Errorf("Unxpected non-empty error list: %v", errs)
}
}
开发者ID:rrati,项目名称:origin,代码行数:27,代码来源:validation_test.go
示例3: podTemplateA
func podTemplateA() *kapi.PodTemplateSpec {
t := deploytest.OkPodTemplate()
t.Spec.Containers = append(t.Spec.Containers, kapi.Container{
Name: "container1",
Image: "registry:8080/repo1:ref1",
})
return t
}
开发者ID:hloganathan,项目名称:origin,代码行数:8,代码来源:util_test.go
示例4: TestDCPodTemplateSpecNode
func TestDCPodTemplateSpecNode(t *testing.T) {
g := osgraph.New()
dc := &deployapi.DeploymentConfig{}
dc.Namespace = "ns"
dc.Name = "foo"
dc.Spec.Template = test.OkPodTemplate()
_ = EnsureDeploymentConfigNode(g, dc)
edges := g.Edges()
if len(edges) != 2 {
t.Errorf("expected 2 edges, got %d", len(edges))
return
}
for i := range edges {
if !g.EdgeKinds(edges[i]).Has(osgraph.ContainsEdgeKind) {
t.Errorf("expected %v, got %v", osgraph.ContainsEdgeKind, g.EdgeKinds(edges[i]))
return
}
}
nodes := g.Nodes()
if len(nodes) != 3 {
t.Errorf("expected 3 nodes, got %d", len(nodes))
return
}
sorted, err := topo.Sort(g)
if err != nil {
t.Errorf("unexpected error: %v", err)
return
}
// Just to be sure
if len(sorted) != 3 {
t.Errorf("expected 3 nodes, got %d", len(sorted))
return
}
if _, ok := sorted[0].(*DeploymentConfigNode); !ok {
t.Errorf("expected first node to be a DeploymentConfigNode")
return
}
if _, ok := sorted[1].(*kubetypes.PodTemplateSpecNode); !ok {
t.Errorf("expected second node to be a PodTemplateSpecNode")
return
}
if _, ok := sorted[2].(*kubetypes.PodSpecNode); !ok {
t.Errorf("expected third node to be a PodSpecNode")
}
}
开发者ID:RomainVabre,项目名称:origin,代码行数:49,代码来源:nodes_test.go
示例5: TestValidateDeploymentConfigOK
func TestValidateDeploymentConfigOK(t *testing.T) {
errs := ValidateDeploymentConfig(&api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar"},
Spec: api.DeploymentConfigSpec{
Replicas: 1,
Triggers: manualTrigger(),
Selector: test.OkSelector(),
Strategy: test.OkStrategy(),
Template: test.OkPodTemplate(),
},
})
if len(errs) > 0 {
t.Errorf("Unxpected non-empty error list: %#v", errs)
}
}
开发者ID:rrati,项目名称:origin,代码行数:16,代码来源:validation_test.go
示例6: rollingConfig
func rollingConfig(interval, updatePeriod, timeout int) api.DeploymentConfig {
return api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar"},
Spec: api.DeploymentConfigSpec{
Triggers: manualTrigger(),
Strategy: api.DeploymentStrategy{
Type: api.DeploymentStrategyTypeRolling,
RollingParams: &api.RollingDeploymentStrategyParams{
IntervalSeconds: mkint64p(interval),
UpdatePeriodSeconds: mkint64p(updatePeriod),
TimeoutSeconds: mkint64p(timeout),
MaxSurge: intstr.FromInt(1),
},
},
Template: test.OkPodTemplate(),
Selector: test.OkSelector(),
},
}
}
开发者ID:rrati,项目名称:origin,代码行数:19,代码来源:validation_test.go
示例7: rollingConfigMax
func rollingConfigMax(maxSurge, maxUnavailable intstr.IntOrString) api.DeploymentConfig {
return api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar"},
Spec: api.DeploymentConfigSpec{
Triggers: manualTrigger(),
Strategy: api.DeploymentStrategy{
Type: api.DeploymentStrategyTypeRolling,
RollingParams: &api.RollingDeploymentStrategyParams{
IntervalSeconds: mkint64p(1),
UpdatePeriodSeconds: mkint64p(1),
TimeoutSeconds: mkint64p(1),
MaxSurge: maxSurge,
MaxUnavailable: maxUnavailable,
},
},
Template: test.OkPodTemplate(),
Selector: test.OkSelector(),
},
}
}
开发者ID:rrati,项目名称:origin,代码行数:20,代码来源:validation_test.go
示例8: TestCanTrigger
func TestCanTrigger(t *testing.T) {
tests := []struct {
name string
config *deployapi.DeploymentConfig
decoded *deployapi.DeploymentConfig
force bool
expected bool
expectedCauses []deployapi.DeploymentCause
expectedErr bool
}{
{
name: "no trigger [w/ podtemplate change]",
config: &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "config"},
Spec: deployapi.DeploymentConfigSpec{
Triggers: []deployapi.DeploymentTriggerPolicy{},
Template: deploytest.OkPodTemplateChanged(),
},
Status: deploytest.OkDeploymentConfigStatus(1),
},
decoded: &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "config"},
Spec: deployapi.DeploymentConfigSpec{
Triggers: []deployapi.DeploymentTriggerPolicy{},
Template: deploytest.OkPodTemplate(),
},
Status: deploytest.OkDeploymentConfigStatus(1),
},
force: false,
expected: false,
expectedCauses: nil,
},
{
name: "forced updated",
config: &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "config"},
Spec: deployapi.DeploymentConfigSpec{
Template: deploytest.OkPodTemplateChanged(),
},
Status: deploytest.OkDeploymentConfigStatus(1),
},
decoded: &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "config"},
Spec: deployapi.DeploymentConfigSpec{
Template: deploytest.OkPodTemplate(),
},
Status: deploytest.OkDeploymentConfigStatus(1),
},
force: true,
expected: true,
expectedCauses: []deployapi.DeploymentCause{{Type: deployapi.DeploymentTriggerManual}},
},
{
name: "config change trigger only [w/ podtemplate change]",
config: &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "config"},
Spec: deployapi.DeploymentConfigSpec{
Template: deploytest.OkPodTemplateChanged(),
Triggers: []deployapi.DeploymentTriggerPolicy{
deploytest.OkConfigChangeTrigger(),
},
},
Status: deploytest.OkDeploymentConfigStatus(1),
},
decoded: &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "config"},
Spec: deployapi.DeploymentConfigSpec{
Template: deploytest.OkPodTemplate(),
Triggers: []deployapi.DeploymentTriggerPolicy{
deploytest.OkConfigChangeTrigger(),
},
},
Status: deploytest.OkDeploymentConfigStatus(1),
},
force: false,
expected: true,
expectedCauses: deploytest.OkConfigChangeDetails().Causes,
},
{
name: "config change trigger only [no change][initial]",
config: &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "config"},
Spec: deployapi.DeploymentConfigSpec{
Template: deploytest.OkPodTemplate(),
Triggers: []deployapi.DeploymentTriggerPolicy{
deploytest.OkConfigChangeTrigger(),
},
},
Status: deploytest.OkDeploymentConfigStatus(0),
},
decoded: &deployapi.DeploymentConfig{
//.........这里部分代码省略.........
开发者ID:juanluisvaladas,项目名称:origin,代码行数:101,代码来源:rest_test.go
示例9: TestCanTrigger
func TestCanTrigger(t *testing.T) {
tests := []struct {
name string
config *deployapi.DeploymentConfig
decoded *deployapi.DeploymentConfig
expected bool
expectedCauses []deployapi.DeploymentCause
}{
{
name: "nil decoded config",
config: testapi.OkDeploymentConfig(1),
decoded: nil,
expected: false,
expectedCauses: nil,
},
{
name: "no trigger",
config: &deployapi.DeploymentConfig{
Spec: deployapi.DeploymentConfigSpec{
Template: testapi.OkPodTemplateChanged(),
},
Status: testapi.OkDeploymentConfigStatus(1),
},
decoded: &deployapi.DeploymentConfig{
Spec: deployapi.DeploymentConfigSpec{
Template: testapi.OkPodTemplate(),
},
Status: testapi.OkDeploymentConfigStatus(1),
},
expected: false,
expectedCauses: nil,
},
{
name: "config change trigger only",
config: &deployapi.DeploymentConfig{
Spec: deployapi.DeploymentConfigSpec{
Template: testapi.OkPodTemplateChanged(),
Triggers: []deployapi.DeploymentTriggerPolicy{
testapi.OkConfigChangeTrigger(),
},
},
Status: testapi.OkDeploymentConfigStatus(1),
},
decoded: &deployapi.DeploymentConfig{
Spec: deployapi.DeploymentConfigSpec{
Template: testapi.OkPodTemplate(),
Triggers: []deployapi.DeploymentTriggerPolicy{
testapi.OkConfigChangeTrigger(),
},
},
Status: testapi.OkDeploymentConfigStatus(1),
},
expected: true,
expectedCauses: testapi.OkConfigChangeDetails().Causes,
},
{
name: "config change trigger only [no change][initial]",
config: &deployapi.DeploymentConfig{
Spec: deployapi.DeploymentConfigSpec{
Template: testapi.OkPodTemplate(),
Triggers: []deployapi.DeploymentTriggerPolicy{
testapi.OkConfigChangeTrigger(),
},
},
Status: testapi.OkDeploymentConfigStatus(0),
},
decoded: &deployapi.DeploymentConfig{
Spec: deployapi.DeploymentConfigSpec{
Template: testapi.OkPodTemplate(),
Triggers: []deployapi.DeploymentTriggerPolicy{
testapi.OkConfigChangeTrigger(),
},
},
Status: testapi.OkDeploymentConfigStatus(0),
},
expected: true,
expectedCauses: testapi.OkConfigChangeDetails().Causes,
},
{
name: "config change trigger only [no change]",
config: &deployapi.DeploymentConfig{
Spec: deployapi.DeploymentConfigSpec{
Template: testapi.OkPodTemplate(),
Triggers: []deployapi.DeploymentTriggerPolicy{
testapi.OkConfigChangeTrigger(),
},
},
Status: testapi.OkDeploymentConfigStatus(1),
},
//.........这里部分代码省略.........
开发者ID:sgallagher,项目名称:origin,代码行数:101,代码来源:controller_test.go
示例10: TestValidateDeploymentConfigMissingFields
func TestValidateDeploymentConfigMissingFields(t *testing.T) {
errorCases := map[string]struct {
DeploymentConfig api.DeploymentConfig
ErrorType field.ErrorType
Field string
}{
"missing name": {
api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "", Namespace: "bar"},
Spec: test.OkDeploymentConfigSpec(),
},
field.ErrorTypeRequired,
"metadata.name",
},
"missing namespace": {
api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: ""},
Spec: test.OkDeploymentConfigSpec(),
},
field.ErrorTypeRequired,
"metadata.namespace",
},
"invalid name": {
api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "-foo", Namespace: "bar"},
Spec: test.OkDeploymentConfigSpec(),
},
field.ErrorTypeInvalid,
"metadata.name",
},
"invalid namespace": {
api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "-bar"},
Spec: test.OkDeploymentConfigSpec(),
},
field.ErrorTypeInvalid,
"metadata.namespace",
},
"missing trigger.type": {
api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar"},
Spec: api.DeploymentConfigSpec{
Replicas: 1,
Triggers: []api.DeploymentTriggerPolicy{
{
ImageChangeParams: &api.DeploymentTriggerImageChangeParams{
ContainerNames: []string{"foo"},
},
},
},
Selector: test.OkSelector(),
Strategy: test.OkStrategy(),
Template: test.OkPodTemplate(),
},
},
field.ErrorTypeRequired,
"spec.triggers[0].type",
},
"missing Trigger imageChangeParams.from": {
api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar"},
Spec: api.DeploymentConfigSpec{
Replicas: 1,
Triggers: []api.DeploymentTriggerPolicy{
{
Type: api.DeploymentTriggerOnImageChange,
ImageChangeParams: &api.DeploymentTriggerImageChangeParams{
ContainerNames: []string{"foo"},
},
},
},
Selector: test.OkSelector(),
Strategy: test.OkStrategy(),
Template: test.OkPodTemplate(),
},
},
field.ErrorTypeRequired,
"spec.triggers[0].imageChangeParams.from",
},
"invalid Trigger imageChangeParams.from.kind": {
api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar"},
Spec: api.DeploymentConfigSpec{
Replicas: 1,
Triggers: []api.DeploymentTriggerPolicy{
{
Type: api.DeploymentTriggerOnImageChange,
ImageChangeParams: &api.DeploymentTriggerImageChangeParams{
From: kapi.ObjectReference{
Kind: "Invalid",
Name: "name:tag",
},
ContainerNames: []string{"foo"},
},
},
},
Selector: test.OkSelector(),
Strategy: test.OkStrategy(),
Template: test.OkPodTemplate(),
//.........这里部分代码省略.........
开发者ID:rrati,项目名称:origin,代码行数:101,代码来源:validation_test.go
示例11: TestValidateDeploymentConfigUpdate
func TestValidateDeploymentConfigUpdate(t *testing.T) {
oldConfig := &api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar", ResourceVersion: "1"},
Spec: api.DeploymentConfigSpec{
Replicas: 1,
Triggers: manualTrigger(),
Selector: test.OkSelector(),
Strategy: test.OkStrategy(),
Template: test.OkPodTemplate(),
},
Status: api.DeploymentConfigStatus{
LatestVersion: 5,
},
}
newConfig := &api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "foo", Namespace: "bar", ResourceVersion: "1"},
Spec: api.DeploymentConfigSpec{
Replicas: 1,
Triggers: manualTrigger(),
Selector: test.OkSelector(),
Strategy: test.OkStrategy(),
Template: test.OkPodTemplate(),
},
Status: api.DeploymentConfigStatus{
LatestVersion: 3,
},
}
scenarios := []struct {
oldLatestVersion int
newLatestVersion int
}{
{5, 3},
{5, 7},
{0, -1},
}
for _, values := range scenarios {
oldConfig.Status.LatestVersion = values.oldLatestVersion
newConfig.Status.LatestVersion = values.newLatestVersion
errs := ValidateDeploymentConfigUpdate(newConfig, oldConfig)
if len(errs) == 0 {
t.Errorf("Expected update failure")
}
for i := range errs {
if errs[i].Type != field.ErrorTypeInvalid {
t.Errorf("expected update error to have type %s: %v", field.ErrorTypeInvalid, errs[i])
}
if errs[i].Field != "status.latestVersion" {
t.Errorf("expected update error to have field %s: %v", "latestVersion", errs[i])
}
}
}
// testing for a successful update
oldConfig.Status.LatestVersion = 5
newConfig.Status.LatestVersion = 6
errs := ValidateDeploymentConfigUpdate(newConfig, oldConfig)
if len(errs) > 0 {
t.Errorf("Unexpected update failure")
}
}
开发者ID:rrati,项目名称:origin,代码行数:62,代码来源:validation_test.go
注:本文中的github.com/openshift/origin/pkg/deploy/api/test.OkPodTemplate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论