Skip to content

Commit cd8c7b7

Browse files
committed
Working
1 parent 993eb99 commit cd8c7b7

23 files changed

+956
-394
lines changed

load-tests/self/build.savant

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,9 @@ target(name: "start", description: "Starts the java-http server for load testing
8686
fail("Unable to start the server!")
8787
}
8888
}
89+
90+
target(name: "suspend", description: "Starts the java-http server for load testing! ", dependsOn: ["app"]) {
91+
if (new ProcessBuilder('./start.sh', '--suspend').directory(new File("build/dist")).inheritIO().start().waitFor() != 0) {
92+
fail("Unable to start the server!")
93+
}
94+
}

load-tests/self/src/main/java/io/fusionauth/http/load/Main.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static void main(String[] args) throws Exception {
5757
// Try to report every 15 seconds. If nothing has changed, skip.
5858
do {
5959
//noinspection BusyWait
60-
Thread.sleep(Duration.ofSeconds(15).toMillis());
60+
Thread.sleep(Duration.ofSeconds(2).toMillis());
6161

6262
// Cut down on noise if we are not running any requests.
6363
var snapshot = new Snapshot(instrumenter);
@@ -88,7 +88,10 @@ private static Path setupOutput() throws IOException {
8888
Files.createFile(outputFile);
8989
}
9090

91-
System.out.println("Server instrumentation output file. Watch this file for server statistics during your load test.\n - " + outputFile);
91+
System.out.println("""
92+
Server instrumentation output file created. Watch this file for server statistics during your load test.
93+
> watch cat {outputFile}
94+
""".replace("{outputFile}", outputFile.toString()));
9295
return outputFile;
9396
}
9497

@@ -98,24 +101,24 @@ private static void writeStatus(Path outputFile, Snapshot snapshot) throws IOExc
98101
-------------------------------------------
99102
- Servers started: [%,d]
100103
- Active workers: [%,d]
104+
- Total connections: [%,d]
101105
- Accepted requests: [%,d]
102106
- Bad requests: [%,d]
107+
- Closed connections: [%,d]
103108
- Chunked requests: [%,d]
104109
- Chunked responses: [%,d]
105-
- Closed connections: [%,d]
106-
- Total connections: [%,d]
107110
- Bytes read: [%,d]
108111
- Bytes written: [%,d]
109112
""",
110113
snapshot.now,
111-
snapshot.serversStarted,
112-
snapshot.activeWorkers,
114+
snapshot.servers,
115+
snapshot.workers,
116+
snapshot.acceptedConnections,
113117
snapshot.acceptedRequests,
114118
snapshot.badRequests,
119+
snapshot.closedConnections,
115120
snapshot.chunkedRequests,
116121
snapshot.chunkedResponses,
117-
snapshot.closedConnections,
118-
snapshot.totalConnections,
119122
snapshot.bytesRead,
120123
snapshot.bytesWritten);
121124

@@ -125,9 +128,9 @@ private static void writeStatus(Path outputFile, Snapshot snapshot) throws IOExc
125128
}
126129

127130
private static class Snapshot {
128-
public long acceptedRequests;
131+
public long acceptedConnections;
129132

130-
public long activeWorkers;
133+
public long acceptedRequests;
131134

132135
public long badRequests;
133136

@@ -143,20 +146,20 @@ private static class Snapshot {
143146

144147
public long now;
145148

146-
public long serversStarted;
149+
public long servers;
147150

148-
public long totalConnections;
151+
public long workers;
149152

150153
public Snapshot(ThreadSafeCountingInstrumenter instrumenter) {
151154
now = System.currentTimeMillis();
152-
serversStarted = instrumenter.getStartedCount();
153-
activeWorkers = instrumenter.getThreadCount();
155+
servers = instrumenter.getServers();
156+
workers = instrumenter.getWorkers();
157+
acceptedConnections = instrumenter.getAcceptedConnections();
154158
acceptedRequests = instrumenter.getAcceptedRequests();
155159
badRequests = instrumenter.getBadRequests();
156160
chunkedRequests = instrumenter.getChunkedRequests();
157161
chunkedResponses = instrumenter.getChunkedResponses();
158162
closedConnections = instrumenter.getClosedConnections();
159-
totalConnections = instrumenter.getConnections();
160163
bytesRead = instrumenter.getBytesRead();
161164
bytesWritten = instrumenter.getBytesWritten();
162165
}
@@ -167,12 +170,12 @@ public boolean equals(Object o) {
167170
return false;
168171
}
169172
Snapshot snapshot = (Snapshot) o;
170-
return now == snapshot.now && serversStarted == snapshot.serversStarted && activeWorkers == snapshot.activeWorkers && acceptedRequests == snapshot.acceptedRequests && badRequests == snapshot.badRequests && chunkedRequests == snapshot.chunkedRequests && chunkedResponses == snapshot.chunkedResponses && closedConnections == snapshot.closedConnections && totalConnections == snapshot.totalConnections && bytesRead == snapshot.bytesRead && bytesWritten == snapshot.bytesWritten;
173+
return now == snapshot.now && servers == snapshot.servers && workers == snapshot.workers && acceptedRequests == snapshot.acceptedRequests && badRequests == snapshot.badRequests && chunkedRequests == snapshot.chunkedRequests && chunkedResponses == snapshot.chunkedResponses && closedConnections == snapshot.closedConnections && acceptedConnections == snapshot.acceptedConnections && bytesRead == snapshot.bytesRead && bytesWritten == snapshot.bytesWritten;
171174
}
172175

173176
@Override
174177
public int hashCode() {
175-
return Objects.hash(now, serversStarted, activeWorkers, acceptedRequests, badRequests, chunkedRequests, chunkedResponses, closedConnections, totalConnections, bytesRead, bytesWritten);
178+
return Objects.hash(now, servers, workers, acceptedRequests, badRequests, chunkedRequests, chunkedResponses, closedConnections, acceptedConnections, bytesRead, bytesWritten);
176179
}
177180
}
178181
}

src/main/java/io/fusionauth/http/ParseException.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
public class ParseException extends RuntimeException {
2424
private final String state;
2525

26+
private Integer index;
27+
2628
public ParseException() {
2729
this.state = null;
2830
}
@@ -37,6 +39,22 @@ public ParseException(String message, String state) {
3739
this.state = state;
3840
}
3941

42+
public int getIndex() {
43+
return index;
44+
}
45+
46+
public void setIndex(int index) {
47+
this.index = index;
48+
}
49+
50+
public String getMessage() {
51+
var message = super.getMessage();
52+
if (index != null) {
53+
message += " Occurred at index [" + index + "]";
54+
}
55+
return message;
56+
}
57+
4058
public String getState() {
4159
return state;
4260
}

0 commit comments

Comments
 (0)