Beispiel #1
0
    def test_drains_and_reactivates(self):
        """Ensures that the active are drained and the drained are reactivated."""
        template_cfg = config_pb2.InstanceTemplateConfig.InstanceTemplate(
            base_name='base-name', )
        manager_cfgs = config_pb2.InstanceGroupManagerConfig(managers=[
            config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
                template_base_name='base-name',
                zone='zone1',
            ),
            config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
                template_base_name='base-name',
                zone='zone2',
            ),
        ], ).managers
        expected_active_keys = [
            parse.get_instance_group_manager_key(template_cfg,
                                                 manager_cfgs[0]),
            parse.get_instance_group_manager_key(template_cfg,
                                                 manager_cfgs[1]),
        ]
        instance_template_revision = models.InstanceTemplateRevision(
            active=[
                ndb.Key(models.InstanceGroupManager, 'fake-key'),
            ],
            drained=expected_active_keys,
        )

        self.failUnless(
            parse.ensure_instance_group_managers_active(
                template_cfg, manager_cfgs, instance_template_revision))
        self.assertItemsEqual(instance_template_revision.active,
                              expected_active_keys)
        self.assertEqual(instance_template_revision.drained[0].id(),
                         'fake-key')
Beispiel #2
0
  def test_drains_and_reactivates(self):
    """Ensures that the active are drained and the drained are reactivated."""
    template_cfg = config_pb2.InstanceTemplateConfig.InstanceTemplate(
        base_name='base-name',
    )
    manager_cfgs = config_pb2.InstanceGroupManagerConfig(
        managers=[
            config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
                template_base_name='base-name',
                zone='zone1',
            ),
            config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
                template_base_name='base-name',
                zone='zone2',
            ),
        ],
    ).managers
    expected_active_keys = [
        parse.get_instance_group_manager_key(template_cfg, manager_cfgs[0]),
        parse.get_instance_group_manager_key(template_cfg, manager_cfgs[1]),
    ]
    instance_template_revision = models.InstanceTemplateRevision(
        active=[
            ndb.Key(models.InstanceGroupManager, 'fake-key'),
        ],
        drained=expected_active_keys,
    )

    self.failUnless(parse.ensure_instance_group_managers_active(
        template_cfg, manager_cfgs, instance_template_revision))
    self.assertItemsEqual(
        instance_template_revision.active, expected_active_keys)
    self.assertEqual(instance_template_revision.drained[0].id(), 'fake-key')
Beispiel #3
0
    def test_activates(self):
        """Ensures that the instance group managers are activated."""
        template_cfg = config_pb2.InstanceTemplateConfig.InstanceTemplate(
            base_name='base-name', )
        manager_cfgs = config_pb2.InstanceGroupManagerConfig(managers=[
            config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
                template_base_name='base-name',
                zone='zone1',
            ),
            config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
                template_base_name='base-name',
                zone='zone2',
            ),
        ], ).managers
        expected_active_keys = [
            parse.get_instance_group_manager_key(template_cfg,
                                                 manager_cfgs[0]),
            parse.get_instance_group_manager_key(template_cfg,
                                                 manager_cfgs[1]),
        ]
        instance_template_revision = models.InstanceTemplateRevision()

        self.failUnless(
            parse.ensure_instance_group_managers_active(
                template_cfg, manager_cfgs, instance_template_revision))
        self.assertItemsEqual(instance_template_revision.active,
                              expected_active_keys)
Beispiel #4
0
  def test_activates(self):
    """Ensures that the instance group managers are activated."""
    template_cfg = config_pb2.InstanceTemplateConfig.InstanceTemplate(
        base_name='base-name',
    )
    manager_cfgs = config_pb2.InstanceGroupManagerConfig(
        managers=[
            config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
                template_base_name='base-name',
                zone='zone1',
            ),
            config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
                template_base_name='base-name',
                zone='zone2',
            ),
        ],
    ).managers
    expected_active_keys = [
        parse.get_instance_group_manager_key(template_cfg, manager_cfgs[0]),
        parse.get_instance_group_manager_key(template_cfg, manager_cfgs[1]),
    ]
    instance_template_revision = models.InstanceTemplateRevision()

    self.failUnless(parse.ensure_instance_group_managers_active(
        template_cfg, manager_cfgs, instance_template_revision))
    self.assertItemsEqual(
        instance_template_revision.active, expected_active_keys)