コード例 #1
0
ファイル: Common.cs プロジェクト: unitysir/UA-.NETStandard
        public static async Task <GlobalDiscoveryTestServer> StartGDS(bool clean)
        {
            GlobalDiscoveryTestServer server = null;
            Random random = new Random();
            int    testPort;
            bool   retryStartServer   = false;
            int    serverStartRetries = 10;

            do
            {
                try
                {
                    // work around travis issue by selecting different ports on every run
                    testPort = random.Next(50000, 60000);
                    server   = new GlobalDiscoveryTestServer(true);
                    await server.StartServer(clean, testPort);
                }
                catch (ServiceResultException sre)
                {
                    serverStartRetries--;
                    if (serverStartRetries == 0 ||
                        sre.StatusCode != StatusCodes.BadNoCommunication)
                    {
                        throw;
                    }
                    retryStartServer = true;
                }
                await Task.Delay(1000);
            } while (retryStartServer);

            return(server);
        }
コード例 #2
0
ファイル: PushTest.cs プロジェクト: yongwuhou/UA-.NETStandard
        protected async Task OneTimeSetUp()
        {
            // make sure all servers started in travis use a different port, or test will fail
            int testPort = 50000 + (((Int32)DateTime.UtcNow.ToFileTimeUtc() / 10000) & 0x1fff);

            _serverCapabilities = new ServerCapabilities();
            _randomSource       = new RandomSource(randomStart);
            _dataGenerator      = new DataGenerator(_randomSource);
            _server             = new GlobalDiscoveryTestServer(true);
            await _server.StartServer(true, testPort);

            await Task.Delay(1000);

            // load clients
            _gdsClient = new GlobalDiscoveryTestClient(true);
            await _gdsClient.LoadClientConfiguration(testPort);

            _pushClient = new ServerConfigurationPushTestClient(true);
            await _pushClient.LoadClientConfiguration(testPort);

            // connect once
            await _gdsClient.GDSClient.Connect(_gdsClient.GDSClient.EndpointUrl);

            await _pushClient.PushClient.Connect(_pushClient.PushClient.EndpointUrl);

            ConnectGDSClient(true);
            RegisterPushServerApplication(_pushClient.PushClient.EndpointUrl);

            _selfSignedServerCert = new X509Certificate2(_pushClient.PushClient.Session.ConfiguredEndpoint.Description.ServerCertificate);
            _domainNames          = Utils.GetDomainsFromCertficate(_selfSignedServerCert).ToArray();

            CreateCATestCerts(_pushClient.TempStorePath);
        }
コード例 #3
0
ファイル: Common.cs プロジェクト: jh-isw/UA-.NETStandard
        public static async Task <GlobalDiscoveryTestServer> StartGDS(bool clean)
        {
            GlobalDiscoveryTestServer server = null;
            int  testPort           = ServerFixtureUtils.GetNextFreeIPPort();
            bool retryStartServer   = false;
            int  serverStartRetries = 25;

            do
            {
                try
                {
                    server = new GlobalDiscoveryTestServer(true);
                    await server.StartServer(clean, testPort).ConfigureAwait(false);
                }
                catch (ServiceResultException sre)
                {
                    serverStartRetries--;
                    testPort = s_random.Next(ServerFixtureUtils.MinTestPort, ServerFixtureUtils.MaxTestPort);
                    if (serverStartRetries == 0 ||
                        sre.StatusCode != StatusCodes.BadNoCommunication)
                    {
                        throw;
                    }
                    retryStartServer = true;
                }
                await Task.Delay(s_random.Next(100, 1000)).ConfigureAwait(false);
            } while (retryStartServer);

            return(server);
        }
コード例 #4
0
ファイル: ClientTest.cs プロジェクト: zhcngu/UA-.NETStandard
        protected void OneTimeSetUp()
        {
            // work around travis issue by selecting different ports on every run
            int testPort = 50000 + (((Int32)DateTime.UtcNow.ToFileTimeUtc() / 10000) & 0x1fff);

            _server = new GlobalDiscoveryTestServer(true);
            _server.StartServer(true, testPort).Wait();

            // load client
            _gdsClient = new GlobalDiscoveryTestClient(true);
            _gdsClient.LoadClientConfiguration(testPort).Wait();

            // good applications test set
            _appTestDataGenerator      = new ApplicationTestDataGenerator(1);
            _goodApplicationTestSet    = _appTestDataGenerator.ApplicationTestSet(goodApplicationsTestCount, false);
            _invalidApplicationTestSet = _appTestDataGenerator.ApplicationTestSet(invalidApplicationsTestCount, true);

            _goodRegistrationOk      = false;
            _invalidRegistrationOk   = false;
            _goodNewKeyPairRequestOk = false;
        }