Merge remote-tracking branch 'eclipse/master' into feature_MECS-86_tenant_specific_polling_configuration
# Conflicts: # hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/Tena ntConfigurationDashboardView.java
This commit is contained in:
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit;
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
@@ -31,6 +30,7 @@ import org.eclipse.hawkbit.repository.LocalArtifactRepository;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupRepository;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.RolloutRepository;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataRepository;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleRepository;
|
||||
@@ -195,6 +195,9 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
|
||||
@Autowired
|
||||
protected RolloutGroupRepository rolloutGroupRepository;
|
||||
|
||||
@Autowired
|
||||
protected RolloutRepository rolloutRepository;
|
||||
|
||||
protected MockMvc mvc;
|
||||
|
||||
@Autowired
|
||||
@@ -213,23 +216,6 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
|
||||
|
||||
private static CIMySqlTestDatabase tesdatabase;
|
||||
|
||||
static {
|
||||
final Properties props = System.getProperties();
|
||||
|
||||
// if( props.getProperty( SuiteEmbeddedConfiguration.IM_HOME ) == null )
|
||||
// {
|
||||
// props.setProperty( SuiteEmbeddedConfiguration.IM_HOME,
|
||||
// "./src/test/resources/im" );
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.context.EnvironmentAware#setEnvironment(org.
|
||||
* springframework.core.env. Environment)
|
||||
*/
|
||||
@Override
|
||||
public void setEnvironment(final Environment environment) {
|
||||
this.environment = environment;
|
||||
@@ -292,6 +278,8 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
|
||||
assertThat(softwareModuleTypeRepository.findAll()).isEmpty();
|
||||
assertThat(distributionSetTypeRepository.findAll()).isEmpty();
|
||||
assertThat(tenantMetaDataRepository.findAll()).isEmpty();
|
||||
assertThat(rolloutGroupRepository.findAll()).isEmpty();
|
||||
assertThat(rolloutRepository.findAll()).isEmpty();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -312,7 +311,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
deploymentManagement.cancelAction(assigningAction, target);
|
||||
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
|
||||
|
||||
deploymentManagement.forceQuitAction(assigningAction, target);
|
||||
deploymentManagement.forceQuitAction(assigningAction);
|
||||
|
||||
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
|
||||
|
||||
@@ -350,8 +349,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
// force quit assignment
|
||||
try {
|
||||
deploymentManagement.forceQuitAction(assigningAction,
|
||||
targetManagement.findTargetByControllerID(target.getControllerId()));
|
||||
deploymentManagement.forceQuitAction(assigningAction);
|
||||
fail("expected ForceQuitActionNotAllowedException");
|
||||
} catch (final ForceQuitActionNotAllowedException ex) {
|
||||
}
|
||||
@@ -764,13 +762,16 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
|
||||
|
||||
// verifying that the assignment is correct
|
||||
assertEquals("Active target actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals("Target actions are wrong", 1, deploymentManagement.findActionsByTarget(targ).size());
|
||||
assertEquals("Target status is wrong", TargetUpdateStatus.PENDING, targ.getTargetInfo().getUpdateStatus());
|
||||
assertEquals("Assigned ds is wrong", dsA, targ.getAssignedDistributionSet());
|
||||
assertEquals("Active ds is wrong", dsA,
|
||||
deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
|
||||
assertNull("Installed ds should be null", targ.getTargetInfo().getInstalledDistributionSet());
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ).size()).as("Active target actions are wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(deploymentManagement.findActionsByTarget(targ).size()).as("Target actions are wrong").isEqualTo(1);
|
||||
assertThat(targ.getTargetInfo().getUpdateStatus()).as("UpdateStatus of target is wrong")
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targ.getAssignedDistributionSet()).as("Assigned distribution set of target is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet())
|
||||
.as("Distribution set of actionn is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet())
|
||||
.as("Installed distribution set of action should be null").isNotNull();
|
||||
|
||||
final Page<Action> updAct = actionRepository.findByDistributionSet(pageReq, dsA);
|
||||
final Action action = updAct.getContent().get(0);
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||
import org.eclipse.hawkbit.TestDataUtil;
|
||||
@@ -34,6 +35,8 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.utils.MultipleInvokeHelper;
|
||||
import org.eclipse.hawkbit.repository.utils.SuccessCondition;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Description;
|
||||
@@ -859,7 +862,7 @@ public class RolloutManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verify the creation and the start of a rollout in asynchronous mode.")
|
||||
public void createAndStartRolloutInAsync() {
|
||||
public void createAndStartRolloutInAsync() throws Exception {
|
||||
|
||||
final int amountTargetsForRollout = 500;
|
||||
final int amountGroups = 5;
|
||||
@@ -883,31 +886,18 @@ public class RolloutManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
myRollout = rolloutManagement.createRolloutAsync(myRollout, amountGroups, conditions);
|
||||
|
||||
int counter = 1;
|
||||
int counterMax = 10;
|
||||
while (!isRolloutInGivenStatus(myRollout.getId(), RolloutStatus.READY) && (counter <= counterMax)) {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
SuccessConditionRolloutStatus conditionRolloutTargetCount = new SuccessConditionRolloutStatus(
|
||||
RolloutStatus.READY);
|
||||
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
|
||||
conditionRolloutTargetCount, 15000, 500)).as("Rollout status").isNotNull();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId());
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
rolloutManagement.startRolloutAsync(myRollout);
|
||||
|
||||
counter = 1;
|
||||
counterMax = 10;
|
||||
while (!isRolloutInGivenStatus(myRollout.getId(), RolloutStatus.RUNNING) && counter <= counterMax) {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
conditionRolloutTargetCount = new SuccessConditionRolloutStatus(RolloutStatus.RUNNING);
|
||||
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
|
||||
conditionRolloutTargetCount, 15000, 500)).as("Rollout status").isNotNull();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId());
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
@@ -917,14 +907,6 @@ public class RolloutManagementTest extends AbstractIntegrationTest {
|
||||
validateRolloutActionStatus(myRollout.getId(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
private boolean isRolloutInGivenStatus(final Long rolloutID, final RolloutStatus status) {
|
||||
final Rollout myRollout = rolloutManagement.findRolloutById(rolloutID);
|
||||
if (myRollout.getStatus() == status) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void validateRolloutGroupActionStatus(final RolloutGroup rolloutGroup,
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus) {
|
||||
final RolloutGroup rolloutGroupWithDetail = rolloutGroupManagement
|
||||
@@ -1021,4 +1003,35 @@ public class RolloutManagementTest extends AbstractIntegrationTest {
|
||||
return map;
|
||||
}
|
||||
|
||||
private static class SuccessConditionRolloutStatus implements SuccessCondition<RolloutStatus> {
|
||||
|
||||
private final RolloutStatus rolloutStatus;
|
||||
|
||||
public SuccessConditionRolloutStatus(final RolloutStatus rolloutStatus) {
|
||||
this.rolloutStatus = rolloutStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean success(final RolloutStatus result) {
|
||||
return result.equals(rolloutStatus);
|
||||
}
|
||||
}
|
||||
|
||||
private class RolloutStatusCallable implements Callable<RolloutStatus> {
|
||||
|
||||
final Long rolloutId;
|
||||
|
||||
RolloutStatusCallable(final Long rolloutId) {
|
||||
this.rolloutId = rolloutId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RolloutStatus call() throws Exception {
|
||||
|
||||
final Rollout myRollout = rolloutManagement.findRolloutById(rolloutId);
|
||||
return myRollout.getStatus();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractIntegrationTest {
|
||||
@Test
|
||||
@Description("Test filter software module test type by max")
|
||||
public void testFilterByMaxAssignment() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.MAX.name() + "==1", 3);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "==1", 3);
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.utils;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Helper to call a request multiple times regarding a given condition until
|
||||
* timeout is reached.
|
||||
*
|
||||
*/
|
||||
public final class MultipleInvokeHelper {
|
||||
|
||||
/**
|
||||
* Call with timeout until result is not null.
|
||||
*
|
||||
* @param callable
|
||||
* class
|
||||
* @param timeout
|
||||
* value
|
||||
* @param pollInterval
|
||||
* value
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static <T> T doWithTimeoutUntilResultIsNotNull(final Callable<T> callable, final long timeout,
|
||||
final long pollInterval) throws Exception // NOPMD
|
||||
{
|
||||
return doWithTimeout(callable, new SuccessCondition<T>() {
|
||||
@Override
|
||||
public boolean success(final T result) {
|
||||
return result != null;
|
||||
};
|
||||
}, timeout, pollInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call with timeout.
|
||||
*
|
||||
* @param callable
|
||||
* class
|
||||
* @param successCondition
|
||||
* class
|
||||
* @param timeout
|
||||
* value
|
||||
* @param pollInterval
|
||||
* value
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static <T> T doWithTimeout(final Callable<T> callable, final SuccessCondition<T> successCondition,
|
||||
final long timeout, final long pollInterval) throws Exception // NOPMD
|
||||
{
|
||||
|
||||
if (pollInterval < 0) {
|
||||
throw new IllegalArgumentException("pollInterval must non negative");
|
||||
}
|
||||
|
||||
long duration = 0;
|
||||
Exception exception = null;
|
||||
T returnValue = null;
|
||||
while (untilTimeoutReached(timeout, duration)) {
|
||||
try {
|
||||
returnValue = callable.call();
|
||||
// clear exception
|
||||
exception = null;
|
||||
} catch (final Exception ex) {
|
||||
exception = ex;
|
||||
}
|
||||
Thread.sleep(pollInterval);
|
||||
duration += pollInterval > 0 ? pollInterval : 1;
|
||||
if (exception == null && successCondition.success(returnValue)) {
|
||||
return returnValue;
|
||||
} else {
|
||||
returnValue = null;
|
||||
}
|
||||
}
|
||||
if (exception != null) {
|
||||
throw exception;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
private static boolean untilTimeoutReached(final long timeout, final long duration) {
|
||||
return duration <= timeout || timeout < 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.utils;
|
||||
|
||||
/**
|
||||
* SuccessCondition Interface.
|
||||
*
|
||||
* @param <T>
|
||||
* type of the value to get verified
|
||||
*/
|
||||
public interface SuccessCondition<T> {
|
||||
|
||||
/**
|
||||
* The implementation of the success condition.
|
||||
*
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
boolean success(final T result);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user