mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-23 15:40:44 -06:00
partial work on nb webdriver
This commit is contained in:
parent
5e8c5bdfca
commit
115b0260f2
136
driver-web/pom.xml
Normal file
136
driver-web/pom.xml
Normal file
@ -0,0 +1,136 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>driver-web</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>mvn-defaults</artifactId>
|
||||
<groupId>io.nosqlbench</groupId>
|
||||
<version>3.12.83-SNAPSHOT</version>
|
||||
<relativePath>../mvn-defaults</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
A nosqlbench driver module;
|
||||
Provides the ability to drive steps through the webdriver API.
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.nosqlbench</groupId>
|
||||
<artifactId>engine-api</artifactId>
|
||||
<version>3.12.83-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>htmlunit-driver</artifactId>
|
||||
<version>2.39.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-api</artifactId>
|
||||
<version>3.141.59</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.seleniumhq.selenium</groupId>-->
|
||||
<!-- <artifactId>selenium-json</artifactId>-->
|
||||
<!-- <version>4.0.0-alpha-5</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-remote-driver</artifactId>
|
||||
<version>3.141.59</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>3.141.59</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-chrome-driver</artifactId>
|
||||
<version>3.141.59</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-htmlunit-driver</artifactId>
|
||||
<version>2.52.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.12</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.seleniumhq.selenium</groupId>-->
|
||||
<!-- <artifactId>selenium-devtools</artifactId>-->
|
||||
<!-- <version>4.0.0-alpha-5</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.seleniumhq.selenium</groupId>-->
|
||||
<!-- <artifactId>selenium-htmlunit-driver</artifactId>-->
|
||||
<!-- <version>2.52.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.squareup.okhttp3</groupId>-->
|
||||
<!-- <artifactId>okhttp</artifactId>-->
|
||||
<!-- <version>4.5.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.seleniumhq.selenium</groupId>-->
|
||||
<!-- <artifactId>selenium-htmlunit-driver</artifactId>-->
|
||||
<!-- <version></version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- test scope only -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>shade</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
package io.nosqlbench.driver.web;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
|
||||
public class NBWebDriver implements ActivityType<WebDriverActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package io.nosqlbench.driver.web;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.engine.api.activityimpl.SimpleActivity;
|
||||
|
||||
public class WebDriverActivity extends SimpleActivity{
|
||||
|
||||
public WebDriverActivity(ActivityDef activityDef) {
|
||||
super(activityDef);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package io.nosqlbench.driver.web;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.core.Action;
|
||||
import io.nosqlbench.engine.api.activityapi.core.ActionDispenser;
|
||||
import io.nosqlbench.engine.api.activityapi.core.Activity;
|
||||
import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.api.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
public class WebDriverActivityType implements ActivityType<WebDriverActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "webdriver";
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebDriverActivity getActivity(ActivityDef activityDef) {
|
||||
return new WebDriverActivity(activityDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionDispenser getActionDispenser(WebDriverActivity activity) {
|
||||
return new WebDriverActionDispenser(activity);
|
||||
}
|
||||
|
||||
private static class WebDriverActionDispenser implements ActionDispenser {
|
||||
|
||||
private final Activity activity;
|
||||
|
||||
private WebDriverActionDispenser(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getAction(int slot) {
|
||||
return new WebDriverAsyncAction((WebDriverActivity) activity, slot);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package io.nosqlbench.driver.web;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.core.BaseAsyncAction;
|
||||
import io.nosqlbench.engine.api.activityapi.core.ops.fluent.opfacets.TrackedOp;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
* Holds the definition and tracking state for a web driver command.
|
||||
*/
|
||||
public class WebDriverAsyncAction extends BaseAsyncAction<WebDriverCmdState,WebDriverActivity> {
|
||||
|
||||
public WebDriverAsyncAction(WebDriverActivity activity, int slot) {
|
||||
super(activity,slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startOpCycle(TrackedOp<WebDriverCmdState> opc) {
|
||||
WebDriver driver = new ChromeDriver();
|
||||
driver.get("http://docs.nosqlbench.io/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongFunction<WebDriverCmdState> getOpInitFunction() {
|
||||
return (cycle) -> new WebDriverCmdState(this,cycle);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package io.nosqlbench.driver.web;
|
||||
|
||||
public class WebDriverCmdState {
|
||||
|
||||
private final WebDriverAsyncAction action;
|
||||
private final long cycle;
|
||||
|
||||
public WebDriverCmdState(WebDriverAsyncAction action, long cycle) {
|
||||
|
||||
this.action = action;
|
||||
this.cycle = cycle;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package io.nosqlbench.driver.web;
|
||||
|
||||
import io.nosqlbench.nb.api.testutils.Perf;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
||||
import org.openqa.selenium.remote.RemoteWebElement;
|
||||
|
||||
|
||||
/**
|
||||
* References:
|
||||
* <UL>
|
||||
* <LI>https://www.guru99.com/selenium-with-htmlunit-driver-phantomjs.html</LI>
|
||||
* <LI></LI>
|
||||
* </UL>
|
||||
*/
|
||||
public class ExampleWebScript {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void getDocsSiteChromeDriver() {
|
||||
System.setProperty("webdriver.http.factory", "okhttp");
|
||||
WebDriver driver = new ChromeDriver();
|
||||
Perf perf = new Perf("chrome");
|
||||
int ops = 100;
|
||||
try (Perf.Time time = perf.start("chrome",ops)) {
|
||||
for (int i = 1; i <= ops; i++) {
|
||||
System.out.print(".");
|
||||
if ((i%10)==0) { System.out.println(i); }
|
||||
driver.get("http://localhost:6081");
|
||||
}
|
||||
}
|
||||
System.out.println("!");
|
||||
|
||||
System.out.println(perf.toString());
|
||||
// driver.get("http://docs.nosqlbench.io/");
|
||||
driver.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void getDocSiteWebHtml() {
|
||||
// System.setProperty("webdriver.http.factory", "okhttp");
|
||||
WebDriver driver = new HtmlUnitDriver(false);
|
||||
Perf perf = new Perf("htmlunit");
|
||||
int ops = 100;
|
||||
try (Perf.Time time = perf.start("htmlunit",ops)) {
|
||||
for (int i = 1; i <= ops; i++) {
|
||||
System.out.print(".");
|
||||
if ((i%10)==0) { System.out.println(i); }
|
||||
driver.get("http://localhost:6081");
|
||||
}
|
||||
}
|
||||
System.out.println("!");
|
||||
|
||||
System.out.println(perf.toString());
|
||||
// driver.get("http://docs.nosqlbench.io/");
|
||||
driver.close();
|
||||
}
|
||||
}
|
@ -22,10 +22,8 @@ import io.nosqlbench.engine.api.activityapi.core.ops.fluent.opfacets.TrackedOp;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
* <p>An AsyncAction allows an activity type to implement asynchronous
|
||||
* An AsyncAction allows an activity type to implement asynchronous
|
||||
* operations within each thread.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public interface AsyncAction<D> extends Action {
|
||||
|
||||
@ -64,33 +62,4 @@ public interface AsyncAction<D> extends Action {
|
||||
*/
|
||||
boolean enqueue(TrackedOp<D> opc);
|
||||
|
||||
// /**
|
||||
// * Await completion of all pending operations for this thread.
|
||||
// * If all tasks are already complete when this is called, then it
|
||||
// * should return immediately.
|
||||
// * @param timeout Timeout in milliseconds
|
||||
// * @return true, if all tasks pending for this thread are completed.
|
||||
// */
|
||||
// boolean awaitCompletion(long timeout);
|
||||
|
||||
// /**
|
||||
// * Once constructed, all async actions are expected to provide a tracker
|
||||
// * object which can be used to register callback for operational events,
|
||||
// * as well as to provide a diagnostic view of what is happening with
|
||||
// * the number of pending operations per thread.
|
||||
// * @return An async operations tracker
|
||||
// */
|
||||
// OpTracker<D> getTracker();
|
||||
|
||||
// /**
|
||||
// * When the activity needs to create a new op context which tracks all
|
||||
// * things interesting for the operation, it will call this method.
|
||||
// * The payload type D determines any and all of what an async action
|
||||
// * may know about an op.
|
||||
// *
|
||||
// * @return A new op state of parameterized type D
|
||||
// */
|
||||
// D allocateOpData(long cycle);
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,9 +18,9 @@
|
||||
package io.nosqlbench.engine.api.activityapi.ratelimits;
|
||||
|
||||
import io.nosqlbench.engine.api.metrics.DeltaHdrHistogramReservoir;
|
||||
import io.nosqlbench.testutils.Bounds;
|
||||
import io.nosqlbench.testutils.Perf;
|
||||
import io.nosqlbench.testutils.Result;
|
||||
import io.nosqlbench.nb.api.testutils.Bounds;
|
||||
import io.nosqlbench.nb.api.testutils.Perf;
|
||||
import io.nosqlbench.nb.api.testutils.Result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -18,8 +18,8 @@
|
||||
package io.nosqlbench.engine.api.activityapi.ratelimits;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.testutils.Perf;
|
||||
import io.nosqlbench.testutils.Result;
|
||||
import io.nosqlbench.nb.api.testutils.Perf;
|
||||
import io.nosqlbench.nb.api.testutils.Result;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
package io.nosqlbench.engine.api.activityapi.ratelimits;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.testutils.Perf;
|
||||
import io.nosqlbench.nb.api.testutils.Perf;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
package io.nosqlbench.engine.api.activityapi.ratelimits;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.testutils.Perf;
|
||||
import io.nosqlbench.nb.api.testutils.Perf;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
package io.nosqlbench.engine.api.activityapi.ratelimits;
|
||||
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.testutils.Result;
|
||||
import io.nosqlbench.nb.api.testutils.Result;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -15,9 +15,23 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package io.nosqlbench.testutils;
|
||||
package io.nosqlbench.nb.api.testutils;
|
||||
|
||||
/**
|
||||
* Easily step from one value to the next according to a modified
|
||||
* logarithmic sequence that makes it easy to pick useful testing
|
||||
* boundaries.
|
||||
*
|
||||
* With levels per magnitude at 1, the progression goes in powers
|
||||
* of 10. With any higher value than 1, each magnitude is divided
|
||||
* into equal parts. For example, starting at 10 with 2 levels per magnitude,
|
||||
* you get 50, 100, 500, 1000, 5000, and so on when you ask for
|
||||
* the next higher bound.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Bounds {
|
||||
|
||||
private final int levelsPerMagnitude;
|
||||
private long currentValue;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package io.nosqlbench.testutils;
|
||||
package io.nosqlbench.nb.api.testutils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@ -179,4 +179,28 @@ public class Perf implements Iterable<Result> {
|
||||
public Iterator<Result> iterator() {
|
||||
return results.iterator();
|
||||
}
|
||||
|
||||
public Time start(String name, long ops) {
|
||||
return new Time(this, name, ops);
|
||||
}
|
||||
|
||||
public static class Time implements AutoCloseable {
|
||||
private final Perf perf;
|
||||
private final long start;
|
||||
private String name;
|
||||
private long ops;
|
||||
|
||||
public Time(Perf perf, String name, long ops) {
|
||||
this.name = name;
|
||||
this.ops = ops;
|
||||
this.start = System.nanoTime();
|
||||
this.perf = perf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
long end = System.nanoTime();
|
||||
perf.add(name,start,end,ops);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package io.nosqlbench.testutils;
|
||||
package io.nosqlbench.nb.api.testutils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -15,7 +15,7 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package io.nosqlbench.testutils;
|
||||
package io.nosqlbench.nb.api.testutils;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package io.nosqlbench.testutils;
|
||||
package io.nosqlbench.nb.api.testutils;
|
||||
|
||||
import org.junit.Test;
|
||||
|
4
pom.xml
4
pom.xml
@ -1,4 +1,5 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>nosqlbench</artifactId>
|
||||
@ -41,6 +42,7 @@
|
||||
<module>activitytype-http</module>
|
||||
<module>activitytype-cql</module>
|
||||
<module>activitytype-cqlverify</module>
|
||||
<module>driver-web</module>
|
||||
|
||||
<!-- VIRTDATA MODULES -->
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user