mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
Added a simple util to perfom some manual testing to verify the client-server communication.
This must of course be fully automated.
This commit is contained in:
parent
4c003b7a20
commit
6554c1a694
@ -11,6 +11,7 @@ import org.apache.http.client.methods.HttpGet;
|
|||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
|
//TODO: take advantage of Etag and 304 responses.
|
||||||
public class HTTPToggleRepository implements ToggleRepository {
|
public class HTTPToggleRepository implements ToggleRepository {
|
||||||
private static final Log LOG = LogFactory.getLog(HTTPToggleRepository.class);
|
private static final Log LOG = LogFactory.getLog(HTTPToggleRepository.class);
|
||||||
|
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package no.finn.unleash;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import no.finn.unleash.repository.HTTPToggleRepository;
|
||||||
|
import no.finn.unleash.repository.PollingToggleRepository;
|
||||||
|
import no.finn.unleash.repository.ToggleRepository;
|
||||||
|
|
||||||
|
public class ManualTesting {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
HTTPToggleRepository httpRepo = new HTTPToggleRepository("http://localhost:4242/features");
|
||||||
|
ToggleRepository repository = new PollingToggleRepository(httpRepo, 1);
|
||||||
|
|
||||||
|
|
||||||
|
Unleash unleash = new Unleash(repository);
|
||||||
|
|
||||||
|
for(int i=0;i<100;i++) {
|
||||||
|
(new Thread(new UnleashThread(unleash, "thread-"+i, 100))).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class UnleashThread implements Runnable {
|
||||||
|
|
||||||
|
final Unleash unleash;
|
||||||
|
final String name;
|
||||||
|
final int maxRounds;
|
||||||
|
int currentRound = 0;
|
||||||
|
|
||||||
|
UnleashThread(Unleash unleash, String name, int maxRounds) {
|
||||||
|
this.unleash = unleash;
|
||||||
|
this.name = name;
|
||||||
|
this.maxRounds = maxRounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
while(currentRound < maxRounds) {
|
||||||
|
currentRound++;
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
boolean enabled = unleash.isEnabled("featureX");
|
||||||
|
long timeUsed = System.nanoTime() - startTime;
|
||||||
|
|
||||||
|
System.out.println(name + "\t" +"featureX" +":" + enabled + "\t " + timeUsed + "ns");
|
||||||
|
|
||||||
|
try {
|
||||||
|
//Wait 1 to 10ms before next round
|
||||||
|
Thread.sleep(new Random().nextInt(10000));
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,23 @@
|
|||||||
{"features":[{"name":"featureX","status":"on","strategy":"default"},{"name":"featureY","status":"off","strategy":"baz","parameters":{"foo":"bar"}},{"name":"featureZ","status":"on","strategy":"baz","parameters":{"foo":"rab"}}]}
|
{"features": [
|
||||||
|
{
|
||||||
|
"name": "featureX",
|
||||||
|
"enabled": true,
|
||||||
|
"strategy": "default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "featureY",
|
||||||
|
"enabled": false,
|
||||||
|
"strategy": "baz",
|
||||||
|
"parameters": {
|
||||||
|
"foo": "bar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "featureZ",
|
||||||
|
"enabled": true,
|
||||||
|
"strategy": "baz",
|
||||||
|
"parameters": {
|
||||||
|
"foo": "rab"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}
|
Loading…
Reference in New Issue
Block a user