-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding a project for profiling experiments #1685
- Loading branch information
Showing
10 changed files
with
212 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<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> | ||
|
||
<groupId>com.intuit.karate.examples</groupId> | ||
<artifactId>profiling-test</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.version>3.6.0</maven.compiler.version> | ||
<karate.version>2.0.0</karate.version> | ||
<gatling.plugin.version>3.1.2</gatling.plugin.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.intuit.karate</groupId> | ||
<artifactId>karate-gatling</artifactId> | ||
<version>${karate.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<testResources> | ||
<testResource> | ||
<directory>src/test/java</directory> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
</excludes> | ||
</testResource> | ||
</testResources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven.compiler.version}</version> | ||
<configuration> | ||
<encoding>UTF-8</encoding> | ||
<source>${java.version}</source> | ||
<target>${java.version}</target> | ||
<compilerArgument>-Werror</compilerArgument> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.gatling</groupId> | ||
<artifactId>gatling-maven-plugin</artifactId> | ||
<version>${gatling.plugin.version}</version> | ||
<configuration> | ||
<simulationsFolder>src/test/java</simulationsFolder> | ||
<includes> | ||
<include>perf.TestSimulation</include> | ||
</includes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<name>profiling-test</name> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function(){ | ||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<immediateFlush>false</immediateFlush> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> | ||
<immediateFlush>false</immediateFlush> | ||
<file>target/karate.log</file> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<logger name="com.intuit.karate" level="WARN"/> | ||
|
||
<root level="WARN"> | ||
<appender-ref ref="STDOUT" /> | ||
<appender-ref ref="FILE" /> | ||
</root> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package perf; | ||
|
||
import com.intuit.karate.PerfHook; | ||
import com.intuit.karate.Runner; | ||
import com.intuit.karate.core.FeatureResult; | ||
import com.intuit.karate.core.PerfEvent; | ||
import com.intuit.karate.core.ScenarioRuntime; | ||
import com.intuit.karate.http.HttpRequest; | ||
|
||
/** | ||
* | ||
* @author pthomas3 | ||
*/ | ||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
TestUtils.startServer(); | ||
int count = 0; | ||
PerfHook hook = new PerfHook() { | ||
@Override | ||
public String getPerfEventName(HttpRequest request, ScenarioRuntime sr) { | ||
return request.getMethod() + " " + request.getUrl(); | ||
} | ||
|
||
@Override | ||
public void reportPerfEvent(PerfEvent event) { | ||
|
||
} | ||
|
||
@Override | ||
public void submit(Runnable runnable) { | ||
runnable.run(); | ||
} | ||
|
||
@Override | ||
public void afterFeature(FeatureResult fr) { | ||
|
||
} | ||
|
||
@Override | ||
public void pause(Number millis) { | ||
|
||
} | ||
|
||
}; | ||
while (true) { | ||
count++; | ||
Runner.callAsync(Runner.builder(), "classpath:perf/test.feature", null, hook); | ||
System.out.print(count + " "); | ||
if (count % 100 == 0) { | ||
System.out.println(""); | ||
} | ||
} | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
examples/profiling-test/src/test/java/perf/TestSimulation.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package perf | ||
|
||
import com.intuit.karate.gatling.PreDef._ | ||
import io.gatling.core.Predef._ | ||
|
||
import scala.concurrent.duration._ | ||
|
||
class TestSimulation extends Simulation { | ||
|
||
val protocol = karateProtocol() | ||
TestUtils.startServer() | ||
|
||
val test = scenario("test").exec(karateFeature("classpath:perf/test.feature")) | ||
|
||
setUp( | ||
test.inject(rampUsers(10) during (5 seconds)).protocols(protocol) | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package perf; | ||
|
||
import com.intuit.karate.core.MockServer; | ||
|
||
/** | ||
* | ||
* @author pthomas3 | ||
*/ | ||
public class TestUtils { | ||
|
||
public static void startServer() { | ||
MockServer server = MockServer.feature("classpath:perf/mock.feature").build(); | ||
System.setProperty("mock.server.url", "http://localhost:" + server.getPort()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Feature: | ||
|
||
Scenario: | ||
* def var1 = { foo: 'bar' } | ||
* def var2 = { baz: 'ban' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Feature: | ||
|
||
Scenario: pathMatches('/test') | ||
* def response = { success: true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Feature: | ||
|
||
Background: | ||
* def backgroundData = callonce read('called.feature') | ||
* url karate.properties['mock.server.url'] | ||
|
||
Scenario: | ||
* path 'test' | ||
* method get | ||
* match response == { success: true } | ||
* match backgroundData contains { var1: { foo: 'bar' } } | ||
* def scenarioData = karate.call('called.feature') | ||
* match scenarioData contains { var2: { baz: 'ban' } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters