Tests require predictable map ordering

Bug #1427149 reported by James Tunnicliffe
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
juju-core
Fix Released
High
James Tunnicliffe

Bug Description

In gccgo or newer go versions we can't assume that map ordering is fixed, which results in some new test failures, for example:

dooferlad@homework2:~/juju/service$ go test

----------------------------------------------------------------------
FAIL: service_test.go:49: serviceSuite.TestListServicesCommand

service_test.go:64:
    c.Check(cmd, gc.Equals, strings.Join([]string{
        fmt.Sprintf(line, "/sbin/init", upstart),
        "el" + fmt.Sprintf(line, "/sbin/upstart", upstart),
        "el" + fmt.Sprintf(line, "/sbin/systemd", systemd),
        "el" + fmt.Sprintf(line, "/bin/systemd", systemd),
        "el" + fmt.Sprintf(line, "/lib/systemd/systemd", systemd),
        "else exit 1",
        "fi",
    }, "\n"))
... obtained string = "" +
... "if [[ \"$(cat /proc/1/cmdline)\" == \"/lib/systemd/systemd\" ]]; then /bin/systemctl list-unit-files --no-legend --no-page -t service | grep -o -P '^\\w[\\S]*(?=\\.service)'\n" +
... "elif [[ \"$(cat /proc/1/cmdline)\" == \"/sbin/init\" ]]; then sudo initctl list | awk '{print $1}' | sort | uniq\n" +
... "elif [[ \"$(cat /proc/1/cmdline)\" == \"/sbin/upstart\" ]]; then sudo initctl list | awk '{print $1}' | sort | uniq\n" +
... "elif [[ \"$(cat /proc/1/cmdline)\" == \"/sbin/systemd\" ]]; then /bin/systemctl list-unit-files --no-legend --no-page -t service | grep -o -P '^\\w[\\S]*(?=\\.service)'\n" +
... "elif [[ \"$(cat /proc/1/cmdline)\" == \"/bin/systemd\" ]]; then /bin/systemctl list-unit-files --no-legend --no-page -t service | grep -o -P '^\\w[\\S]*(?=\\.service)'\n" +
... "else exit 1\n" +
... "fi"
... expected string = "" +
... "if [[ \"$(cat /proc/1/cmdline)\" == \"/sbin/init\" ]]; then sudo initctl list | awk '{print $1}' | sort | uniq\n" +
... "elif [[ \"$(cat /proc/1/cmdline)\" == \"/sbin/upstart\" ]]; then sudo initctl list | awk '{print $1}' | sort | uniq\n" +
... "elif [[ \"$(cat /proc/1/cmdline)\" == \"/sbin/systemd\" ]]; then /bin/systemctl list-unit-files --no-legend --no-page -t service | grep -o -P '^\\w[\\S]*(?=\\.service)'\n" +
... "elif [[ \"$(cat /proc/1/cmdline)\" == \"/bin/systemd\" ]]; then /bin/systemctl list-unit-files --no-legend --no-page -t service | grep -o -P '^\\w[\\S]*(?=\\.service)'\n" +
... "elif [[ \"$(cat /proc/1/cmdline)\" == \"/lib/systemd/systemd\" ]]; then /bin/systemctl list-unit-files --no-legend --no-page -t service | grep -o -P '^\\w[\\S]*(?=\\.service)'\n" +
... "else exit 1\n" +
... "fi"

OOPS: 5 passed, 1 FAILED
--- FAIL: TestPackage (0.01s)
FAIL
exit status 1
FAIL github.com/juju/juju/service 0.022s

Changed in juju:
assignee: nobody → James Tunnicliffe (dooferlad)
affects: juju → juju-core
Changed in juju-core:
status: New → In Progress
tags: added: ci regression test-failure
Changed in juju-core:
importance: Undecided → High
milestone: none → 1.23
Revision history for this message
Dimiter Naydenov (dimitern) wrote :
Revision history for this message
Aaron Bentley (abentley) wrote :

Could you please check whether that also fixes https://bugs.launchpad.net/juju-core/+bug/1427454 ?

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Actually I think I have found another instance of this in github.com/juju/juju/apiserver/provisioner. Unfortunately you can't just run all the test once and say you have fixed all the problems - I am doing a lot of repeated testing today!

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

@abently yes, this is the same problem and I have fixed that particular failure. I think I have them all now.

Changed in juju-core:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
Changed in juju-core:
status: Fix Committed → Fix Released
Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 1.23 → 1.23-beta1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.