Skip to content

Commit

Permalink
Temp: investigating failures
Browse files Browse the repository at this point in the history
Signed-off-by: Flavia Rainone <frainone@redhat.com>
  • Loading branch information
fl4via committed Oct 16, 2023
1 parent 6f0ca47 commit 1eba6de
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
module: [core, servlet, websockets-jsr]
module: [core]
#, servlet, websockets-jsr]
jdk: [11, 17]
openjdk_impl: [ temurin ]
steps:
Expand Down Expand Up @@ -103,7 +104,7 @@ jobs:
- name: Print Version
run: mvn -v
- name: Run Tests
run: mvn -U -B -fae test -Pproxy '-DfailIfNoTests=false' -pl ${{ matrix.module }}
run: mvn -U -B -fae test -Pproxy '-DfailIfNoTests=false' -pl ${{ matrix.module }} -Dtest=RapidResetDDoSUnitTestCase
- uses: actions/upload-artifact@v2
if: failure()
with:
Expand All @@ -119,7 +120,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
module: [core, servlet, websockets-jsr]
module: [core]
#, servlet, websockets-jsr]
proxy: ['-Pproxy', '']
jdk: [11]
steps:
Expand Down Expand Up @@ -155,7 +157,7 @@ jobs:
- name: Print Version
run: mvn -v
- name: Run Tests
run: mvn -U -B -fae test ${{ matrix.proxy }} '-DfailIfNoTests=false' -pl ${{ matrix.module }} -Dtest.ipv6=true
run: mvn -U -B -fae test ${{ matrix.proxy }} '-DfailIfNoTests=false' -pl ${{ matrix.module }} -Dtest.ipv6=true -Dtest=RapidResetDDoSUnitTestCase
- uses: actions/upload-artifact@v2
if: failure()
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,15 @@ protected AbstractHttp2StreamSourceChannel createChannelImpl(FrameHeaderData fra
throw new ConnectionErrorException(Http2Channel.ERROR_PROTOCOL_ERROR, UndertowMessages.MESSAGES.streamIdMustNotBeZeroForFrameType(FRAME_TYPE_RST_STREAM));
}
channel = new Http2RstStreamStreamSourceChannel(this, frameData, parser.getErrorCode(), frameParser.streamId);
System.out.println("got rst stream for stream Id " + frameParser.streamId);
handleRstStream(frameParser.streamId, true);
if(isIdle(frameParser.streamId)) {
sendGoAway(ERROR_PROTOCOL_ERROR);
}
break;
}
case FRAME_TYPE_SETTINGS: {
System.out.println("got rst stream for stream Id " + frameParser.streamId);
if (!Bits.anyAreSet(frameParser.flags, SETTINGS_FLAG_ACK)) {
if(updateSettings(((Http2SettingsParser) frameParser.parser).getSettings())) {
sendSettingsAck();
Expand All @@ -523,6 +525,7 @@ protected AbstractHttp2StreamSourceChannel createChannelImpl(FrameHeaderData fra
}
case FRAME_TYPE_GOAWAY: {
Http2GoAwayParser http2GoAwayParser = (Http2GoAwayParser) frameParser.parser;
System.out.println(this + " received go away with status " + http2GoAwayParser);
channel = new Http2GoAwayStreamSourceChannel(this, frameData, frameParser.getFrameLength(), http2GoAwayParser.getStatusCode(), http2GoAwayParser.getLastGoodStreamId());
peerGoneAway = true;
//the peer is going away
Expand Down Expand Up @@ -842,6 +845,7 @@ void sendPing(byte[] data, final ChannelExceptionHandler<AbstractHttp2StreamSink
}

public void sendGoAway(int status) {
System.out.println((isClient()? "client" : "server" ) + "is sending go away " + status);
sendGoAway(status, new Http2ControlMessageExceptionHandler());
}

Expand Down Expand Up @@ -1149,6 +1153,7 @@ public void sendRstStream(int streamId, int statusCode) {
//no point sending if the channel is closed
return;
}
System.out.println((isClient()? "client": "server") + "sending rst stream");
sentRstStreams.store(streamId, handleRstStream(streamId, false));
if(UndertowLogger.REQUEST_IO_LOGGER.isDebugEnabled()) {
UndertowLogger.REQUEST_IO_LOGGER.debugf(new ClosedChannelException(), "Sending rststream on channel %s stream %s", this, streamId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public boolean handle(final ByteBuffer byteBuffer) throws IOException {
if(continuationParser != null && type != FRAME_TYPE_CONTINUATION) {
throw new ConnectionErrorException(Http2Channel.ERROR_PROTOCOL_ERROR, UndertowMessages.MESSAGES.expectedContinuationFrame());
}
//System.out.println(http2Channel + " parsing frame with stream id: " + streamId);
switch (type) {
case FRAME_TYPE_DATA: {
if (streamId == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected Http2GoAwayStreamSinkChannel(Http2Channel channel, int status, int las
super(channel);
this.status = status;
this.lastGoodStreamId = lastGoodStreamId;
new Exception("creating go away with status " + status).printStackTrace();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public void handleEvent(AbstractFramedChannel channel) {
try {
AbstractFramedStreamSourceChannel stream = channel.receive();
if(stream != null) {
System.out.println("AbstractFramedChannel.DRAIN_LISTENER invoked");
UndertowLogger.REQUEST_IO_LOGGER.debugf("Draining channel %s as no receive listener has been set", stream);
stream.getReadSetter().set(ChannelListeners.drainListener(Long.MAX_VALUE, null, null));
stream.wakeupReads();
Expand Down Expand Up @@ -968,6 +969,7 @@ public void handleEvent(final StreamSourceChannel channel) {
} else {
ChannelListener listener = receiveSetter.get();
if (listener == null) {
System.out.println("Setting DRAIN LISTENER from inside FrameReadListener");
listener = DRAIN_LISTENER;
}
//UndertowLogger.REQUEST_IO_LOGGER.tracef("Invoking receive listener: %s - receiver: %s", listener, receiver);
Expand Down Expand Up @@ -1023,6 +1025,7 @@ public void handleEvent(final CloseableChannel c) {
if(!sourceClosed || !sinkClosed) {
return; //both sides need to be closed
} else if(localReadData != null && !localReadData.isFreed()) {
System.out.println("handling event closable channel, and local read data was not null, nor was it free, we'll enable drain listener");
//we make sure there is no data left to receive, if there is then we invoke the receive listener
runInIoThread(new Runnable() {
@Override
Expand All @@ -1031,6 +1034,7 @@ public void run() {
int rem = localReadData.getBuffer().remaining();
ChannelListener listener = receiveSetter.get();
if(listener == null) {
System.out.println("set listener to drain listener");
listener = DRAIN_LISTENER;
}
ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public static void beforeClass() throws Exception {

// Create xnio worker
worker = Xnio.getInstance().createWorker(null, DEFAULT_OPTIONS);
exceptionCount = 0;
}

@AfterClass
Expand Down Expand Up @@ -185,6 +186,8 @@ public void testNoErrorWithOverwrittenConfig() throws Exception {
}

public void assertDoSRstFramesHandled(int totalNumberOfRequests, int rstStreamLimit, boolean errorExpected, URI serverAddress) throws Exception {
Thread.sleep(10000);
System.out.println("\n\n\n\n");
final List<ClientResponse> responses = new CopyOnWriteArrayList<>();
final CountDownLatch latch = new CountDownLatch(totalNumberOfRequests);

Expand Down Expand Up @@ -241,10 +244,16 @@ public void assertDoSRstFramesHandled(int totalNumberOfRequests, int rstStreamLi

latch.await(200, TimeUnit.SECONDS);

Assert.assertEquals(errorExpected? rstStreamLimit + 1:totalNumberOfRequests, responses.size());
for (final ClientResponse response : responses) {
final String responseBody = response.getAttachment(RESPONSE_BODY);
Assert.assertTrue("Unexpected response body: " + responseBody, responseBody.isEmpty() || responseBody.equals(message));
// server sent go away before processing and responding client frames, sometimes this happens, depends on the order of threads
// being executed
if (responses.isEmpty()) {
Assert.assertTrue(errorExpected);
} else {
Assert.assertEquals(errorExpected ? rstStreamLimit + 1 : totalNumberOfRequests, responses.size());
for (final ClientResponse response : responses) {
final String responseBody = response.getAttachment(RESPONSE_BODY);
Assert.assertTrue("Unexpected response body: " + responseBody, responseBody.isEmpty() || responseBody.equals(message));
}
}
if (errorExpected) {
Assert.assertNotNull(exception);
Expand All @@ -258,6 +267,7 @@ public void assertDoSRstFramesHandled(int totalNumberOfRequests, int rstStreamLi
}
} finally {
IoUtils.safeClose(connection);
System.out.println(connection.getCloseSetter());
}
}

Expand All @@ -272,6 +282,8 @@ private static Http2ClientConnection createHttp2Channel(StreamConnection connect
return clientConnection = new DoSHttp2ClientConnection(http2Channel, false, defaultHost, null, true);
}

private static int exceptionCount;

private ClientCallback<ClientExchange> createClientCallback(final List<ClientResponse> responses, final CountDownLatch latch) {
return new ClientCallback<>() {
@Override public void completed(ClientExchange result) {
Expand Down Expand Up @@ -313,6 +325,7 @@ private ClientCallback<ClientExchange> createClientCallback(final List<ClientRes
}

@Override public void failed(IOException e) {
exceptionCount ++;
e.printStackTrace();
exception = e;
latch.countDown();
Expand Down

0 comments on commit 1eba6de

Please sign in to comment.