Precise unit test failure discoverySuite.TestDiscoverInitSystemScript

Bug #1433566 reported by Curtis Hovey
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
juju-core
Fix Released
Critical
Eric Snow
1.23
Fix Released
Critical
Eric Snow

Bug Description

Both run-unit-tests-precise-amd64 and run-unit-tests-precise-i386 are failing because of
FAIL: discovery_test.go:333: discoverySuite.TestDiscoverInitSystemScript
FAIL: discoverySuite.TestNewShellSelectCommand

Revision history for this message
Curtis Hovey (sinzui) wrote :

----------------------------------------------------------------------
FAIL: discovery_test.go:333: discoverySuite.TestDiscoverInitSystemScript

[LOG] 0:00.056 INFO juju.util.exec run result: exit status 1
[LOG] 0:00.075 DEBUG juju.service discovered init system "upstart" from executable "/sbin/init"
discovery_test.go:347:
    c.Check(response.Code, gc.Equals, 0)
... obtained int = 1
... expected int = 0

discovery_test.go:348:
    c.Check(string(response.Stdout), gc.Equals, initSystem)
... obtained string = ""
... expected string = "upstart"

discovery_test.go:349:
    c.Check(string(response.Stderr), gc.Equals, "")
... obtained string = "/tmp/check-1597969999/1/discover_init_system.sh: line 34: /: Is a directory\n"
... expected string = ""

----------------------------------------------------------------------
FAIL: discovery_test.go:359: discoverySuite.TestNewShellSelectCommand

cat > /tmp/check-1597969999/7/discover_init_system.sh << 'EOF'
#!/usr/bin/env bash

function checkInitSystem() {
    if [[ $1 == *"systemd"* ]]; then
        echo -n systemd
        exit $?
    elif [[ $1 == *"upstart"* ]]; then
        echo -n upstart
        exit $?
    fi
}

# Find the executable.
executable=$(cat /proc/1/cmdline | awk -F"\0" '{print $1}')
if [[ $? -ne 0 ]]; then
    exit 1
fi

# Check the executable.
checkInitSystem "$executable"

# First fall back to following symlinks.
if [[ -L $executable ]]; then
    linked=$(readlink -f "$executable")
    if [[ $? -eq 0 ]]; then
        executable=$linked

        # Check the linked executable.
        checkInitSystem "$linked"
    fi
fi

# Fall back to checking the "version" text.
verText=$("${executable}" --version)
if [[ $? -eq 0 ]]; then
    checkInitSystem "$verText"
fi

# uh-oh
exit 1

EOF
chmod 0755 /tmp/check-1597969999/7/discover_init_system.sh
init_system=$(/tmp/check-1597969999/7/discover_init_system.sh)
if [[ $init_system == "systemd" ]]; then echo -n systemd
elif [[ $init_system == "upstart" ]]; then echo -n upstart
else exit 1
fi
[LOG] 0:00.033 INFO juju.util.exec run result: exit status 1
[LOG] 0:00.037 DEBUG juju.service discovered init system "upstart" from executable "/sbin/init"
discovery_test.go:378:
    c.Check(response.Code, gc.Equals, 0)
... obtained int = 1
... expected int = 0

discovery_test.go:379:
    c.Check(string(response.Stdout), gc.Equals, initSystem)
... obtained string = ""
... expected string = "upstart"

discovery_test.go:380:
    c.Check(string(response.Stderr), gc.Equals, "")
... obtained string = "/tmp/check-1597969999/7/discover_init_system.sh: line 34: /: Is a directory\n"
... expected string = ""

OOPS: 27 passed, 2 FAILED

Changed in juju-core:
assignee: nobody → Eric Snow (ericsnowcurrently)
status: Triaged → In Progress
Revision history for this message
Eric Snow (ericsnowcurrently) wrote :

It's odd to me that these tests are not failing on master (from what I can tell). Regardless, I'm looking into it.

Revision history for this message
Eric Snow (ericsnowcurrently) wrote :

Apparently older versions of awk cannot handle \0 as a record separator. The alternative is to use the ps command.

Revision history for this message
Eric Snow (ericsnowcurrently) wrote :
Changed in juju-core:
status: In Progress → Fix Committed
Ian Booth (wallyworld)
Changed in juju-core:
status: Fix Committed → In Progress
milestone: 1.23-beta1 → 1.24-alpha1
Changed in juju-core:
status: In Progress → Fix Committed
Tim Penhey (thumper)
Changed in juju-core:
status: Fix Committed → Fix Released
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.