當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript instance.write.service.InstanceWriter類代碼示例

本文整理匯總了TypeScript中core/instance/instance.write.service.InstanceWriter的典型用法代碼示例。如果您正苦於以下問題:TypeScript write.service.InstanceWriter類的具體用法?TypeScript write.service.InstanceWriter怎麽用?TypeScript write.service.InstanceWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了write.service.InstanceWriter類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe('Service: instance writer', function () {
  let service: InstanceWriter,
    serverGroupReader: ServerGroupReader,
    taskExecutor: TaskExecutor,
    $q: ng.IQService,
    $scope: ng.IScope,
    applicationModelBuilder: ApplicationModelBuilder,
    MultiselectModel: any;

  beforeEach(
    mock.module(
      INSTANCE_WRITE_SERVICE,
      APPLICATION_MODEL_BUILDER,
      require('../cluster/filter/multiselect.model').name
    )
  );

  beforeEach(
    mock.inject((instanceWriter: InstanceWriter,
                 _taskExecutor_: TaskExecutor,
                 _serverGroupReader_: ServerGroupReader,
                 _$q_: ng.IQService,
                 $rootScope: ng.IRootScopeService,
                 _applicationModelBuilder_: ApplicationModelBuilder,
                 _MultiselectModel_: any) => {
      service = instanceWriter;
      taskExecutor = _taskExecutor_;
      serverGroupReader = _serverGroupReader_;
      $q = _$q_;
      $scope = $rootScope.$new();
      applicationModelBuilder = _applicationModelBuilder_;
      MultiselectModel = _MultiselectModel_;
    })
  );

  describe('terminate and decrement server group', () => {

    it('should set setMaxToNewDesired flag based on current server group capacity', function () {
      const serverGroup = {
        asg: {
          minSize: 4,
          maxSize: 4
        }
      };
      const instance: IInstance = {
        id: 'i-123456',
        account: 'test',
        region: 'us-east-1',
        serverGroup: 'asg-1',
        health: [],
        healthState: 'Up',
        zone: 'a',
        launchTime: 2,

      };
      const application: Application = applicationModelBuilder.createApplication('app', { key: 'serverGroups', lazy: true });
      let executedTask: IJob = null;

      spyOn(taskExecutor, 'executeTask').and.callFake((task: ITaskCommand) => {
        executedTask = task.job[0];
      });
      spyOn(serverGroupReader, 'getServerGroup').and.returnValue($q.when(serverGroup));


      service.terminateInstanceAndShrinkServerGroup(instance, application, {});
      $scope.$digest();
      $scope.$digest();

      expect(taskExecutor.executeTask).toHaveBeenCalled();
      expect(executedTask['setMaxToNewDesired']).toBe(true);
    });

  });

  describe('multi-instance operations', () => {

    let task: ITaskCommand,
        serverGroupA: IServerGroup,
        serverGroupB: IServerGroup;

    function getInstanceGroup(serverGroup: IServerGroup): IMultiInstanceGroup {
      return MultiselectModel.getOrCreateInstanceGroup(serverGroup);
    }

    function addInstance(serverGroup: IServerGroup, instance: IInstance) {
      const instanceGroup: IMultiInstanceGroup = getInstanceGroup(serverGroup);
      instanceGroup.instanceIds.push(instance.id);
      instanceGroup.instances.push(instance);
    }

    beforeEach(function () {
      task = null;
      serverGroupA = { type: 'aws', cloudProvider: 'aws', name: 'asg-v001', account: 'prod', region: 'us-east-1', cluster: 'asg', instanceCounts: null, instances: [] };
      serverGroupB = { type: 'gce', cloudProvider: 'gce', name: 'asg-v002', account: 'test', region: 'us-west-1', cluster: 'asg', instanceCounts: null, instances: [] };

      spyOn(taskExecutor, 'executeTask').and.callFake((command: ITaskCommand) => task = command);
    });

    it('only sends jobs for groups with instances', () => {
      const application: Application = applicationModelBuilder.createApplication('app');
//.........這裏部分代碼省略.........
開發者ID:robfletcher,項目名稱:deck,代碼行數:101,代碼來源:instance.write.service.spec.ts

示例2: it

    it('includes a useful descriptor on enable in discovery', function() {
      const application: Application = ApplicationModelBuilder.createApplicationForTests('app');
      addInstance(serverGroupA, {
        name: 'i-123',
        id: 'i-123',
        health: [],
        healthState: 'Up',
        zone: 'a',
        launchTime: 2,
      });

      service.enableInstancesInDiscovery([getInstanceGroup(serverGroupA)], application);
      expect(task.description).toBe('Enable 1 instance in discovery');

      addInstance(serverGroupA, {
        name: 'i-1234',
        id: 'i-1234',
        health: [],
        healthState: 'Up',
        zone: 'a',
        launchTime: 1,
      });
      service.enableInstancesInDiscovery([getInstanceGroup(serverGroupA)], application);
      expect(task.description).toBe('Enable 2 instances in discovery');
    });
開發者ID:emjburns,項目名稱:deck,代碼行數:25,代碼來源:instance.write.service.spec.ts

示例3: it

    it('includes a useful descriptor on terminate instances', () => {
      const application: Application = applicationModelBuilder.createApplication('app');
      addInstance(serverGroupA, {
        name: 'i-123',
        id: 'i-123',
        health: [],
        healthState: 'Up',
        zone: 'a',
        launchTime: 2,
      });

      service.terminateInstances([getInstanceGroup(serverGroupA)], application);
      expect(task.description).toBe('Terminate 1 instance');

      addInstance(serverGroupA, {
        name: 'i-1234',
        id: 'i-1234',
        health: [],
        healthState: 'Up',
        zone: 'a',
        launchTime: 1,
      });
      service.terminateInstances([getInstanceGroup(serverGroupA)], application);
      expect(task.description).toBe('Terminate 2 instances');
    });
開發者ID:mizzy,項目名稱:deck,代碼行數:25,代碼來源:instance.write.service.spec.ts

示例4: it

    it('includes a useful descriptor on disable in discovery', function () {
      let application: Application = applicationModelBuilder.createApplication();
      addInstance(serverGroupA, {id: 'i-123', health: [], healthState: 'Up', zone: 'a', launchTime: 2});

      service.disableInstancesInDiscovery([getInstanceGroup(serverGroupA)], application);
      expect(task.description).toBe('Disable 1 instance in discovery');

      addInstance(serverGroupA, {id: 'i-1234', health: [], healthState: 'Up', zone: 'a', launchTime: 1});
      service.disableInstancesInDiscovery([getInstanceGroup(serverGroupA)], application);
      expect(task.description).toBe('Disable 2 instances in discovery');
    });
開發者ID:jtk54,項目名稱:deck,代碼行數:11,代碼來源:instance.write.service.spec.ts

示例5: it

    it('should set setMaxToNewDesired flag based on current server group capacity', function () {
      const serverGroup = {
        asg: {
          minSize: 4,
          maxSize: 4
        }
      };
      const instance: IInstance = {
        id: 'i-123456',
        account: 'test',
        region: 'us-east-1',
        serverGroup: 'asg-1',
        health: [],
        healthState: 'Up',
        zone: 'a',
        launchTime: 2,

      };
      const application: Application = applicationModelBuilder.createApplication('app', { key: 'serverGroups', lazy: true });
      let executedTask: IJob = null;

      spyOn(taskExecutor, 'executeTask').and.callFake((task: ITaskCommand) => {
        executedTask = task.job[0];
      });
      spyOn(serverGroupReader, 'getServerGroup').and.returnValue($q.when(serverGroup));


      service.terminateInstanceAndShrinkServerGroup(instance, application, {});
      $scope.$digest();
      $scope.$digest();

      expect(taskExecutor.executeTask).toHaveBeenCalled();
      expect(executedTask['setMaxToNewDesired']).toBe(true);
    });
開發者ID:robfletcher,項目名稱:deck,代碼行數:34,代碼來源:instance.write.service.spec.ts


注:本文中的core/instance/instance.write.service.InstanceWriter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。