Exemplo n.º 1
0
 def get(self):
     cleanup.schedule_deleted_instance_check()
     cleanup.schedule_deleted_instance_cleanup()
     cleanup.schedule_drained_instance_cleanup()
     cleanup.cleanup_instance_group_managers()
     cleanup.cleanup_instance_template_revisions()
     cleanup.cleanup_instance_templates()
Exemplo n.º 2
0
    def test_no_entities(self):
        def get_drained_instance_template_revisions(*args, **kwargs):
            return []

        @ndb.tasklet
        def delete_instance_template_revision(*args, **kwargs):
            self.fail('delete_instance_template_revision called')

        self.mock(
            cleanup.instance_templates,
            'get_drained_instance_template_revisions',
            get_drained_instance_template_revisions,
        )
        self.mock(
            cleanup,
            'delete_instance_template_revision',
            delete_instance_template_revision,
        )

        cleanup.cleanup_instance_template_revisions()
        self.failIf(models.InstanceTemplateRevision.query().count())
Exemplo n.º 3
0
    def test_deletes(self):
        def get_drained_instance_template_revisions(*args, **kwargs):
            return [
                ndb.Key(models.InstanceTemplateRevision, 'fake-key-1'),
                ndb.Key(models.InstanceTemplateRevision, 'fake-key-3'),
                ndb.Key(models.InstanceTemplateRevision, 'fake-key-4'),
            ]

        @ndb.tasklet
        def delete_instance_template_revision(key):
            yield key.delete_async()

        self.mock(
            cleanup.instance_templates,
            'get_drained_instance_template_revisions',
            get_drained_instance_template_revisions,
        )
        self.mock(
            cleanup,
            'delete_instance_template_revision',
            delete_instance_template_revision,
        )
        models.InstanceTemplateRevision(key=ndb.Key(
            models.InstanceTemplateRevision, 'fake-key-1'), ).put()
        models.InstanceTemplateRevision(key=ndb.Key(
            models.InstanceTemplateRevision, 'fake-key-2'), ).put()
        models.InstanceTemplateRevision(key=ndb.Key(
            models.InstanceTemplateRevision, 'fake-key-3'), ).put()
        models.InstanceTemplateRevision(key=ndb.Key(
            models.InstanceTemplateRevision, 'fake-key-4'), ).put()

        cleanup.cleanup_instance_template_revisions(max_concurrent=2)
        self.failIf(
            ndb.Key(models.InstanceTemplateRevision, 'fake-key-1').get())
        self.failUnless(
            ndb.Key(models.InstanceTemplateRevision, 'fake-key-2').get())
        self.failIf(
            ndb.Key(models.InstanceTemplateRevision, 'fake-key-3').get())
        self.failIf(
            ndb.Key(models.InstanceTemplateRevision, 'fake-key-4').get())
Exemplo n.º 4
0
 def get(self):
   cleanup.schedule_deleted_instance_cleanup()
   cleanup.schedule_drained_instance_cleanup()
   cleanup.cleanup_instance_group_managers()
   cleanup.cleanup_instance_template_revisions()
   cleanup.cleanup_instance_templates()