Skip to content

Commit

Permalink
spread: improve openstackName() test and make it similar to "google" …
Browse files Browse the repository at this point in the history
…again
  • Loading branch information
mvo5 committed Aug 17, 2023
1 parent 0e4f033 commit 9053022
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions spread/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ runcmd:
- pkill -o -HUP sshd || true
`
const openstackReadyMarker = "MACHINE-IS-READY"
const openstackNameLayout = "Jan021504.000000"
const openstackDefaultFlavor = "m1.medium"

type openstackImage struct {
Expand All @@ -182,10 +183,7 @@ type openstackImagesCache struct {

var timeNow = time.Now

// XXX: add docstring
func openstackName() string {
// XXX: granularity will be 1min?
const openstackNameLayout = "Jan021504.000000"
return strings.ToLower(strings.Replace(timeNow().UTC().Format(openstackNameLayout), ".", "-", 1))
}

Expand Down
4 changes: 2 additions & 2 deletions spread/openstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ func (s *openstackSuite) TestTrivial(c *C) {

func (s *openstackSuite) TestOpenstackName(c *C) {
restore := spread.MockTimeNow(func() time.Time {
return time.Date(2007, 8, 22, 11, 59, 58, 999, time.UTC)
return time.Date(2007, 8, 22, 11, 59, 58, 987654321, time.UTC)
})
defer restore()

name := spread.OpenstackName()
c.Check(name, Equals, "aug221159-000000")
c.Check(name, Equals, "aug221159-987654")
}

type fakeGlanceImageClient struct {
Expand Down

0 comments on commit 9053022

Please sign in to comment.