Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unlimited collections from the repository API #496

Merged
merged 36 commits into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0dde869
Started to get rid of unlimited collections
kaizimmerm Mar 31, 2017
d689140
Align API usage.
kaizimmerm Apr 3, 2017
6e7d12a
Merge branch 'master' of local repository into fix_memory_repo
kaizimmerm Apr 3, 2017
943d8be
fix compile issues.
kaizimmerm Apr 3, 2017
fb8f4a9
Fix tests.
kaizimmerm Apr 3, 2017
2824981
Remove comments
kaizimmerm Apr 3, 2017
fb807c2
Performance optimizations.
kaizimmerm Apr 3, 2017
c725279
Remove dead code.
kaizimmerm Apr 3, 2017
88201e7
Merge branch 'master' into fix_memory_repo
kaizimmerm Apr 13, 2017
d9e63ba
Merge branch 'master' into fix_memory_repo
kaizimmerm Apr 18, 2017
7846baf
Allign method names
kaizimmerm Apr 18, 2017
f3c3d0a
Wait until the action update event is processed
MelleD Apr 18, 2017
d003910
Started new tag APIs
kaizimmerm Apr 19, 2017
bdb5b0a
Merge branch 'master' into fix_memory_repo
kaizimmerm Apr 24, 2017
9739106
Quotas into central interface. Tag tests added. Event names fixed.
kaizimmerm Apr 25, 2017
5455c3a
Simplified consumer run for every tenant.
kaizimmerm Apr 25, 2017
709b4aa
remove unused fields.
kaizimmerm Apr 25, 2017
c41640d
Alligned beans.
kaizimmerm Apr 25, 2017
7c1d89f
Deprecated client methods for old resources.
kaizimmerm Apr 25, 2017
34f0bef
Fix new foreach method.
kaizimmerm Apr 25, 2017
99cae2f
Fix transaction for foreach.
kaizimmerm Apr 25, 2017
4310145
Extended DS creating to handle larger volumes. Fix on Readme.
kaizimmerm Apr 25, 2017
eed965e
Fixed simulator bug and cleaned up tests.
kaizimmerm Apr 26, 2017
058a725
Merge branch 'master' into fix_memory_repo
kaizimmerm Apr 27, 2017
c4c0126
Merge branch 'master' into fix_memory_repo
kaizimmerm Apr 27, 2017
0088564
Fix in sorting.
kaizimmerm Apr 28, 2017
fe2770f
Remove configuration processor.
kaizimmerm Apr 28, 2017
38536d4
Fix wrong usage of sanitize.
kaizimmerm Apr 28, 2017
23e2bfc
Missing brackets.
kaizimmerm Apr 28, 2017
1b610ec
Fix README API compatability.
kaizimmerm Apr 28, 2017
972f1d2
Merge branch 'master' into fix_memory_repo
kaizimmerm May 3, 2017
22a66ab
Fix misinterpretation of pessimistic locking exceptions.
kaizimmerm May 4, 2017
693eede
Fix stability sentence.
kaizimmerm May 4, 2017
5f4be69
Merge branch 'master' into fix_memory_repo
kaizimmerm May 6, 2017
53ded7f
Code cleanup.
kaizimmerm May 6, 2017
e513fdd
Fixed page calculation
kaizimmerm May 9, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,7 @@ $ java -jar ./examples/hawkbit-example-mgmt-simulator/target/hawkbit-example-mgm

hawkBit is currently in '0.X' semantic version. That is due to the need that there is still content in hawkBit that is in need for refactoring. That includes the maven module structure, Spring Boot Properties, Spring Boot auto configuration as well as internal Java APIs (e.g. the [repository API](https://github.com/eclipse/hawkbit/issues/197) ).

However, the external APIs (i.e. [Management API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-mgmt-api), [DDI API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-ddi-api), [DDI Artifact Download API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-ddi-dl-api) and [DMF API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-dmf/hawkbit-dmf-api) are on major version 'v1' and will be kept stable.
However, the device facing [DDI API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-ddi-api) is on major version 'v1' and will be kept stable.

Server facing and [DMF API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-dmf/hawkbit-dmf-api) are [Management API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-mgmt-api) are on v1 as well. However, we cannot fully guarantee the same stability during hawkBit's 0.X development but we will try as best we can.

6 changes: 4 additions & 2 deletions examples/hawkbit-device-simulator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ This can be configured/disabled by spring boot properties
## hawkBit APIs

The simulator supports `DDI` as well as the `DMF` integration APIs.
In case there is no AMQP message broker (like rabbitMQ) running, you can disable the AMQP support for the device simulator, so the simulator is not trying to connect to an amqp message broker.
Configuration property `hawkbit.device.simulator.amqp.enabled=true`

In case there is no AMQP message broker (like rabbitMQ) running, you can disable the AMQP support for the device simulator, so the simulator is not trying to connect to an amqp message broker.

Configuration property `hawkbit.device.simulator.amqp.enabled=false`

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.mgmt.client.scenarios;

import java.math.BigDecimal;
import java.security.SecureRandom;
import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -316,31 +317,38 @@ private void waitUntilRolloutIsReady(final Long id) {

private void createDistributionSets(final Scenario scenario) {
LOGGER.info("Creating {} distribution sets", scenario.getDistributionSets());
final BigDecimal pages = new BigDecimal(scenario.getDistributionSets())
.divide(new BigDecimal(PAGE_SIZE), BigDecimal.ROUND_UP).max(new BigDecimal(1));

IntStream.range(0, pages.intValue()).parallel().forEach(i -> createDistributionSetPage(scenario, i));
LOGGER.info("Creating {} distribution sets -> Done", scenario.getDistributionSets());
}

private void createDistributionSetPage(final Scenario scenario, final int page) {

final List<MgmtDistributionSet> sets = distributionSetResource
.createDistributionSets(new DistributionSetBuilder().name(scenario.getDsName()).type("os_app")
.version("1.0.").buildAsList(scenario.getDistributionSets()))
.version("1.0.").buildAsList(calculateOffset(page),
(page + 1) * PAGE_SIZE > scenario.getDistributionSets()
? (scenario.getDistributionSets() - calculateOffset(page)) : PAGE_SIZE))
.getBody();

assignSoftwareModulesTo(scenario, sets);

tagDistributionSets(scenario, sets);
tagDistributionSets(page, sets);

LOGGER.info("Creating {} distribution sets -> Done", scenario.getDistributionSets());
}

private void tagDistributionSets(final Scenario scenario, final List<MgmtDistributionSet> sets) {
for (int i = 0; i < scenario.getDsTags(); i++) {
final MgmtTag tag = distributionSetTagResource
.createDistributionSetTags(
new TagBuilder().name("DS Tag" + i).description("DS tag for DS " + i).build())
.getBody().get(0);
private void tagDistributionSets(final int page, final List<MgmtDistributionSet> sets) {
final MgmtTag tag = distributionSetTagResource
.createDistributionSetTags(
new TagBuilder().name("Page " + page).description("DS tag for DS page" + page).build())
.getBody().get(0);

distributionSetTagResource.assignDistributionSets(tag.getTagId(),
sets.stream().map(
set -> new MgmtAssignedDistributionSetRequestBody().setDistributionSetId(set.getDsId()))
.collect(Collectors.toList()));
}
distributionSetTagResource.assignDistributionSets(tag.getTagId(),
sets.stream()
.map(set -> new MgmtAssignedDistributionSetRequestBody().setDistributionSetId(set.getDsId()))
.collect(Collectors.toList()));
}

private void assignSoftwareModulesTo(final Scenario scenario, final List<MgmtDistributionSet> sets) {
Expand Down Expand Up @@ -379,8 +387,10 @@ private List<MgmtSoftwareModule> addModules(final Scenario scenario, final MgmtD

private void createTargets(final Scenario scenario, final List<Long> deviceGroupTags) {
LOGGER.info("Creating {} targets", scenario.getTargets());
IntStream.range(0, scenario.getTargets() / PAGE_SIZE).parallel()
.forEach(i -> createTargetPage(scenario, i, deviceGroupTags));
final BigDecimal pages = new BigDecimal(scenario.getTargets())
.divide(new BigDecimal(PAGE_SIZE), BigDecimal.ROUND_UP).max(new BigDecimal(1));

IntStream.range(0, pages.intValue()).parallel().forEach(i -> createTargetPage(scenario, i, deviceGroupTags));
LOGGER.info("Creating {} targets -> Done", scenario.getTargets());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
*
*/
public enum TagFields implements FieldNameProvider {
/**
* The id field.
*/
ID("id"),

/**
* The name field.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public enum TargetFilterQueryFields implements FieldNameProvider {
*/
AUTOASSIGNDISTRIBUTIONSET("autoAssignDistributionSet", "name", "version");


private final String fieldName;
private List<String> subEntityAttributes;
private boolean mapField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void invalidRequestsOnArtifactResource() throws Exception {
public void downloadArtifactThroughFileName() throws Exception {
downLoadProgress = 1;
shippedBytes = 0;
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(0);

// create target
final Target target = testdataFactory.createTarget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,14 @@ public void rootRsCancelAction() throws Exception {
// Retrieved is reported

List<Action> activeActionsByTarget = deploymentManagement
.findActiveActionsByTarget(savedTarget.getControllerId());
.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent();

assertThat(activeActionsByTarget).hasSize(1);
assertThat(activeActionsByTarget.get(0).getStatus()).isEqualTo(Status.RUNNING);
final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId());

activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId());
activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
.getContent();

// the canceled action should still be active!
assertThat(cancelAction.isActive()).isTrue();
Expand Down Expand Up @@ -174,7 +175,8 @@ public void rootRsCancelAction() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());

activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId());
activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
.getContent();
assertThat(activeActionsByTarget).hasSize(0);
final Action canceledAction = deploymentManagement.findAction(cancelAction.getId()).get();
assertThat(canceledAction.isActive()).isFalse();
Expand Down Expand Up @@ -241,22 +243,22 @@ public void rootRsCancelActionFeedback() throws Exception {
final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId());
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);

assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
.content(JsonBuilder.cancelActionFeedback(cancelAction.getId().toString(), "proceeding"))
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());

assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(3);

mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
.content(JsonBuilder.cancelActionFeedback(cancelAction.getId().toString(), "resumed"))
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(4);

mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
Expand All @@ -265,30 +267,30 @@ public void rootRsCancelActionFeedback() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(5);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);

// cancellation canceled -> should remove the action from active
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
.content(JsonBuilder.cancelActionFeedback(cancelAction.getId().toString(), "canceled"))
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(6);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);

// cancellation rejected -> action still active until controller close
// it
// with finished or
// error
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
.content(JsonBuilder.cancelActionFeedback(cancelAction.getId().toString(), "rejected"))
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(7);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);

// update closed -> should remove the action from active
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/"
Expand All @@ -297,7 +299,7 @@ public void rootRsCancelActionFeedback() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(8);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(0);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(0);
}

@Test
Expand Down Expand Up @@ -325,12 +327,12 @@ public void multipleCancelActionFeedback() throws Exception {
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(3);

// 3 update actions, 0 cancel actions
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(3);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(3);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3);
final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId());
final Action cancelAction2 = deploymentManagement.cancelAction(updateAction2.getId());

assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(3);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3);
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
Expand All @@ -357,7 +359,7 @@ public void multipleCancelActionFeedback() throws Exception {
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(7);

// 1 update actions, 1 cancel actions
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(2);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2);
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction2.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
Expand Down Expand Up @@ -391,12 +393,12 @@ public void multipleCancelActionFeedback() throws Exception {
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(10);

// 1 update actions, 0 cancel actions
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);

final Action cancelAction3 = deploymentManagement.cancelAction(updateAction3.getId());

// action is in cancelling state
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
assertThat(deploymentManagement.getAssignedDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get())
.isEqualTo(ds3);
Expand All @@ -418,7 +420,7 @@ public void multipleCancelActionFeedback() throws Exception {
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(13);

// final status
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(0);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(0);
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
}

Expand Down
Loading