Skip to content

Commit

Permalink
test: be more lenient towards deviations
Browse files Browse the repository at this point in the history
  • Loading branch information
joshiste committed Jan 24, 2023
1 parent de24f8e commit 54845bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ void should_limit_all_traffic() {
Steadybit.networkLimitBandwidth(attackBandwidth)
.forContainers(target)
.exec(() -> {
assertThat(tester.measureBandwidth()).isCloseTo(this.attackBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.attackBandwidth.getValue(), withPercentage(15));
});
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(15));
}

@Test
Expand All @@ -46,18 +46,18 @@ void should_limit_all_traffic_using_port_filter() {
.destPort(tester.getDataPort())
.forContainers(target)
.exec(() -> {
assertThat(tester.measureBandwidth()).isCloseTo(this.attackBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.attackBandwidth.getValue(), withPercentage(15));
});

// mismatch
Steadybit.networkLimitBandwidth(this.attackBandwidth)
.destPort(tester.getDataPort() + 999)
.forContainers(target)
.exec(() -> {
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(15));
});

assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(15));
}

@Test
Expand All @@ -68,18 +68,18 @@ void should_limit_all_traffic_using_ip_filter() {
.destAddress(tester.getIperfClientAddress())
.forContainers(target)
.exec(() -> {
assertThat(tester.measureBandwidth()).isCloseTo(this.attackBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.attackBandwidth.getValue(), withPercentage(15));
});

// mismatch
Steadybit.networkLimitBandwidth(this.attackBandwidth)
.destAddress("1.1.1.1")
.forContainers(target)
.exec(() -> {
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(15));
});

assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(15));
}

@Test
Expand All @@ -91,7 +91,7 @@ void should_limit_all_traffic_using_ip_and_port_filter() {
.destPort(tester.getDataPort())
.forContainers(target)
.exec(() -> {
assertThat(tester.measureBandwidth()).isCloseTo(this.attackBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.attackBandwidth.getValue(), withPercentage(15));
});

// mismatch address
Expand All @@ -100,7 +100,7 @@ void should_limit_all_traffic_using_ip_and_port_filter() {
.destPort(tester.getDataPort())
.forContainers(target)
.exec(() -> {
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(15));
});

// mismatch port
Expand All @@ -109,10 +109,10 @@ void should_limit_all_traffic_using_ip_and_port_filter() {
.destPort(tester.getDataPort() + 999)
.forContainers(target)
.exec(() -> {
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(15));
});

assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(10));
assertThat(tester.measureBandwidth()).isCloseTo(this.normalBandwidth.getValue(), withPercentage(15));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void should_loose_some_packages() {
Steadybit.networkLoosePackages(20)
.forContainers(target)
.exec(() -> {
assertThat(tester.measureLoss()).isCloseTo(20, offset(5));
assertThat(tester.measureLoss()).isCloseTo(20, offset(10));
});
assertThat(tester.measureLoss()).isLessThan(5);
}
Expand All @@ -42,7 +42,7 @@ void should_loose_some_packages_using_port_filter() {
.destPort(tester.getDataPort())
.forContainers(target)
.exec(() -> {
assertThat(tester.measureLoss()).isCloseTo(20, offset(5));
assertThat(tester.measureLoss()).isCloseTo(20, offset(10));
});

// mismatch
Expand All @@ -63,7 +63,7 @@ void should_loose_some_packages_using_ip_filter() {
.destAddress(tester.getIperfClientAddress())
.forContainers(target)
.exec(() -> {
assertThat(tester.measureLoss()).isCloseTo(20, offset(5));
assertThat(tester.measureLoss()).isCloseTo(20, offset(10));
});

// mismatch
Expand All @@ -84,7 +84,7 @@ void should_loose_some_packages_using_ip_and_port_filter() {
.destAddress(tester.getIperfClientAddress())
.forContainers(target)
.exec(() -> {
assertThat(tester.measureLoss()).isCloseTo(20, offset(5));
assertThat(tester.measureLoss()).isCloseTo(20, offset(10));
});

// mismatch address
Expand Down

0 comments on commit 54845bd

Please sign in to comment.