From 9053022cba28214d14cfecf72b0d610dba41e235 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 17 Aug 2023 18:25:53 +0200 Subject: [PATCH] spread: improve openstackName() test and make it similar to "google" again --- spread/openstack.go | 4 +--- spread/openstack_test.go | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/spread/openstack.go b/spread/openstack.go index ac44b8e4..d97d6795 100644 --- a/spread/openstack.go +++ b/spread/openstack.go @@ -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 { @@ -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)) } diff --git a/spread/openstack_test.go b/spread/openstack_test.go index 518694db..0ad5dc77 100644 --- a/spread/openstack_test.go +++ b/spread/openstack_test.go @@ -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 {