Exemple #1
0
    def test_matches_existing_entity(self):
        """Ensures that an entity matches when it already exists."""
        template_cfg = config_pb2.InstanceTemplateConfig.InstanceTemplate(
            base_name='base-name', )
        manager_cfg = config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
            maximum_size=3,
            minimum_size=2,
            template_base_name='base-name',
            zone='zone',
        )
        expected_key = parse.get_instance_group_manager_key(
            template_cfg, manager_cfg)
        models.InstanceGroupManager(
            key=expected_key,
            maximum_size=2,
            minimum_size=1,
        ).put()

        future = parse.ensure_instance_group_manager_exists(
            template_cfg, manager_cfg)
        future.wait()
        key = future.get_result()
        entity = key.get()

        self.assertEqual(key, expected_key)
        self.assertEqual(entity.maximum_size, manager_cfg.maximum_size)
        self.assertEqual(entity.minimum_size, manager_cfg.minimum_size)
Exemple #2
0
  def test_matches_existing_entity(self):
    """Ensures that an entity matches when it already exists."""
    template_cfg = config_pb2.InstanceTemplateConfig.InstanceTemplate(
        base_name='base-name',
    )
    manager_cfg = config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
        maximum_size=3,
        minimum_size=2,
        template_base_name='base-name',
        zone='zone',
    )
    expected_key = parse.get_instance_group_manager_key(
        template_cfg, manager_cfg)
    models.InstanceGroupManager(
        key=expected_key,
        maximum_size=2,
        minimum_size=1,
    ).put()

    future = parse.ensure_instance_group_manager_exists(
        template_cfg, manager_cfg)
    future.wait()
    key = future.get_result()
    entity = key.get()

    self.assertEqual(key, expected_key)
    self.assertEqual(entity.maximum_size, manager_cfg.maximum_size)
    self.assertEqual(entity.minimum_size, manager_cfg.minimum_size)
Exemple #3
0
    def test_creates_new_entity(self):
        """Ensures that a new entity is created when one doesn't exist."""
        template_cfg = config_pb2.InstanceTemplateConfig.InstanceTemplate(
            base_name='base-name', )
        manager_cfg = config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
            maximum_size=2,
            minimum_size=1,
            template_base_name='base-name',
            zone='zone',
        )
        expected_key = parse.get_instance_group_manager_key(
            template_cfg, manager_cfg)

        future = parse.ensure_instance_group_manager_exists(
            template_cfg, manager_cfg)
        future.wait()
        key = future.get_result()
        entity = key.get()

        self.assertEqual(key, expected_key)
        self.assertEqual(entity.maximum_size, manager_cfg.maximum_size)
        self.assertEqual(entity.minimum_size, manager_cfg.minimum_size)
Exemple #4
0
  def test_creates_new_entity(self):
    """Ensures that a new entity is created when one doesn't exist."""
    template_cfg = config_pb2.InstanceTemplateConfig.InstanceTemplate(
        base_name='base-name',
    )
    manager_cfg = config_pb2.InstanceGroupManagerConfig.InstanceGroupManager(
        maximum_size=2,
        minimum_size=1,
        template_base_name='base-name',
        zone='zone',
    )
    expected_key = parse.get_instance_group_manager_key(
        template_cfg, manager_cfg)

    future = parse.ensure_instance_group_manager_exists(
        template_cfg, manager_cfg)
    future.wait()
    key = future.get_result()
    entity = key.get()

    self.assertEqual(key, expected_key)
    self.assertEqual(entity.maximum_size, manager_cfg.maximum_size)
    self.assertEqual(entity.minimum_size, manager_cfg.minimum_size)