~yolanda.robla/ubuntu/saucy/squid3/fix-squid3-startstop

« back to all changes in this revision

Viewing changes to debian/tests/testlib_httpd.py

  • Committer: yolanda.robla at canonical
  • Date: 2013-06-07 09:41:47 UTC
  • Revision ID: yolanda.robla@canonical.com-20130607094147-fj4fg1wgfy1kxx68
fixes in start/stop

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        self.access_log = "/var/log/apache2/access.log"
48
48
        self.error_log = "/var/log/apache2/error.log"
49
49
        if not hasattr(self, 'initscript'):
50
 
            self._set_initscript("/etc/init.d/apache2")
 
50
            self._set_initscript("apache2")
51
51
 
52
52
        # Dapper's apache2 is disabled by default
53
53
        if self.lsb_release['Release'] == 6.06:
83
83
        testlib.config_restore(self.apache2_default)
84
84
 
85
85
    def _start(self):
86
 
        '''Start httpd'''
87
 
        #print self.initscript,"start"
88
 
        if self.lsb_release['Release'] >= 12.04:
 
86
        '''Start process'''
 
87
        # check if there is a /etc/init/initscript.conf
 
88
        if os.path.exists("/etc/init/%s.conf" % self.initscript):
89
89
            rc, report = testlib.cmd(['start', self.initscript])
90
90
        else:
91
 
            rc, report = testlib.cmd([self.initscript, 'start'])
 
91
            rc, report = testlib.cmd(["/etc/init.d/%s" % self.initscript, 'start'])
92
92
 
93
93
        expected = 0
94
94
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
96
96
        time.sleep(2)
97
97
 
98
98
    def _stop(self):
99
 
        '''Stop httpd'''
 
99
        '''Stop process'''
100
100
        # check if process is running
101
 
        rc, pidof = testlib.cmd(['pidof', '-x', self.initscript])
102
 
        if pidof:
103
 
            #print self.initscript,"stop"
104
 
            if self.lsb_release['Release'] >= 12.04:
 
101
        if os.path.exists("/etc/init/%s.conf" % self.initscript):
 
102
            rc, pidof = testlib.cmd(['pidof', '-x', self.initscript])
 
103
            if pidof:
105
104
                rc, report = testlib.cmd(['stop', self.initscript])
106
105
            else:
107
 
                rc, report = testlib.cmd([self.initscript, 'stop'])
 
106
                # no need to stop it, it's stopped
 
107
                rc, report = (0, '')
 
108
        else:
 
109
            rc, report = testlib.cmd([self.initscript, 'stop'])
108
110
 
109
 
            expected = 0
110
 
            result = 'Got exit code %d, expected %d\n' % (rc, expected)
111
 
            self.assertEquals(expected, rc, result + report)
 
111
        expected = 0
 
112
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
 
113
        self.assertEquals(expected, rc, result + report)
112
114
 
113
115
    def _clearlogs(self):
114
116
        '''Clear httpd logs'''