Skip to content

Commit 4472a9a

Browse files
committed
acceptance_test: use human-readable timestamps
1 parent a7a0fad commit 4472a9a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

acceptance_test/main_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ var _ = Describe("BOSH Windows", func() {
121121
for i := 0; i < redeployRetries; i++ {
122122
By(fmt.Sprintf("Redeploy attempt: #%d\n", i))
123123

124-
version := fmt.Sprintf("0.dev+%d", getTimestampInMs())
124+
version := fmt.Sprintf("0.dev+%s", getTimestamp())
125125
tightLoopStemcellVersions = append(tightLoopStemcellVersions, version)
126126
Expect(boshCommand.RunIn(fmt.Sprintf("create-release --force --version %s", version), releaseDir)).To(Succeed())
127127

@@ -193,11 +193,16 @@ var _ = Describe("BOSH Windows", func() {
193193
})
194194

195195
func buildDeploymentName(baseName string) string {
196-
return fmt.Sprintf("%s-%s-%d", windowsVersion, baseName, getTimestampInMs())
196+
return fmt.Sprintf(
197+
"%s-%s-%s",
198+
windowsVersion,
199+
baseName,
200+
time.Now().Format("2006-01-02T15h04s05"),
201+
)
197202
}
198203

199-
func getTimestampInMs() int64 {
200-
return time.Now().UTC().UnixNano() / int64(time.Millisecond)
204+
func getTimestamp() string {
205+
return time.Now().Format("20060102150405")
201206
}
202207

203208
type TestConfig struct {
@@ -384,7 +389,7 @@ func createBwatsRelease(bosh *BoshCommand) string {
384389
pwd, err := os.Getwd()
385390
Expect(err).NotTo(HaveOccurred())
386391

387-
releaseVersion = fmt.Sprintf("0.dev+%d", getTimestampInMs())
392+
releaseVersion = fmt.Sprintf("0.dev+%s", getTimestamp())
388393
var goZipPath string
389394
if _, err = os.Stat(filepath.Join(pwd, GoZipFile)); os.IsNotExist(err) {
390395
goZipPath, err = downloadFile("golang-", GolangURL)
@@ -498,11 +503,9 @@ func (m ManifestProperties) toMap() map[string]string {
498503
}
499504

500505
func downloadLogs(instanceName string, jobName string, index int, bosh *BoshCommand) *gbytes.Buffer {
501-
tempDir, err := os.MkdirTemp("", "")
502-
Expect(err).NotTo(HaveOccurred())
503-
defer os.RemoveAll(tempDir) //nolint:errcheck
506+
tempDir := GinkgoT().TempDir()
504507

505-
err = bosh.Run(fmt.Sprintf("--deployment=%s logs %s/%d --dir %s", deploymentName, instanceName, index, tempDir))
508+
err := bosh.Run(fmt.Sprintf("--deployment=%s logs %s/%d --dir %s", deploymentName, instanceName, index, tempDir))
506509
Expect(err).NotTo(HaveOccurred())
507510

508511
matches, err := filepath.Glob(filepath.Join(tempDir, fmt.Sprintf("%s.%s.%d-*.tgz", deploymentName, instanceName, index)))
@@ -534,7 +537,9 @@ func downloadFile(prefix, sourceUrl string) (string, error) {
534537
return "", err
535538
}
536539
defer res.Body.Close() //nolint:errcheck
537-
if _, err := io.Copy(f, res.Body); err != nil {
540+
541+
_, err = io.Copy(f, res.Body)
542+
if err != nil {
538543
return "", err
539544
}
540545

0 commit comments

Comments
 (0)