InstanceLifecycle: aws.String("spot"),
InstanceType: aws.String("t2.micro"),
PrivateIpAddress: aws.String("10.1.2.3"),
- State: &ec2.InstanceState{Name: aws.String("running")},
+ State: &ec2.InstanceState{Name: aws.String("running"), Code: aws.Int64(16)},
}, {
InstanceId: aws.String("i-124"),
InstanceLifecycle: aws.String("spot"),
InstanceType: aws.String("t2.micro"),
PrivateIpAddress: aws.String("10.1.2.4"),
- State: &ec2.InstanceState{Name: aws.String("running")},
+ State: &ec2.InstanceState{Name: aws.String("running"), Code: aws.Int64(16)},
}},
}},
}, nil
return nil, nil
}
-func GetInstanceSet(c *check.C) (cloud.InstanceSet, cloud.ImageID, arvados.Cluster) {
+func GetInstanceSet(c *check.C) (*ec2InstanceSet, cloud.ImageID, arvados.Cluster) {
cluster := arvados.Cluster{
InstanceTypes: arvados.InstanceTypeMap(map[string]arvados.InstanceType{
"tiny": {
ap, err := newEC2InstanceSet(exampleCfg.DriverParameters, "test123", nil, logrus.StandardLogger())
c.Assert(err, check.IsNil)
- return ap, cloud.ImageID(exampleCfg.ImageIDForTestSuite), cluster
+ return ap.(*ec2InstanceSet), cloud.ImageID(exampleCfg.ImageIDForTestSuite), cluster
}
ap := ec2InstanceSet{
- ec2config: ec2InstanceSetConfig{},
instanceSetID: "test123",
logger: logrus.StandardLogger(),
client: &ec2stub{c: c, reftime: time.Now().UTC()},
}
}()
+ ap.ec2config.SpotPriceUpdateInterval = arvados.Duration(time.Hour)
+ ap.ec2config.EBSPrice = 0.1 // $/GiB/month
inst1, err := ap.Create(cluster.InstanceTypes["tiny-preemptible"], img, tags, "true", pk)
c.Assert(err, check.IsNil)
defer inst1.Destroy()
instances, err = ap.Instances(tags)
running := 0
for _, inst := range instances {
- if *inst.(*ec2Instance).instance.InstanceLifecycle == "spot" {
+ ec2i := inst.(*ec2Instance).instance
+ if *ec2i.InstanceLifecycle == "spot" && *ec2i.State.Code&16 != 0 {
running++
}
}
c.Logf("instances are running, and identifiable as spot instances")
break
}
- c.Logf("waiting for instances to be identifiable as spot instances...")
+ c.Logf("waiting for instances to reach running state so their availability zone becomes visible...")
time.Sleep(10 * time.Second)
}
for _, inst := range instances {
- hist := inst.PriceHistory()
+ hist := inst.PriceHistory(arvados.InstanceType{})
c.Logf("%s price history: %v", inst.ID(), hist)
c.Check(len(hist) > 0, check.Equals, true)
+
+ histWithScratch := inst.PriceHistory(arvados.InstanceType{AddedScratch: 640 << 30})
+ c.Logf("%s price history with 640 GiB scratch: %v", inst.ID(), histWithScratch)
+
for i, ip := range hist {
c.Check(ip.Price, check.Not(check.Equals), 0.0)
if i > 0 {
c.Check(ip.StartTime.Before(hist[i-1].StartTime), check.Equals, true)
}
+ c.Check(ip.Price < histWithScratch[i].Price, check.Equals, true)
}
}
}