Skip to content

Commit

Permalink
Fixing bug in ratelimiter when rampUp period is 0 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
noconnor authored May 23, 2019
1 parent 433d407 commit 1464151
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply plugin: 'jacoco'
group = 'com.github.noconnor'
sourceCompatibility = 1.8
// http://semver.org/
version = '1.13.0'
version = '1.13.1'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.github.noconnor.junitperf.statements;

import com.github.noconnor.junitperf.data.EvaluationContext;
import com.github.noconnor.junitperf.statistics.StatisticsCalculator;
import com.github.noconnor.junitperf.statistics.providers.NoOpStatisticsCollector;
import com.google.common.util.concurrent.RateLimiter;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.Builder;
import org.junit.runners.model.Statement;

import java.util.List;
import java.util.concurrent.ThreadFactory;
import java.util.function.Consumer;
import org.junit.runners.model.Statement;
import com.github.noconnor.junitperf.data.EvaluationContext;
import com.github.noconnor.junitperf.statistics.StatisticsCalculator;
import com.github.noconnor.junitperf.statistics.providers.NoOpStatisticsCollector;
import com.google.common.util.concurrent.RateLimiter;
import com.google.common.util.concurrent.ThreadFactoryBuilder;

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.util.concurrent.RateLimiter.create;
Expand Down Expand Up @@ -85,7 +85,9 @@ private void assertThresholdsMet() {
}

private RateLimiter createRateLimiter(final EvaluationContext context) {
return create(context.getConfiguredRateLimit(), context.getConfiguredRampUpPeriodMs(), MILLISECONDS);
int rampUp = context.getConfiguredRampUpPeriodMs();
int rateLimit = context.getConfiguredRateLimit();
return rampUp > 0 ? create(rateLimit, rampUp, MILLISECONDS) : create(rateLimit);
}


Expand Down

0 comments on commit 1464151

Please sign in to comment.