@Test
  public void testScheduleDag100() {
    HashSet<VM> vms = new HashSet<VM>();
    for (int i = 0; i < 10; i++) {
      VMStaticParams vmStaticParams = VMStaticParams.getDefaults();

      VM vm = new VM(vmStaticParams, cloudsim);
      vms.add(vm);
      cloudsim.send(engine.getId(), cloud.getId(), 0.0, WorkflowEvent.VM_LAUNCH, vm);
    }

    DAG dag = DAGParser.parseDAG(new File("dags/CyberShake_100.dag"));

    List<DAG> dags = new ArrayList<DAG>();
    dags.add(dag);

    // FIXME (_mequrel): looks awkward, a comment should be added or some logic inversed
    new EnsembleManager(dags, engine, cloudsim);

    cloudsim.startSimulation();

    assertEquals(vms.size(), engine.getAvailableVMs().size());
    assertEquals(0, engine.getQueuedJobs().size());

    jobLog.printJobs("testEnsembleDynamicSchedulerDag_CyberShake_100");
  }
  @Test
  public void testScheduleDag() {
    HashSet<VM> vms = new HashSet<VM>();
    for (int i = 0; i < 10; i++) {
      VMStaticParams vmStaticParams = VMStaticParams.getDefaults();

      VM vm = new VM(vmStaticParams, cloudsim);
      vms.add(vm);
      cloudsim.send(engine.getId(), cloud.getId(), 0.0, WorkflowEvent.VM_LAUNCH, vm);
    }

    DAG dag = new DAG();
    for (int i = 0; i < 100; i++) {
      Task task = new Task("TASK" + i, "transformation", (i % 10), VMType.DEFAULT_VM_TYPE);
      dag.addTask(task);
    }

    List<DAG> dags = new ArrayList<DAG>();
    dags.add(dag);

    // FIXME (_mequrel): looks awkward, a comment should be added or some logic inversed
    new EnsembleManager(dags, engine, cloudsim);

    cloudsim.startSimulation();

    assertEquals(vms.size(), engine.getAvailableVMs().size());
    assertEquals(0, engine.getQueuedJobs().size());

    jobLog.printJobs("testEnsembleDynamicSchedulerDag");
  }
  @Test
  public void testScheduleVMS() {
    HashSet<VM> vms = new HashSet<VM>();
    for (int i = 0; i < 10; i++) {
      VMStaticParams vmStaticParams = VMStaticParams.getDefaults();

      VM vm = new VM(vmStaticParams, cloudsim);
      vm.setProvisioningDelay(0.0);
      vm.setDeprovisioningDelay(0.0);
      vms.add(vm);
      cloudsim.send(engine.getId(), cloud.getId(), 0.1, WorkflowEvent.VM_LAUNCH, vm);
    }

    cloudsim.startSimulation();

    assertEquals(vms.size(), engine.getAvailableVMs().size());
  }
 public EnsembleManager(Collection<DAG> dags, WorkflowEngine engine, CloudSimWrapper cloudsim) {
   super("EnsembleManager", cloudsim);
   this.engine = engine;
   this.dags = new LinkedList<DAGJob>();
   this.listeners = new LinkedList<DAGJobListener>();
   prioritizeDAGs(dags);
   cloudsim.addEntity(this);
 }
  @Before
  public void setUpVMCacheTest() {
    cloudsim = Mockito.spy(new CloudSimWrapper());
    cloudsim.init();

    job = Mockito.mock(Job.class);
    vm = Mockito.mock(VM.class);
    Mockito.when(vm.getId()).thenReturn(100);
    job.setVM(vm);
    Mockito.when(job.getVM()).thenReturn(vm);
    task = Mockito.mock(Task.class);
    Mockito.when(job.getTask()).thenReturn(task);
  }
  @Before
  public void setUp() {
    // TODO(_mequrel_): change to IoC in the future or to mock
    cloudsim = new CloudSimWrapper();
    cloudsim.init();

    storageManager = new VoidStorageManager(cloudsim);
    provisioner = null;
    scheduler = new EnsembleDynamicScheduler(cloudsim);
    engine = new WorkflowEngine(new SimpleJobFactory(1000), provisioner, scheduler, cloudsim);
    cloud = new Cloud(cloudsim);

    jobLog = new WorkflowLog(cloudsim);
    engine.addJobListener(jobLog);
  }
  @Test
  public void testSimpleTransfer24() {
    Random rng = new Random(7);

    TransferDriver td = new TransferDriver(cloudsim);

    Port a = new Port(1000);
    Port[] b = new Port[4];
    for (int i = 0; i < 4; i++) {
      b[i] = new Port(1000);
    }
    Link l = new Link(1000, 1000.0);
    List<Transfer> transfers = new ArrayList<Transfer>();

    for (int i = 0; i < 24; i++) {
      Transfer t1 =
          new Transfer(a, b[i % 4], l, (int) (100 * rng.nextDouble()) * MB, td.getId(), cloudsim);
      transfers.add(t1);
    }

    td.setTransfers(transfers);

    cloudsim.startSimulation();
  }
 @Before
 public void setUp() {
   // TODO(_mequrel_): change to IoC in the future or to mock
   cloudsim = new CloudSimWrapper();
   cloudsim.init();
 }