Пример #1
0
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)
}
Пример #2
0
func (t *LiveTests) TestPutBucketOnlyOnce(c *gc.C) {
	t.PrepareOnce(c)
	s3inst := ec2.EnvironS3(t.Env)
	b, err := s3inst.Bucket("test-once-" + uniqueName)
	c.Assert(err, jc.ErrorIsNil)
	s := ec2.BucketStorage(b)

	// Check that we don't do a PutBucket every time by
	// getting it to create the bucket, destroying the bucket behind
	// the scenes, and trying to put another object,
	// which should fail because it doesn't try to do
	// the PutBucket again.

	err = s.Put("test-object", strings.NewReader("test"), 4)
	c.Assert(err, jc.ErrorIsNil)

	err = s.Remove("test-object")
	c.Assert(err, jc.ErrorIsNil)

	err = ec2.DeleteBucket(s)
	c.Assert(err, jc.ErrorIsNil)

	err = s.Put("test-object", strings.NewReader("test"), 4)
	c.Assert(err, gc.ErrorMatches, ".*The specified bucket does not exist")
}