Skip to content

Commit

Permalink
Merge pull request #512 from flatcar/jepio/ntp-test-fix
Browse files Browse the repository at this point in the history
fix check for systemd-timesyncd.service
  • Loading branch information
jepio authored Mar 26, 2024
2 parents dd7518a + 3d28115 commit 7f38187
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions kola/tests/bpf/local-gadget.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func localGadgetTest(c cluster.TestCluster) {

tmpl, err := template.New("user-data").Parse(config)
if err != nil {
c.Fatalf("parsing user-data: %w", err)
c.Fatalf("parsing user-data: %v", err)
}

c.Run("dns gadget", func(c cluster.TestCluster) {
Expand All @@ -133,7 +133,7 @@ func localGadgetTest(c cluster.TestCluster) {

var buf bytes.Buffer
if err := tmpl.Execute(&buf, gadget); err != nil {
c.Fatalf("rendering user-data: %w", err)
c.Fatalf("rendering user-data: %v", err)
}

node, err := c.NewMachine(conf.ContainerLinuxConfig(buf.String()))
Expand Down
23 changes: 17 additions & 6 deletions kola/tests/coretest/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,27 +322,38 @@ func TestServicesActive() error {
return servicesActive([]string{
"multi-user.target",
"docker.socket",
"systemd-timesyncd.service",
"update-engine.service",
}, []string{
"systemd-timesyncd.service",
"chronyd.service",
"ntpd.service",
})
}

func TestServicesActiveCoreOS() error {
return servicesActive([]string{
"multi-user.target",
})
}, []string{})
}

func servicesActive(units []string) error {
func servicesActive(allOf []string, anyOf []string) error {
//t.Parallel()
for _, unit := range units {
for _, unit := range allOf {
c := exec.Command("systemctl", "is-active", unit)
err := c.Run()
if err != nil {
return fmt.Errorf("Services Active: %v", err)
return fmt.Errorf("services Active: %s: %v", unit, err)
}
}
return nil
var err error
for _, unit := range anyOf {
c := exec.Command("systemctl", "is-active", unit)
err = c.Run()
if err == nil {
return nil
}
}
return fmt.Errorf("no NTP service active: %v", err)
}

func TestServicesDisabledRHCOS() error {
Expand Down
2 changes: 1 addition & 1 deletion kola/tests/ostree/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func ostreeRemoteTest(c cluster.TestCluster) {
osRemoteListSplit := strings.Split(string(osRemoteListOut), "\n")
// should have original remote + newly added remote
if len(osRemoteListSplit) != initialRemotesNum+1 {
c.Fatalf(`Did not find expected amount of ostree remotes: %q. Expected %d`, string(osRemoteListOut), osRemoteListSplit)
c.Fatalf(`Did not find expected amount of ostree remotes: %q. Expected %d`, string(osRemoteListOut), len(osRemoteListSplit))
}

var remoteFound bool = false
Expand Down
2 changes: 1 addition & 1 deletion kola/tests/ostree/unlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func ostreeHotfixTest(c cluster.TestCluster) {
}

if rollbackStatus.Deployments[0].Unlocked != "none" {
c.Fatalf(`Rollback did not remove hotfix mode; got: $q`, rollbackStatus.Deployments[0].Unlocked)
c.Fatalf(`Rollback did not remove hotfix mode; got: %q`, rollbackStatus.Deployments[0].Unlocked)
}

_, secCmdErr := c.SSH(m, ("command -v " + rpmName))
Expand Down
2 changes: 1 addition & 1 deletion kola/tests/rpmostree/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func rpmOstreeInstallUninstall(c cluster.TestCluster) {

// check the metadata to make sure everything went well
if len(postUninstallStatus.Deployments) != 2 {
c.Fatal("Expected %d deployments, got %d", 2, len(postUninstallStatus.Deployments))
c.Fatalf("Expected %d deployments, got %d", 2, len(postUninstallStatus.Deployments))
}

if postUninstallStatus.Deployments[0].Checksum != originalCsum {
Expand Down
4 changes: 4 additions & 0 deletions kola/tests/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func init() {
inline: |
[Service]
ExecStart=/bin/echo "should be deleted because its part of the Azure OEM cleanup paths"
systemd:
units:
- name: chronyd.service
mask: true
`),
})
register.Register(&register.Test{
Expand Down

0 comments on commit 7f38187

Please sign in to comment.