vldpyatkov commented on code in PR #13836: URL: https://github.com/apache/ignite/pull/13836#discussion_r4585955737
########## modules/core/src/test/java/org/apache/ignite/internal/client/thin/events/IgniteClientConnectionIdTest.java: ########## @@ -0,0 +1,246 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.client.thin.events; + +import java.io.DataInputStream; +import java.net.Socket; +import java.util.List; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignition; +import org.apache.ignite.client.ClientException; +import org.apache.ignite.client.IgniteClient; +import org.apache.ignite.client.IgniteClientFuture; +import org.apache.ignite.client.events.ConnectionClosedEvent; +import org.apache.ignite.client.events.ConnectionDescription; +import org.apache.ignite.client.events.ConnectionEventListener; +import org.apache.ignite.client.events.HandshakeStartEvent; +import org.apache.ignite.client.events.HandshakeSuccessEvent; +import org.apache.ignite.client.events.RequestEvent; +import org.apache.ignite.client.events.RequestEventListener; +import org.apache.ignite.client.events.RequestFailEvent; +import org.apache.ignite.client.events.RequestStartEvent; +import org.apache.ignite.client.events.RequestSuccessEvent; +import org.apache.ignite.configuration.ClientConfiguration; +import org.apache.ignite.internal.binary.BinaryReaderEx; +import org.apache.ignite.internal.binary.BinaryUtils; +import org.apache.ignite.internal.binary.BinaryWriterEx; +import org.apache.ignite.internal.binary.streams.BinaryStreams; +import org.apache.ignite.internal.client.thin.AbstractThinClientTest; +import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor; +import org.apache.ignite.mxbean.ClientProcessorMXBean; +import org.apache.ignite.spi.systemview.view.ClientConnectionView; +import org.apache.ignite.spi.systemview.view.SystemView; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.ListeningTestLogger; +import org.junit.Test; + +import static org.apache.ignite.internal.client.thin.ProtocolVersion.LATEST_VER; +import static org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW; +import static org.apache.ignite.internal.util.CommonUtils.HANDSHAKE; +import static org.apache.ignite.internal.util.CommonUtils.THIN_CLIENT; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertNotEquals; + +/** Tests server-assigned connection IDs in thin client events and diagnostics. */ +public class IgniteClientConnectionIdTest extends AbstractThinClientTest { + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + startGrid(0); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + super.afterTest(); + } + + /** Tests IDs in events, including an asynchronous failure delivered after reconnection. */ + @Test + public void testConnectionIdAfterReconnect() throws Exception { + List<ConnectionDescription> starts = new CopyOnWriteArrayList<>(); Review Comment: I used CopyOnWriteArrayList because the test checks event order using indexed access. It collects only a few events, so copying overhead should be negligible. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
