-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[integration] timesync test #3461
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package test_test | ||
|
||
import ( | ||
"os/exec" | ||
"strconv" | ||
|
||
// "github.com/crc-org/crc/test/extended/crc/cmd". | ||
"github.com/crc-org/crc/test/extended/crc/cmd" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
const ( | ||
sleepSeconds = "30" | ||
maxDateDiffInSeconds = 10 | ||
) | ||
|
||
var _ = Describe("Guest machine time should be in sync with host", Label("guest-timesync", "darwin"), func() { | ||
|
||
BeforeSuite(func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way I understand That said, I am not sure if the |
||
It("Ensuring instance is running") | ||
if err := cmd.CheckCRCStatus("running"); err != nil { | ||
// cluster is not running | ||
startInstance() | ||
} | ||
}) | ||
|
||
It("checks instance date is in sync with host after host suspension", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what good practice is in Ginkgo, but I imagine |
||
By("scheduling a suspensions and resume of the host") | ||
Expect(exec.Command("pmset", "relative", sleepSeconds).Run()).To(Succeed()) | ||
Expect(exec.Command("pmset", "sleepnow").Run()).To(Succeed()) | ||
By("getting dates from instance and host") | ||
out, err := exec.Command("date", "-u", "+%s").Output() | ||
Expect(err).To(BeEmpty()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think elsewhere I'm using |
||
hostDate := string(out) | ||
instanceDate, err := SendCommandToVM("date -u +%s") | ||
Expect(err).To(BeEmpty()) | ||
By("ensuring date matches on host and instance") | ||
hostDateAsInt, err := strconv.Atoi(hostDate) | ||
Expect(err).To(BeEmpty()) | ||
instanceDateAsInt, err := strconv.Atoi(instanceDate) | ||
Expect(err).To(BeEmpty()) | ||
dateDiff := instanceDateAsInt - hostDateAsInt | ||
Ω(dateDiff).Should(BeNumerically("<=", maxDateDiffInSeconds)) | ||
}) | ||
|
||
AfterSuite(func() { | ||
// delete instance cleanup... | ||
It("Cleanup instance") | ||
Expect(cmd.CRC("cleanup").Execute()).To(Succeed()) | ||
}) | ||
|
||
}) |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||
package test_test | ||||
|
||||
import ( | ||||
. "github.com/onsi/ginkgo/v2" | ||||
. "github.com/onsi/gomega" | ||||
) | ||||
|
||||
func startInstance() { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd maybe call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, there's a file called crc/test/e2e/testsuite/testsuite.go Line 583 in e3054a1
extended we can later refactor it to be used in multiple places. Again, up to you.
|
||||
// cluster is not running | ||||
if bundlePath == "" { | ||||
Expect(RunCRCExpectSuccess("setup")).To(ContainSubstring("Your system is correctly setup for using CRC")) | ||||
} else { | ||||
Expect(RunCRCExpectSuccess("setup", "-b", bundlePath)).To(ContainSubstring("Your system is correctly setup for using CRC")) | ||||
} | ||||
It("start CRC", func() { | ||||
Expect(RunCRCExpectSuccess("start", "-p", pullSecretPath)).To(ContainSubstring("Started the OpenShift cluster")) | ||||
}) | ||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this line can be removed?