CiscoCloud / distributive

Unit testing for the cloud
Apache License 2.0
147 stars 20 forks source link

filesystem.go: file check - exception handling #41

Closed langston-barrett closed 9 years ago

langston-barrett commented 9 years ago

It seems if the file isn't there the error it throughs isn't a very had one. @noahjl discovered this in the haproxy.json health checks.

This was using version 0.1.1 on the mi vagrant box.


# The way to cause it - 

bash-4.2# distributive -v=2 -f haproxy.json
Running with verbosity level 2
Creating checklist(s)...
Running checklist: haproxy health check
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x30 pc=0x418a70]

goroutine 1 [running]:
main.func·001(0xc20801c5a0, 0x14, 0x4a41b5, 0x0, 0x0)
        /home/vagrant/rpmbuild/BUILD/distributive-0.1.1/filesystem.go:38 +0x70
main.isType(0x73d0b0, 0x4, 0x7cead0, 0xc20801c5a0, 0x14, 0x10, 0x0, 0x0)
        /home/vagrant/rpmbuild/BUILD/distributive-0.1.1/filesystem.go:20 +0x58
main.file(0xc20800a240, 0x1, 0x4, 0x1, 0x0, 0x0)
        /home/vagrant/rpmbuild/BUILD/distributive-0.1.1/filesystem.go:43 +0x6e
main.runChecks(0xc20801c4e0, 0x14, 0xc20803ad80, 0x28, 0xc20803c320, 0x2, 0x2, 0x0, 0x0, 0x0, ...)
        /home/vagrant/rpmbuild/BUILD/distributive-0.1.1/main.go:288 +0x3b2
main.main()
        /home/vagrant/rpmbuild/BUILD/distributive-0.1.1/main.go:326 +0x31f

# The particular file used to get here
-bash-4.2# cat haproxy.json
{
    "Name": "haproxy health check",
    "Notes": "For use with Microservice Infrastructure",
    "Checklist" : [
        {
            "Name": "haproxy environment file",
            "Check": "file",
            "Parameters": ["/etc/default/haproxy"]
        },
        {
            "Name": "haproxy configuration file",
            "Check": "file",
            "Parameters": ["/usr/lib/systemd/system/haproxy.service"]
        }
    ]
}