本文整理汇总了Golang中launchpad/net/goamz/s3/s3test.NewServer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewServer函数的具体用法?Golang NewServer怎么用?Golang NewServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewServer函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestBootstrapInstanceIdHealerHeal
func (s *S) TestBootstrapInstanceIdHealerHeal(c *gocheck.C) {
ec2Server, err := ec2test.NewServer()
c.Assert(err, gocheck.IsNil)
defer ec2Server.Quit()
s3Server, err := s3test.NewServer(nil)
c.Assert(err, gocheck.IsNil)
defer s3Server.Quit()
h := bootstrapInstanceIdHealer{}
region := aws.SAEast
region.EC2Endpoint = ec2Server.URL()
region.S3Endpoint = s3Server.URL()
h.e = ec2.New(aws.Auth{AccessKey: "some", SecretKey: "thing"}, region)
sg, err := h.ec2().CreateSecurityGroup("juju-delta-0", "")
c.Assert(err, gocheck.IsNil)
h.s = s3.New(aws.Auth{AccessKey: "some", SecretKey: "thing"}, region)
jujuBucket := "ble"
config.Set("juju:bucket", jujuBucket)
bucket := h.s3().Bucket(jujuBucket)
err = bucket.PutBucket(s3.PublicReadWrite)
c.Assert(err, gocheck.IsNil)
resp, err := h.ec2().RunInstances(&ec2.RunInstances{MaxCount: 1, SecurityGroups: []ec2.SecurityGroup{sg.SecurityGroup}})
c.Assert(err, gocheck.IsNil)
err = bucket.Put("provider-state", []byte("doesnotexist"), "binary/octet-stream", s3.PublicReadWrite)
c.Assert(err, gocheck.IsNil)
c.Assert(h.needsHeal(), gocheck.Equals, true)
err = h.Heal()
c.Assert(err, gocheck.IsNil)
data, err := bucket.Get("provider-state")
expected := "zookeeper-instances: [" + resp.Instances[0].InstanceId + "]"
c.Assert(string(data), gocheck.Equals, expected)
}
示例2: startServer
func (srv *localServer) startServer(c *gc.C) {
var err error
srv.ec2srv, err = ec2test.NewServer()
if err != nil {
c.Fatalf("cannot start ec2 test server: %v", err)
}
srv.s3srv, err = s3test.NewServer(srv.config)
if err != nil {
c.Fatalf("cannot start s3 test server: %v", err)
}
aws.Regions["test"] = aws.Region{
Name: "test",
EC2Endpoint: srv.ec2srv.URL(),
S3Endpoint: srv.s3srv.URL(),
S3LocationConstraint: true,
Sign: aws.SignV2,
}
s3inst := s3.New(aws.Auth{}, aws.Regions["test"])
storage := ec2.BucketStorage(s3inst.Bucket("juju-dist"))
envtesting.UploadFakeTools(c, storage)
srv.addSpice(c)
zones := make([]amzec2.AvailabilityZoneInfo, 3)
zones[0].Region = "test"
zones[0].Name = "test-available"
zones[0].State = "available"
zones[1].Region = "test"
zones[1].Name = "test-impaired"
zones[1].State = "impaired"
zones[2].Region = "test"
zones[2].Name = "test-unavailable"
zones[2].State = "unavailable"
srv.ec2srv.SetAvailabilityZones(zones)
}
示例3: SetUp
func (s *LocalServer) SetUp(c *C) {
srv, err := s3test.NewServer()
c.Assert(err, IsNil)
c.Assert(srv, NotNil)
s.srv = srv
s.region = aws.Region{S3Endpoint: srv.URL()}
}
示例4: main
func main() {
server, err := s3test.NewServer()
if err != nil {
log.Fatalf("Failed to start server: %s.", err)
}
defer server.Quit()
fmt.Printf("Server is listening at %s.\nPress Ctrl-C to close it.\n", server.URL())
for {
}
}
示例5: StartAmzS3AndIAM
func (t *T) StartAmzS3AndIAM(c *gocheck.C) {
var err error
t.S3Server, err = s3test.NewServer(&s3test.Config{Send409Conflict: true})
c.Assert(err, gocheck.IsNil)
config.Set("aws:s3:endpoint", t.S3Server.URL())
t.IamServer, err = iamtest.NewServer()
c.Assert(err, gocheck.IsNil)
config.Set("aws:iam:endpoint", t.IamServer.URL())
config.Unset("aws:s3:bucketEndpoint")
}
示例6: SetUp
func (s *LocalServer) SetUp(c *C) {
srv, err := s3test.NewServer(s.config)
c.Assert(err, IsNil)
c.Assert(srv, NotNil)
s.srv = srv
s.region = aws.Region{
Name: "faux-region-1",
S3Endpoint: srv.URL(),
S3LocationConstraint: true, // s3test server requires a LocationConstraint
}
}
示例7: startServer
func (srv *localServer) startServer(c *C) {
var err error
srv.ec2srv, err = ec2test.NewServer()
if err != nil {
c.Fatalf("cannot start ec2 test server: %v", err)
}
srv.s3srv, err = s3test.NewServer(srv.config)
if err != nil {
c.Fatalf("cannot start s3 test server: %v", err)
}
aws.Regions["test"] = aws.Region{
Name: "test",
EC2Endpoint: srv.ec2srv.URL(),
S3Endpoint: srv.s3srv.URL(),
S3LocationConstraint: true,
}
s3inst := s3.New(aws.Auth{}, aws.Regions["test"])
putFakeTools(c, ec2.BucketStorage(s3inst.Bucket("public-tools")))
srv.addSpice(c)
}
示例8: TestBootstrapInstanceIdHealerNeedsHeal
func (s *S) TestBootstrapInstanceIdHealerNeedsHeal(c *gocheck.C) {
ec2Server, err := ec2test.NewServer()
c.Assert(err, gocheck.IsNil)
defer ec2Server.Quit()
s3Server, err := s3test.NewServer(nil)
c.Assert(err, gocheck.IsNil)
defer s3Server.Quit()
h := bootstrapInstanceIdHealer{}
region := aws.SAEast
region.EC2Endpoint = ec2Server.URL()
region.S3Endpoint = s3Server.URL()
h.e = ec2.New(aws.Auth{AccessKey: "some", SecretKey: "thing"}, region)
h.s = s3.New(aws.Auth{AccessKey: "some", SecretKey: "thing"}, region)
jujuBucket := "ble"
config.Set("juju:bucket", jujuBucket)
bucket := h.s3().Bucket(jujuBucket)
err = bucket.PutBucket(s3.PublicReadWrite)
c.Assert(err, gocheck.IsNil)
err = bucket.Put("provider-state", []byte("doesnotexist"), "binary/octet-stream", s3.PublicReadWrite)
c.Assert(err, gocheck.IsNil)
c.Assert(h.needsHeal(), gocheck.Equals, true)
}