X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3246e20c201aedc9fd448ab99d7d0950654e218b..c38a28a51ba3fbe3fe58e72a5e16c27f79c89719:/lib/cloud/ec2/ec2_test.go diff --git a/lib/cloud/ec2/ec2_test.go b/lib/cloud/ec2/ec2_test.go index ba65758cca..8b754eacac 100644 --- a/lib/cloud/ec2/ec2_test.go +++ b/lib/cloud/ec2/ec2_test.go @@ -25,16 +25,15 @@ package ec2 import ( "encoding/json" "flag" - "log" "testing" "git.curoverse.com/arvados.git/lib/cloud" + "git.curoverse.com/arvados.git/lib/dispatchcloud/test" "git.curoverse.com/arvados.git/sdk/go/arvados" "git.curoverse.com/arvados.git/sdk/go/config" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/sirupsen/logrus" - "golang.org/x/crypto/ssh" check "gopkg.in/check.v1" ) @@ -61,6 +60,10 @@ func (e *ec2stub) ImportKeyPair(input *ec2.ImportKeyPairInput) (*ec2.ImportKeyPa return nil, nil } +func (e *ec2stub) DescribeKeyPairs(input *ec2.DescribeKeyPairsInput) (*ec2.DescribeKeyPairsOutput, error) { + return &ec2.DescribeKeyPairsOutput{}, nil +} + func (e *ec2stub) RunInstances(input *ec2.RunInstancesInput) (*ec2.Reservation, error) { return &ec2.Reservation{Instances: []*ec2.Instance{&ec2.Instance{ InstanceId: aws.String("i-123"), @@ -118,28 +121,26 @@ func GetInstanceSet() (cloud.InstanceSet, cloud.ImageID, arvados.Cluster, error) return nil, cloud.ImageID(""), cluster, err } - ap, err := newEC2InstanceSet(exampleCfg.DriverParameters, "test123", logrus.StandardLogger()) + ap, err := newEC2InstanceSet(exampleCfg.DriverParameters, "test123", nil, logrus.StandardLogger()) return ap, cloud.ImageID(exampleCfg.ImageIDForTestSuite), cluster, err } ap := ec2InstanceSet{ - ec2config: ec2InstanceSetConfig{}, - dispatcherID: "test123", - logger: logrus.StandardLogger(), - client: &ec2stub{}, - keys: make(map[string]string), + ec2config: ec2InstanceSetConfig{}, + instanceSetID: "test123", + logger: logrus.StandardLogger(), + client: &ec2stub{}, + keys: make(map[string]string), } return &ap, cloud.ImageID("blob"), cluster, nil } -var testKey = []byte(`ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLQS1ExT2+WjA0d/hntEAyAtgeN1W2ik2QX8c2zO6HjlPHWXL92r07W0WMuDib40Pcevpi1BXeBWXA9ZB5KKMJB+ukaAu22KklnQuUmNvk6ZXnPKSkGxuCYvPQb08WhHf3p1VxiKfP3iauedBDM4x9/bkJohlBBQiFXzNUcQ+a6rKiMzmJN2gbL8ncyUzc+XQ5q4JndTwTGtOlzDiGOc9O4z5Dd76wtAVJneOuuNpwfFRVHThpJM6VThpCZOnl8APaceWXKeuwOuCae3COZMz++xQfxOfZ9Z8aIwo+TlQhsRaNfZ4Vjrop6ej8dtfZtgUFKfbXEOYaHrGrWGotFDTD example@example`) - func (*EC2InstanceSetSuite) TestCreate(c *check.C) { ap, img, cluster, err := GetInstanceSet() if err != nil { c.Fatal("Error making provider", err) } - pk, _, _, _, err := ssh.ParseAuthorizedKey(testKey) + pk, _ := test.LoadTestKey(c, "../../dispatchcloud/test/sshkey_dispatch") c.Assert(err, check.IsNil) inst, err := ap.Create(cluster.InstanceTypes["tiny"], @@ -161,7 +162,7 @@ func (*EC2InstanceSetSuite) TestCreateWithExtraScratch(c *check.C) { c.Fatal("Error making provider", err) } - pk, _, _, _, err := ssh.ParseAuthorizedKey(testKey) + pk, _ := test.LoadTestKey(c, "../../dispatchcloud/test/sshkey_dispatch") c.Assert(err, check.IsNil) inst, err := ap.Create(cluster.InstanceTypes["tiny-with-extra-scratch"], @@ -183,7 +184,7 @@ func (*EC2InstanceSetSuite) TestCreatePreemptible(c *check.C) { c.Fatal("Error making provider", err) } - pk, _, _, _, err := ssh.ParseAuthorizedKey(testKey) + pk, _ := test.LoadTestKey(c, "../../dispatchcloud/test/sshkey_dispatch") c.Assert(err, check.IsNil) inst, err := ap.Create(cluster.InstanceTypes["tiny-preemptible"], @@ -227,7 +228,7 @@ func (*EC2InstanceSetSuite) TestListInstances(c *check.C) { for _, i := range l { tg := i.Tags() - log.Printf("%v %v %v", i.String(), i.Address(), tg) + c.Logf("%v %v %v", i.String(), i.Address(), tg) } }