ygerzhedovich commented on code in PR #1004:
URL: https://github.com/apache/ignite-3/pull/1004#discussion_r954812864


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/session/SessionManagerTest.java:
##########
@@ -0,0 +1,128 @@
+package org.apache.ignite.internal.sql.engine.session;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.Map;
+import java.util.UUID;
+import javax.validation.constraints.AssertTrue;
+import org.apache.ignite.internal.sql.engine.property.PropertiesHolder;
+import org.apache.ignite.internal.sql.engine.property.Property;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.jetbrains.annotations.Nullable;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class SessionManagerTest {
+
+    private SessionManager sessionMgr;
+    private Map<SessionId, Session> activeSessions;
+
+    @BeforeEach
+    void beforeEach() {
+        sessionMgr = new SessionManager("test", System::currentTimeMillis);
+        activeSessions = IgniteTestUtils.getFieldValue(sessionMgr, 
"activeSessions");
+    }
+
+    @AfterEach
+    void afterEach() throws Exception {
+        sessionMgr.stop();
+    }
+
+    @Test
+    void createSession() {
+        assertEquals(0, activeSessions.size());
+
+        SessionId sessionId1 = sessionMgr.createSession(1000, null);
+        assertNotNull(sessionId1);
+
+        SessionId sessionId2 = sessionMgr.createSession(1000, null);
+        assertNotNull(sessionId2);
+
+        assertNotEquals(sessionId1, sessionId2);
+        assertEquals(2, activeSessions.size());
+    }
+
+    @Test
+    void sessionGet() {
+        PropertiesHolder propHldr = createPropertyHolder();
+
+        SessionId sessionId = sessionMgr.createSession(12345, propHldr);
+
+        Session session = sessionMgr.session(sessionId);
+        assertNotNull(session);
+        assertSame(propHldr, session.queryProperties());
+        assertEquals(12345, session.getIdleTimeoutMs());
+
+        SessionId unknownSessionId = new SessionId(UUID.randomUUID());
+        assertNull(sessionMgr.session(unknownSessionId));
+    }
+
+    @Test
+    void touchSessionDuringGet() throws InterruptedException {

Review Comment:
   please look new code in the patch - I think no simple way don't use Thread 
sleep for the case



-- 
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]

Reply via email to