本文整理汇总了Golang中github.com/remind101/empire/pkg/awsutil.NewHandler函数的典型用法代码示例。如果您正苦于以下问题:Golang NewHandler函数的具体用法?Golang NewHandler怎么用?Golang NewHandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewHandler函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestListAppServices
func TestListAppServices(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.ListServices",
Body: `{"cluster":"cluster"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"serviceArns":["arn:aws:ecs:us-east-1:249285743859:service/ae69bb4c-3903-4844-82fe-548ac5b74570--web"]}`,
},
},
})
m, s := newTestClient(h)
defer s.Close()
resp, err := m.ListAppServices(context.Background(), "ae69bb4c-3903-4844-82fe-548ac5b74570", &ecs.ListServicesInput{
Cluster: aws.String("cluster"),
})
if err != nil {
t.Fatal(err)
}
if got := len(resp.ServiceArns); got != 1 {
t.Fatalf("Expected 1 service returned; got %d", got)
}
}
开发者ID:carriercomm,项目名称:empire,代码行数:28,代码来源:client_test.go
示例2: TestELB_EmptyLoadBalancers
func TestELB_EmptyLoadBalancers(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
{
Request: awsutil.Request{
RequestURI: "/",
Body: `Action=DescribeLoadBalancers&PageSize=20&Version=2012-06-01`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<DescribeLoadBalancersResult>
<LoadBalancerDescriptions/>
</DescribeLoadBalancersResult>
</DescribeLoadBalancersResponse>`,
},
},
})
m, s := newTestELBManager(h)
defer s.Close()
lbs, err := m.LoadBalancers(context.Background(), nil)
if err != nil {
t.Fatal(err)
}
if got, want := len(lbs), 0; got != want {
t.Fatalf("%v load balancers; want %v", got, want)
}
}
开发者ID:zofuthan,项目名称:empire,代码行数:28,代码来源:elb_test.go
示例3: buildLoadBalancerForDestroy
func buildLoadBalancerForDestroy() (*ELBManager, *httptest.Server, *LoadBalancer) {
h := awsutil.NewHandler([]awsutil.Cycle{
{
Request: awsutil.Request{
RequestURI: "/",
Body: `Action=DeleteLoadBalancer&LoadBalancerName=acme-inc&Version=2012-06-01`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<?xml version="1.0"?>
<DeleteLoadBalancerResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
</DeleteLoadBalancerResponse>`,
},
},
})
m, s := newTestELBManager(h)
lb := &LoadBalancer{
Name: "acme-inc",
DNSName: "acme-inc.us-east-1.elb.amazonaws.com",
InstancePort: 9000,
External: true,
Tags: map[string]string{AppTag: "acme-inc"},
}
return m, s, lb
}
开发者ID:aaithal,项目名称:empire,代码行数:26,代码来源:elb_test.go
示例4: TestELB_UpdateLoadBalancer
func TestELB_UpdateLoadBalancer(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
{
Request: awsutil.Request{
RequestURI: "/",
Body: `Action=SetLoadBalancerListenerSSLCertificate&LoadBalancerName=loadbalancer&LoadBalancerPort=443&SSLCertificateId=newcert&Version=2012-06-01`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<?xml version="1.0"?>
<UpdateLoadBalancerResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
</UpdateLoadBalancerResponse>`,
},
},
})
m, s := newTestELBManager(h)
defer s.Close()
err := m.UpdateLoadBalancer(context.Background(), UpdateLoadBalancerOpts{
Name: "loadbalancer",
SSLCert: aws.String("newcert"),
})
if err != nil {
t.Fatal(err)
}
}
开发者ID:frewsxcv,项目名称:empire,代码行数:26,代码来源:elb_test.go
示例5: TestELB_CreateLoadBalancer
func TestELB_CreateLoadBalancer(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
{
Request: awsutil.Request{
RequestURI: "/",
Body: `Action=CreateLoadBalancer&Listeners.member.1.InstancePort=9000&Listeners.member.1.InstanceProtocol=http&Listeners.member.1.LoadBalancerPort=80&Listeners.member.1.Protocol=http&LoadBalancerName=acme-inc&Scheme=internet-facing&SecurityGroups.member.1=&Subnets.member.1=public-subnet&Version=2012-06-01`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<?xml version="1.0"?>
<CreateLoadBalancerResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<DNSName>acme-inc.us-east-1.elb.amazonaws.com</DNSName>
</CreateLoadBalancerResponse>`,
},
},
{
Request: awsutil.Request{
RequestURI: "/",
Body: `Action=ModifyLoadBalancerAttributes&LoadBalancerAttributes.ConnectionDraining.Enabled=true&LoadBalancerAttributes.ConnectionDraining.Timeout=30&LoadBalancerName=acme-inc&Version=2012-06-01`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<?xml version="1.0"?>
<ModifyLoadBalancerAttributesResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
</ModifyLoadBalancerAttributesResponse>`,
},
},
})
m, s := newTestELBManager(h)
defer s.Close()
lb, err := m.CreateLoadBalancer(context.Background(), CreateLoadBalancerOpts{
InstancePort: 9000,
External: true,
})
if err != nil {
t.Fatal(err)
}
expected := &LoadBalancer{
Name: "acme-inc",
DNSName: "acme-inc.us-east-1.elb.amazonaws.com",
InstancePort: 9000,
External: true,
}
if got, want := lb, expected; !reflect.DeepEqual(got, want) {
t.Fatalf("LoadBalancer => %v; want %v", got, want)
}
}
开发者ID:aaithal,项目名称:empire,代码行数:50,代码来源:elb_test.go
示例6: TestScheduler_Run
func TestScheduler_Run(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.RegisterTaskDefinition",
Body: `{"containerDefinitions":[{"cpu":128,"command":["acme-inc", "web", "--port", "80"],"environment":[{"name":"USER","value":"foo"}],"dockerLabels":{"label1":"foo","label2":"bar"},"essential":true,"image":"remind101/acme-inc:latest","memory":128,"name":"run"}],"family":"1234--run"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"taskDefinition":{"taskDefinitionArn":"arn:aws:ecs:us-east-1:249285743859:task-definition/1234--run"}}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.RunTask",
Body: `{"cluster":"empire","count":1,"startedBy":"1234","taskDefinition":"arn:aws:ecs:us-east-1:249285743859:task-definition/1234--run"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: ``,
},
},
})
m, s := newTestScheduler(h)
defer s.Close()
app := &scheduler.App{
ID: "1234",
Env: map[string]string{
"USER": "foo",
},
Labels: map[string]string{
"label1": "foo",
"label2": "bar",
},
}
process := &scheduler.Process{
Type: "run",
Image: image.Image{Repository: "remind101/acme-inc", Tag: "latest"},
Command: []string{"acme-inc", "web", "--port", "80"},
MemoryLimit: 134217728, // 128
CPUShares: 128,
}
if err := m.Run(context.Background(), app, process, nil, nil); err != nil {
t.Fatal(err)
}
}
开发者ID:brianz,项目名称:empire,代码行数:49,代码来源:ecs_test.go
示例7: TestRoute53_DeleteCNAME
func TestRoute53_DeleteCNAME(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
{
Request: awsutil.Request{
RequestURI: "/2013-04-01/hostedzone/FAKEZONE",
Body: ``,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<?xml version="1.0"?>
<GetHostedZoneResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<HostedZone>
<Id>/hostedzone/FAKEZONE</Id>
<Name>empire.</Name>
<CallerReference>FakeReference</CallerReference>
<Config>
<Comment>Fake hosted zone comment.</Comment>
<PrivateZone>true</PrivateZone>
</Config>
<ResourceRecordSetCount>2</ResourceRecordSetCount>
</HostedZone>
<VPCs>
<VPC>
<VPCRegion>us-east-1</VPCRegion>
<VPCId>vpc-0d9ea668</VPCId>
</VPC>
</VPCs>
</GetHostedZoneResponse>`,
},
},
{
Request: awsutil.Request{
RequestURI: `/2013-04-01/hostedzone/FAKEZONE/rrset`,
Body: `ignore`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: ``,
},
},
})
n, s := newTestRoute53Nameserver(h, "/hostedzone/FAKEZONE")
defer s.Close()
if err := n.DeleteCNAME("acme-inc", "123456789.us-east-1.elb.amazonaws.com"); err != nil {
t.Fatal(err)
}
}
开发者ID:aaithal,项目名称:empire,代码行数:49,代码来源:dns_test.go
示例8: TestScheduler_Scale
func TestScheduler_Scale(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.UpdateService",
Body: `{"cluster":"empire","desiredCount":10,"service":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: ``,
},
},
})
m, s := newTestScheduler(h)
defer s.Close()
if err := m.Scale(context.Background(), "1234", "web", 10); err != nil {
t.Fatal(err)
}
}
开发者ID:4eek,项目名称:empire,代码行数:21,代码来源:ecs_test.go
示例9: TestScheduler_Processes
func TestScheduler_Processes(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.ListServices",
Body: `{"cluster":"empire"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"serviceArns":[
"arn:aws:ecs:us-east-1:249285743859:service/1234--web1",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web2",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web3",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web4",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web5",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web6",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web7",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web8",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web9",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web10",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web11",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web12",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web13",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web14",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web15",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web16",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web17",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web18",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web19",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web20",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web21"
]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeServices",
Body: `{"cluster":"empire","services":[
"arn:aws:ecs:us-east-1:249285743859:service/1234--web1",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web2",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web3",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web4",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web5",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web6",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web7",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web8",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web9",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web10"
]}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"services":[{"taskDefinition":"1234--web"}]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeServices",
Body: `{"cluster":"empire","services":[
"arn:aws:ecs:us-east-1:249285743859:service/1234--web11",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web12",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web13",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web14",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web15",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web16",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web17",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web18",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web19",
"arn:aws:ecs:us-east-1:249285743859:service/1234--web20"
]}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"services":[{"taskDefinition":"1234--web"}]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeServices",
Body: `{"cluster":"empire","services":[
"arn:aws:ecs:us-east-1:249285743859:service/1234--web21"
]}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"services":[{"taskDefinition":"1234--web"}]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeTaskDefinition",
//.........这里部分代码省略.........
开发者ID:4eek,项目名称:empire,代码行数:101,代码来源:ecs_test.go
示例10: TestScheduler_Submit
func TestScheduler_Submit(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.ListServices",
Body: `{"cluster":"empire"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"serviceArns":["arn:aws:ecs:us-east-1:249285743859:service/1234--web"]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeServices",
Body: `{"cluster":"empire","services":["arn:aws:ecs:us-east-1:249285743859:service/1234--web"]}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"services":[{"taskDefinition":"1234--web"}]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeTaskDefinition",
Body: `{"taskDefinition":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"taskDefinition":{"containerDefinitions":[{"cpu":128,"command":["acme-inc", "web", "--port 80"],"environment":[{"name":"USER","value":"foo"}],"essential":true,"image":"remind101/acme-inc:latest","memory":128,"name":"web"}]}}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.RegisterTaskDefinition",
Body: `{"containerDefinitions":[{"cpu":128,"command":["acme-inc", "web", "--port 80"],"environment":[{"name":"USER","value":"foo"}],"essential":true,"image":"remind101/acme-inc:latest","memory":128,"name":"web","portMappings":[{"containerPort":8080,"hostPort":8080}]}],"family":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: "",
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.UpdateService",
Body: `{"cluster":"empire","desiredCount":0,"service":"1234--web","taskDefinition":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"service": {}}`,
},
},
})
m, s := newTestScheduler(h)
defer s.Close()
if err := m.Submit(context.Background(), fakeApp); err != nil {
t.Fatal(err)
}
}
开发者ID:4eek,项目名称:empire,代码行数:69,代码来源:ecs_test.go
示例11: TestScheduler_Instances
func TestScheduler_Instances(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.ListServices",
Body: `{"cluster":"empire"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"serviceArns":["arn:aws:ecs:us-east-1:249285743859:service/1234--web"]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.ListTasks",
Body: `{"cluster":"empire","serviceName":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"taskArns":["arn:aws:ecs:us-east-1:249285743859:task/ae69bb4c-3903-4844-82fe-548ac5b74570"]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeTasks",
Body: `{"cluster":"empire","tasks":["arn:aws:ecs:us-east-1:249285743859:task/ae69bb4c-3903-4844-82fe-548ac5b74570"]}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"tasks":[{"taskArn":"arn:aws:ecs:us-east-1:249285743859:task/ae69bb4c-3903-4844-82fe-548ac5b74570","taskDefinitionArn":"arn:aws:ecs:us-east-1:249285743859:task-definition/1234--web","lastStatus":"RUNNING"}]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeTaskDefinition",
Body: `{"taskDefinition":"arn:aws:ecs:us-east-1:249285743859:task-definition/1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"taskDefinition":{"containerDefinitions":[{"name":"web","cpu":256,"memory":256,"command":["acme-inc", "web", "--port 80"]}]}}`,
},
},
})
m, s := newTestScheduler(h)
defer s.Close()
instances, err := m.Instances(context.Background(), "1234")
if err != nil {
t.Fatal(err)
}
if len(instances) != 1 {
t.Fatal("expected 1 instance")
}
i := instances[0]
if got, want := i.State, "RUNNING"; got != want {
t.Fatalf("State => %s; want %s", got, want)
}
if got, want := i.Process.Command, "acme-inc web --port 80"; got != want {
t.Fatalf("Command => %s; want %s", got, want)
}
if got, want := i.Process.Type, "web"; got != want {
t.Fatalf("Type => %s; want %s", got, want)
}
}
开发者ID:4eek,项目名称:empire,代码行数:76,代码来源:ecs_test.go
示例12: TestScheduler_Remove
func TestScheduler_Remove(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.ListServices",
Body: `{"cluster":"empire"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"serviceArns":["arn:aws:ecs:us-east-1:249285743859:service/1234--web"]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeServices",
Body: `{"cluster":"empire","services":["arn:aws:ecs:us-east-1:249285743859:service/1234--web"]}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"services":[{"taskDefinition":"1234--web"}]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeTaskDefinition",
Body: `{"taskDefinition":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"taskDefinition":{"containerDefinitions":[{"cpu":128,"command":["acme-inc", "web", "--port 80"],"environment":[{"name":"USER","value":"foo"}],"essential":true,"image":"remind101/acme-inc:latest","memory":128,"name":"web"}]}}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.UpdateService",
Body: `{"cluster":"empire","desiredCount":0,"service":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: ``,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DeleteService",
Body: `{"cluster":"empire","service":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: ``,
},
},
})
m, s := newTestScheduler(h)
defer s.Close()
m.lb.(*mockLBManager).On("LoadBalancers", map[string]string{
"AppID": "1234",
}).Return([]*lb.LoadBalancer{}, nil)
if err := m.Remove(context.Background(), "1234"); err != nil {
t.Fatal(err)
}
}
开发者ID:brianz,项目名称:empire,代码行数:73,代码来源:ecs_test.go
示例13: TestScheduler_Submit
func TestScheduler_Submit(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.ListServices",
Body: `{"cluster":"empire"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"serviceArns":["arn:aws:ecs:us-east-1:249285743859:service/1234--web"]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeServices",
Body: `{"cluster":"empire","services":["arn:aws:ecs:us-east-1:249285743859:service/1234--web"]}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"services":[{"taskDefinition":"1234--web"}]}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.DescribeTaskDefinition",
Body: `{"taskDefinition":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"taskDefinition":{"containerDefinitions":[{"cpu":128,"command":["acme-inc", "web", "--port 80"],"environment":[{"name":"USER","value":"foo"},{"name":"PORT","value":"8080"}],"essential":true,"image":"remind101/acme-inc:latest","memory":128,"name":"web"}]}}`,
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.RegisterTaskDefinition",
Body: `{"containerDefinitions":[{"cpu":128,"command":["acme-inc", "web", "--port", "80"],"environment":[{"name":"USER","value":"foo"},{"name":"PORT","value":"8080"}],"dockerLabels":{"label1":"foo","label2":"bar"},"essential":true,"image":"remind101/acme-inc:latest","memory":128,"name":"web","portMappings":[{"containerPort":8080,"hostPort":8080}]}],"family":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: "",
},
},
awsutil.Cycle{
Request: awsutil.Request{
RequestURI: "/",
Operation: "AmazonEC2ContainerServiceV20141113.UpdateService",
Body: `{"cluster":"empire","desiredCount":0,"service":"1234--web","taskDefinition":"1234--web"}`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `{"service": {}}`,
},
},
})
m, s := newTestScheduler(h)
defer s.Close()
m.lb.(*mockLBManager).On("LoadBalancers", map[string]string{
"AppID": "1234",
"ProcessType": "web",
}).Return([]*lb.LoadBalancer{
{Name: "lb-1234", InstancePort: 8080},
}, nil)
if err := m.Submit(context.Background(), fakeApp, nil); err != nil {
t.Fatal(err)
}
}
开发者ID:brianz,项目名称:empire,代码行数:76,代码来源:ecs_test.go
示例14: TestELB_LoadBalancers
func TestELB_LoadBalancers(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
{
Request: awsutil.Request{
RequestURI: "/",
Body: `Action=DescribeLoadBalancers&PageSize=20&Version=2012-06-01`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<DescribeLoadBalancersResult>
<NextMarker>
abcd
</NextMarker>
<LoadBalancerDescriptions>
<member>
<SecurityGroups>
<member>sg-1</member>
</SecurityGroups>
<LoadBalancerName>foo</LoadBalancerName>
<DNSName>foo.us-east-1.elb.amazonaws.com</DNSName>
<VPCId>vpc-1</VPCId>
<ListenerDescriptions>
<member>
<PolicyNames/>
<Listener>
<Protocol>HTTP</Protocol>
<LoadBalancerPort>80</LoadBalancerPort>
<InstanceProtocol>HTTP</InstanceProtocol>
<InstancePort>9000</InstancePort>
</Listener>
</member>
</ListenerDescriptions>
<AvailabilityZones>
<member>us-east-1a</member>
</AvailabilityZones>
<Scheme>internal</Scheme>
<Subnets>
<member>subnet-1a</member>
</Subnets>
</member>
</LoadBalancerDescriptions>
</DescribeLoadBalancersResult>
</DescribeLoadBalancersResponse>`,
},
},
{
Request: awsutil.Request{
RequestURI: "/",
Body: `Action=DescribeTags&LoadBalancerNames.member.1=foo&Version=2012-06-01`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<DescribeTagsResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<DescribeTagsResult>
<TagDescriptions>
<member>
<Tags>
<member>
<Key>AppName</Key>
<Value>foo</Value>
</member>
<member>
<Key>ProcessType</Key>
<Value>web</Value>
</member>
</Tags>
<LoadBalancerName>foo</LoadBalancerName>
</member>
</TagDescriptions>
</DescribeTagsResult>
</DescribeTagsResponse>`,
},
},
{
Request: awsutil.Request{
RequestURI: "/",
Body: `Action=DescribeLoadBalancers&Marker=%0A%09++++++abcd%0A%09++++&PageSize=20&Version=2012-06-01`,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<DescribeLoadBalancersResult>
<NextMarker></NextMarker>
<LoadBalancerDescriptions>
<member>
<SecurityGroups>
<member>sg-1</member>
</SecurityGroups>
<LoadBalancerName>bar</LoadBalancerName>
<DNSName>bar.us-east-1.elb.amazonaws.com</DNSName>
<VPCId>vpc-1</VPCId>
<ListenerDescriptions>
<member>
<PolicyNames/>
<Listener>
<Protocol>HTTP</Protocol>
<LoadBalancerPort>80</LoadBalancerPort>
<InstanceProtocol>HTTP</InstanceProtocol>
<InstancePort>9001</InstancePort>
//.........这里部分代码省略.........
开发者ID:aaithal,项目名称:empire,代码行数:101,代码来源:elb_test.go
示例15: TestRoute53_zone
func TestRoute53_zone(t *testing.T) {
h := awsutil.NewHandler([]awsutil.Cycle{
{
Request: awsutil.Request{
RequestURI: "/2013-04-01/hostedzone/FAKEZONE",
Body: ``,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<?xml version="1.0"?>
<GetHostedZoneResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<HostedZone>
<Id>/hostedzone/FAKEZONE</Id>
<Name>empire.</Name>
<CallerReference>FakeReference</CallerReference>
<Config>
<Comment>Fake hosted zone comment.</Comment>
<PrivateZone>true</PrivateZone>
</Config>
<ResourceRecordSetCount>2</ResourceRecordSetCount>
</HostedZone>
<VPCs>
<VPC>
<VPCRegion>us-east-1</VPCRegion>
<VPCId>vpc-0d9ea668</VPCId>
</VPC>
</VPCs>
</GetHostedZoneResponse>`,
},
},
{
Request: awsutil.Request{
RequestURI: "/2013-04-01/hostedzone/FAKEZONE",
Body: ``,
},
Response: awsutil.Response{
StatusCode: 200,
Body: `<?xml version="1.0"?>
<GetHostedZoneResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<HostedZone>
<Id>/hostedzone/FAKEZONE</Id>
<Name>empire.</Name>
<CallerReference>FakeReference</CallerReference>
<Config>
<Comment>Fake hosted zone comment.</Comment>
<PrivateZone>true</PrivateZone>
</Config>
<ResourceRecordSetCount>2</ResourceRecordSetCount>
</HostedZone>
<VPCs>
<VPC>
<VPCRegion>us-east-1</VPCRegion>
<VPCId>vpc-0d9ea668</VPCId>
</VPC>
</VPCs>
</GetHostedZoneResponse>`,
},
},
})
// Test both a full path to a zoneID and just the zoneID itself
// Route53Nameserver.zone() should be able to handle both.
zoneIDs := []string{"/hostedzone/FAKEZONE", "FAKEZONE"}
for _, zid := range zoneIDs {
n, s := newTestRoute53Nameserver(h, zid)
defer s.Close()
zone, err := n.zone()
if err != nil {
t.Fatal(err)
}
if *zone.ID != "/hostedzone/FAKEZONE" {
t.Fatalf("Got wrong zone ID: %s\n", *zone.ID)
}
}
}
开发者ID:aaithal,项目名称:empire,代码行数:77,代码来源:dns_test.go
注:本文中的github.com/remind101/empire/pkg/awsutil.NewHandler函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论