Beispiel #1
0
    def test_register_agent_to_auth_protected_host(self):
        r = PsDashRunner({
            'MACDASH_AUTH_USERNAME': '******',
            'MACDASH_AUTH_PASSWORD': '******'
        })
        agent = PsDashRunner({
            'MACDASH_AGENT': True,
            'MACDASH_PORT': 5001,
            'MACDASH_REGISTER_TO': 'http://localhost:5000',
            'MACDASH_AUTH_USERNAME': '******',
            'MACDASH_AUTH_PASSWORD': '******'
        })
        jobs = []
        jobs.append(gevent.spawn(r.run))
        gevent.sleep(0.3)
        jobs.append(gevent.spawn(agent.run))
        gevent.sleep(0.3)

        self.assertIn('127.0.0.1:5001', r.get_nodes())
        self.assertEquals(
            r.get_node('127.0.0.1:5001').name, socket.gethostname())
        self.assertEquals(r.get_node('127.0.0.1:5001').port, 5001)

        r.server.close()
        agent.server.close()
        gevent.killall(jobs)
Beispiel #2
0
    def test_register_agent_without_name_defaults_to_hostname(self):
        agent_options = {
            'MACDASH_AGENT': True,
            'MACDASH_PORT': 5001,
            'MACDASH_REGISTER_TO': 'http://localhost:5000'
        }
        r = PsDashRunner()
        agent = PsDashRunner(agent_options)
        jobs = []
        jobs.append(gevent.spawn(r.run))
        gevent.sleep(0.3)
        jobs.append(gevent.spawn(agent.run))
        gevent.sleep(0.3)

        self.assertIn('127.0.0.1:5001', r.get_nodes())
        self.assertEquals(
            r.get_node('127.0.0.1:5001').name, socket.gethostname())
        self.assertEquals(r.get_node('127.0.0.1:5001').port, 5001)

        r.server.close()
        agent.server.close()
        gevent.killall(jobs)