コード例 #1
0
    def test_old_container_is_removed_after_threshold(self):
        new_containers = [{'Id':'c2','ikey':'k2', 'unregistered': None}]
        current_containers = {'c1': {'Id':'c1','ikey':'k1', 'unregistered': time.time() - 70}}

        updated_containers = DockerCollector.remove_old_containers(current_containers, new_containers)

        self.assertTrue(len(updated_containers) == 0)
コード例 #2
0
    def test_old_container_is_not_removed_immediately(self):
        new_containers = [{'Id':'c2','ikey':'k2', 'unregistered': None}]
        current_containers = {'c1': {'Id':'c1','ikey':'k1', 'unregistered': time.time()}}

        updated_containers = DockerCollector.remove_old_containers(current_containers, new_containers)

        self.assertEqual(current_containers['c1']['Id'], updated_containers['c1']['Id'])
コード例 #3
0
    def test_old_container_is_removed_after_threshold(self):
        new_containers = [{'Id': 'c2', 'ikey': 'k2', 'unregistered': None}]
        current_containers = {
            'c1': {
                'Id': 'c1',
                'ikey': 'k1',
                'unregistered': time.time() - 70
            }
        }

        updated_containers = DockerCollector.remove_old_containers(
            current_containers, new_containers)

        self.assertTrue(len(updated_containers) == 0)
コード例 #4
0
    def test_old_container_is_not_removed_immediately(self):
        new_containers = [{'Id': 'c2', 'ikey': 'k2', 'unregistered': None}]
        current_containers = {
            'c1': {
                'Id': 'c1',
                'ikey': 'k1',
                'unregistered': time.time()
            }
        }

        updated_containers = DockerCollector.remove_old_containers(
            current_containers, new_containers)

        self.assertEqual(current_containers['c1']['Id'],
                         updated_containers['c1']['Id'])