~free.ekanayaka/landscape-charm/cleanup-legacy-integration-tests

« back to all changes in this revision

Viewing changes to tests/01-begin.py

  • Committer: Free Ekanayaka
  • Date: 2015-04-20 08:56:42 UTC
  • mfrom: (248.1.2 landscape-charm)
  • Revision ID: free.ekanayaka@canonical.com-20150420085642-69xjrsi03pzfv91y
Merge from trunk, fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from helpers import (
21
21
    check_url, juju_status, find_address, get_landscape_units,
22
 
    get_landscape_service_conf, BaseLandscapeTests)
 
22
    get_landscape_service_conf, BaseLandscapeTests, run_command_on_unit)
23
23
 
24
24
 
25
25
log = logging.getLogger(__file__)
149
149
        cls.landscape_units = get_landscape_units(cls.juju_status)
150
150
        cls.first_unit = cls.landscape_units[0]
151
151
 
152
 
    def run_command_on_unit(self, cmd, unit):
153
 
        output = check_output(["juju", "ssh", unit, cmd], stderr=PIPE)
154
 
        return output.decode("utf-8").strip()
155
 
 
156
152
    def stop_server(self, name, unit):
157
153
        cmd = "sudo service %s stop" % name
158
 
        self.run_command_on_unit(cmd, unit)
 
154
        run_command_on_unit(cmd, unit)
159
155
 
160
156
    def start_server(self, name, unit):
161
157
        cmd = "sudo service %s start" % name
162
 
        self.run_command_on_unit(cmd, unit)
 
158
        run_command_on_unit(cmd, unit)
163
159
 
164
160
    def test_app_unavailable_page(self):
165
161
        """
332
328
        check_output(cmd, stderr=PIPE)
333
329
 
334
330
 
 
331
class LandscapeSSLCertificateTests(BaseLandscapeTests):
 
332
 
 
333
    @classmethod
 
334
    def setUpClass(cls):
 
335
        """Prepares juju_status and other attributes that many tests use."""
 
336
        cls.juju_status = juju_status()
 
337
        cls.first_unit = get_landscape_units(cls.juju_status)[0]
 
338
 
 
339
    def test_ssl_certificate_is_in_place(self):
 
340
        """
 
341
        The landscape-server charm looks at the SSL certificate set on the
 
342
        relation with haproxy and writes it on disk in the location that
 
343
        the application expects (it will need it when generating client
 
344
        configuration for Autopilot deployments).
 
345
        """
 
346
        ssl_cert = run_command_on_unit(
 
347
            "cat /etc/ssl/certs/landscape_server_ca.crt", self.first_unit)
 
348
        self.assertTrue(ssl_cert.startswith("-----BEGIN CERTIFICATE-----"))
 
349
 
 
350
 
335
351
if __name__ == "__main__":
336
352
    logging.basicConfig(
337
353
        level='DEBUG', format='%(asctime)s %(levelname)s %(message)s')