Search in sources :

Example 21 with ExecutionWindow

use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.

the class ExecutionWindowTest method testMultiTenant.

@Test
public void testMultiTenant() throws Exception {
    _logger.info("Starting multi tenant ExecutionWindow test");
    ModelClient modelClient = getModelClient();
    ExecutionWindow ew1 = create("t1", "foo1");
    modelClient.save(ew1);
    ExecutionWindow ew2 = create("t1", "bar2");
    modelClient.save(ew2);
    ExecutionWindow ew3 = create("t2", "foo3");
    modelClient.save(ew3);
    ExecutionWindow ew4 = create("t2", "bar4");
    modelClient.save(ew4);
    ExecutionWindow ew5 = create("t2", "foo5");
    modelClient.save(ew5);
    ExecutionWindow ew6 = create("t3", "bar6");
    modelClient.save(ew6);
    List<ExecutionWindow> executionWindows = modelClient.executionWindows().findAll("t1");
    Assert.assertNotNull(executionWindows);
    Assert.assertEquals(2, executionWindows.size());
    executionWindows = modelClient.executionWindows().findAll("t2");
    Assert.assertNotNull(executionWindows);
    Assert.assertEquals(3, executionWindows.size());
    executionWindows = modelClient.executionWindows().findAll("t3");
    Assert.assertNotNull(executionWindows);
    Assert.assertEquals(1, executionWindows.size());
}
Also used : ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) ModelClient(com.emc.sa.model.dao.ModelClient) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 22 with ExecutionWindow

use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.

the class ExecutionWindowHelperTest method testDailySpanningMidnight.

@Test
public void testDailySpanningMidnight() {
    // Daily at 11:30pm
    ExecutionWindow window = createDailyWindow(23, 30);
    setLengthInHours(window, 1);
    ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
    Calendar beforeTime = getDateTimeUTC(2013, Calendar.MAY, 6, 23, 0, 0);
    assertDateTime(helper.calculateNext(beforeTime), 2013, Calendar.MAY, 6, 23, 30, 0);
    assertDateTime(helper.calculateCurrentOrNext(beforeTime), 2013, Calendar.MAY, 6, 23, 30, 0);
    Calendar duringTime = getDateTimeUTC(2013, Calendar.MAY, 6, 23, 45, 0);
    assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 7, 23, 30, 0);
    assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 6, 23, 30, 0);
    duringTime = getDateTimeUTC(2013, Calendar.MAY, 7, 0, 15, 0);
    assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 7, 23, 30, 0);
    assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 6, 23, 30, 0);
    Calendar afterTime = getDateTimeUTC(2013, Calendar.MAY, 7, 1, 0, 0);
    assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 7, 23, 30, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 7, 23, 30, 0);
}
Also used : ExecutionWindowHelper(com.emc.storageos.db.client.util.ExecutionWindowHelper) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 23 with ExecutionWindow

use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.

the class ExecutionWindowHelperTest method testWeeklyAfterTime.

@Test
public void testWeeklyAfterTime() {
    // Weekly on Sunday at 1:15am
    ExecutionWindow window = createWeeklyWindow(Calendar.SUNDAY, 1, 15);
    setLengthInHours(window, 1);
    ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
    Calendar afterTime = getDateTimeUTC(2013, Calendar.MAY, 5, 3, 15, 0);
    assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    afterTime = getDateTimeUTC(2013, Calendar.MAY, 6, 1, 10, 0);
    assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    afterTime = getDateTimeUTC(2013, Calendar.MAY, 7, 1, 10, 0);
    assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    afterTime = getDateTimeUTC(2013, Calendar.MAY, 8, 1, 10, 0);
    assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    afterTime = getDateTimeUTC(2013, Calendar.MAY, 9, 1, 10, 0);
    assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
}
Also used : ExecutionWindowHelper(com.emc.storageos.db.client.util.ExecutionWindowHelper) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 24 with ExecutionWindow

use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.

the class ExecutionWindowHelperTest method testDailyWindowAfterTime.

@Test
public void testDailyWindowAfterTime() {
    // Daily at 1:15am
    ExecutionWindow window = createDailyWindow(1, 15);
    setLengthInHours(window, 1);
    ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
    // Right after the window ends
    Calendar afterTime = getDateTimeUTC(2000, Calendar.FEBRUARY, 5, 2, 16, 0);
    assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
    // Should be the next day
    afterTime = getDateTimeUTC(2000, Calendar.FEBRUARY, 5, 10, 16, 0);
    assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
    // Last day of the month, check for rollover
    afterTime = getDateTimeUTC(2000, Calendar.JANUARY, 31, 5, 0, 0);
    assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 1, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 1, 1, 15, 0);
    // Last day of the year, check for rollover
    afterTime = getDateTimeUTC(2000, Calendar.DECEMBER, 31, 5, 0, 0);
    assertDateTime(helper.calculateNext(afterTime), 2001, Calendar.JANUARY, 1, 1, 15, 0);
    assertDateTime(helper.calculateCurrentOrNext(afterTime), 2001, Calendar.JANUARY, 1, 1, 15, 0);
}
Also used : ExecutionWindowHelper(com.emc.storageos.db.client.util.ExecutionWindowHelper) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 25 with ExecutionWindow

use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.

the class ExecutionWindowHelperTest method testDailyWindowDuringTime.

@Test
public void testDailyWindowDuringTime() {
    // Daily at 1:15am
    ExecutionWindow window = createDailyWindow(1, 15);
    setLengthInHours(window, 1);
    ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
    // Right at the start of the window
    Calendar duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 1, 15, 0);
    // Next will be the day after
    assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
    // Current or next will be today
    assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
    Assert.assertTrue(helper.isActive(duringTime));
    // One minute after the start of the window
    duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 1, 16, 0);
    // Next will be the day after
    assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
    // Current or next will be today
    assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
    Assert.assertTrue(helper.isActive(duringTime));
    // One minute before the end of the window
    duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 2, 14, 0);
    // Next will be the day after
    assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
    // Current or next will be today
    assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
    Assert.assertTrue(helper.isActive(duringTime));
    // Right at the end of the window
    duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 2, 15, 0);
    // Next will be the day after
    assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
    // Current or next will be tomorrow
    assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
    Assert.assertFalse(helper.isActive(duringTime));
}
Also used : ExecutionWindowHelper(com.emc.storageos.db.client.util.ExecutionWindowHelper) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) Calendar(java.util.Calendar) Test(org.junit.Test)

Aggregations

ExecutionWindow (com.emc.storageos.db.client.model.uimodels.ExecutionWindow)25 ExecutionWindowHelper (com.emc.storageos.db.client.util.ExecutionWindowHelper)11 Test (org.junit.Test)11 Calendar (java.util.Calendar)10 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 BaseModelTest (com.emc.sa.model.BaseModelTest)2 Order (com.emc.storageos.db.client.model.uimodels.Order)2 URI (java.net.URI)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 ModelClient (com.emc.sa.model.dao.ModelClient)1 DbClient (com.emc.storageos.db.client.DbClient)1 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 ScheduledEvent (com.emc.storageos.db.client.model.uimodels.ScheduledEvent)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1