Quellcode durchsuchen

HPCC-22022 Fix issue with free port discovery for temp dafilesrv server

Make serverPort a static so shared amongst tests as intended.

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith vor 6 Jahren
Ursprung
Commit
c02cf72454
2 geänderte Dateien mit 17 neuen und 7 gelöschten Zeilen
  1. 12 6
      esp/clients/wsdfuaccess/wsdfuaccess.cpp
  2. 5 1
      fs/dafsserver/dafsserver.cpp

+ 12 - 6
esp/clients/wsdfuaccess/wsdfuaccess.cpp

@@ -564,12 +564,12 @@ class DFUAccessTests : public CppUnit::TestFixture
         CPPUNIT_TEST(testDaFsStreamingGrouped);
         CPPUNIT_TEST(testDaFsStreamingCompressedAndGrouped);
         CPPUNIT_TEST(testFinish);
-   CPPUNIT_TEST_SUITE_END();
+    CPPUNIT_TEST_SUITE_END();
 
-   unsigned serverPort = DAFILESRV_PORT+1; // do not use standard port, which if in a URL will be converted to local path if IP is local
-   StringBuffer basePath;
-   Owned<CSimpleInterface> serverThread;
-   Owned<IFileDescriptor> fileDesc;
+    static unsigned serverPort;
+    StringBuffer basePath;
+    Owned<CSimpleInterface> serverThread;
+    Owned<IFileDescriptor> fileDesc;
 protected:
     void testStartServer()
     {
@@ -769,9 +769,15 @@ protected:
     }
 };
 
+/* MP_START_PORT -> MP_END_PORT is the MP reserved dynamic port range, and is used here for convenience.
+ * MP_START_PORT is used as starting point to find an available port for the temporary dafilesrv service in these unittests.
+ * All (MP) components using this range always check and find an unused port.
+ */
+unsigned DFUAccessTests::serverPort = MP_START_PORT;
+
+
 CPPUNIT_TEST_SUITE_REGISTRATION( DFUAccessTests );
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DFUAccessTests, "DFUAccessTests" );
 
 
 #endif // _USE_CPPUNIT
-

+ 5 - 1
fs/dafsserver/dafsserver.cpp

@@ -4776,7 +4776,11 @@ int setDaliServerTrace(byte flags)
 #include "unittests.hpp"
 #include "rmtfile.hpp"
 
-static unsigned serverPort = DAFILESRV_PORT+1; // do not use standard port, which if in a URL will be converted to local parth if IP is local
+/* MP_START_PORT -> MP_END_PORT is the MP reserved dynamic port range, and is used here for convenience.
+ * MP_START_PORT is used as starting point to find an available port for the temporary dafilesrv service in these unittests.
+ * All (MP) components using this range always check and find an unused port.
+ */
+static unsigned serverPort = MP_START_PORT;
 static StringBuffer basePath;
 static Owned<CSimpleInterface> serverThread;