Пример #1
0
    def test_channel_stopped_irrelevant_channel_nginx_reload(self):
        plugin = NginxPlugin()

        plugin.start_plugin({
            'server_name': 'http//www.example.org',
            'vhost_file': self.make_temp_file(),
            'locations_dir': self.make_temp_dir()
        }, JunebugConfig({}))

        properties = self.create_channel_properties(
            web_path='/foo/bar',
            web_port=2323)

        chan4 = yield self.create_channel(
            self.service, self.redis, id='chan4', properties=properties)

        chan5 = yield self.create_channel(
            self.service, self.redis, id='chan5', properties=properties)

        plugin.channel_started(chan4)

        calls = self.patch_subprocess_call((
            (['which', 'nginx'], 0),
        ))

        plugin.channel_stopped(chan4)
        plugin.channel_stopped(chan5)
        self.assertEqual(calls.count(['nginx', '-s', 'reload']), 1)
Пример #2
0
    def test_channel_stopped_irrelevant_channel_nginx_reload(self):
        plugin = NginxPlugin()

        plugin.start_plugin(
            {
                'server_name': 'http//www.example.org',
                'vhost_file': self.make_temp_file(),
                'locations_dir': self.make_temp_dir()
            }, JunebugConfig({}))

        properties = self.create_channel_properties(config={
            'web_path': '/foo/bar',
            'web_port': 2323,
        })

        chan4 = yield self.create_channel(self.service,
                                          self.redis,
                                          id='chan4',
                                          properties=properties)

        chan5 = yield self.create_channel(self.service,
                                          self.redis,
                                          id='chan5',
                                          properties=properties)

        plugin.channel_started(chan4)

        self.nginx_reloads()  # flush reloads
        plugin.channel_stopped(chan4)
        plugin.channel_stopped(chan5)
        self.assertEqual(self.nginx_reloads(), 1)
Пример #3
0
    def test_channel_stopped(self):
        plugin = NginxPlugin()
        locations_dirname = self.make_temp_dir()

        plugin.start_plugin({
            'server_name': 'http//www.example.org',
            'vhost_file': self.make_temp_file(),
            'locations_dir': locations_dirname
        }, JunebugConfig({}))

        properties = self.create_channel_properties(
            web_path='/foo/bar',
            web_port=2323)

        channel = yield self.create_channel(
            self.service, self.redis, id='chan4', properties=properties)

        plugin.channel_started(channel)

        self.assertTrue(
            path.exists(path.join(locations_dirname, 'chan4.conf')))

        plugin.channel_stopped(channel)

        self.assertFalse(
            path.exists(path.join(locations_dirname, 'chan4.conf')))
Пример #4
0
    def test_channel_stopped(self):
        plugin = NginxPlugin()
        locations_dirname = self.make_temp_dir()

        plugin.start_plugin(
            {
                'server_name': 'http//www.example.org',
                'vhost_file': self.make_temp_file(),
                'locations_dir': locations_dirname
            }, JunebugConfig({}))

        properties = self.create_channel_properties(config={
            'web_path': '/foo/bar',
            'web_port': 2323,
        })

        channel = yield self.create_channel(self.service,
                                            self.redis,
                                            id='chan4',
                                            properties=properties)

        plugin.channel_started(channel)

        self.assertTrue(path.exists(path.join(locations_dirname,
                                              'chan4.conf')))

        plugin.channel_stopped(channel)

        self.assertFalse(
            path.exists(path.join(locations_dirname, 'chan4.conf')))
Пример #5
0
    def test_channel_stopped_irrelevant_channel_nginx_reload(self):
        plugin = NginxPlugin()

        plugin.start_plugin(
            {
                'server_name': 'http//www.example.org',
                'vhost_file': self.make_temp_file(),
                'locations_dir': self.make_temp_dir()
            }, JunebugConfig({}))

        properties = self.create_channel_properties(web_path='/foo/bar',
                                                    web_port=2323)

        chan4 = yield self.create_channel(self.service,
                                          self.redis,
                                          id='chan4',
                                          properties=properties)

        chan5 = yield self.create_channel(self.service,
                                          self.redis,
                                          id='chan5',
                                          properties=properties)

        plugin.channel_started(chan4)

        calls = self.patch_subprocess_call(((['which', 'nginx'], 0), ))

        plugin.channel_stopped(chan4)
        plugin.channel_stopped(chan5)
        self.assertEqual(calls.count(['nginx', '-s', 'reload']), 1)
Пример #6
0
    def test_channel_stopped_irrelevant_channel_nginx_reload(self):
        plugin = NginxPlugin()

        plugin.start_plugin({
            'server_name': 'http//www.example.org',
            'vhost_file': self.make_temp_file(),
            'locations_dir': self.make_temp_dir()
        }, JunebugConfig({}))

        properties = self.create_channel_properties(config={
            'web_path': '/foo/bar',
            'web_port': 2323,
        })

        chan4 = yield self.create_channel(
            self.service, self.redis, id='chan4', properties=properties)

        chan5 = yield self.create_channel(
            self.service, self.redis, id='chan5', properties=properties)

        plugin.channel_started(chan4)

        self.nginx_reloads()  # flush reloads
        plugin.channel_stopped(chan4)
        plugin.channel_stopped(chan5)
        self.assertEqual(self.nginx_reloads(), 1)
Пример #7
0
    def test_channel_stopped_irrelevant_channels(self):
        plugin = NginxPlugin()
        locations_dirname = self.make_temp_dir()

        plugin.start_plugin(
            {
                'server_name': 'http//www.example.org',
                'vhost_file': self.make_temp_file(),
                'locations_dir': locations_dirname
            }, JunebugConfig({}))

        properties = self.create_channel_properties(web_path='/foo/bar',
                                                    web_port=2323)

        chan4 = yield self.create_channel(self.service,
                                          self.redis,
                                          id='chan4',
                                          properties=properties)

        chan5 = yield self.create_channel(self.service,
                                          self.redis,
                                          id='chan5',
                                          properties=properties)

        write(path.join(locations_dirname, 'chan5.conf'), 'foo')
        plugin.channel_started(chan4)

        self.assertTrue(path.exists(path.join(locations_dirname,
                                              'chan4.conf')))

        self.assertTrue(path.exists(path.join(locations_dirname,
                                              'chan5.conf')))

        plugin.channel_stopped(chan4)
        plugin.channel_stopped(chan5)

        self.assertFalse(
            path.exists(path.join(locations_dirname, 'chan4.conf')))

        self.assertTrue(path.exists(path.join(locations_dirname,
                                              'chan5.conf')))
Пример #8
0
    def test_channel_stopped_irrelevant_channels(self):
        plugin = NginxPlugin()
        locations_dirname = self.make_temp_dir()

        plugin.start_plugin({
            'server_name': 'http//www.example.org',
            'vhost_file': self.make_temp_file(),
            'locations_dir': locations_dirname
        }, JunebugConfig({}))

        properties = self.create_channel_properties(config={
            'web_path': '/foo/bar',
            'web_port': 2323,
        })

        chan4 = yield self.create_channel(
            self.service, self.redis, id='chan4', properties=properties)

        chan5 = yield self.create_channel(
            self.service, self.redis, id='chan5', properties=properties)

        write(path.join(locations_dirname, 'chan5.conf'), 'foo')
        plugin.channel_started(chan4)

        self.assertTrue(
            path.exists(path.join(locations_dirname, 'chan4.conf')))

        self.assertTrue(
            path.exists(path.join(locations_dirname, 'chan5.conf')))

        plugin.channel_stopped(chan4)
        plugin.channel_stopped(chan5)

        self.assertFalse(
            path.exists(path.join(locations_dirname, 'chan4.conf')))

        self.assertTrue(
            path.exists(path.join(locations_dirname, 'chan5.conf')))