private void HandleConsoleMessage(ElasticsearchConsoleOut consoleOut, XplatManualResetEvent handle)
        {
            //no need to snoop for metadata if we already started
            if (!this._config.RunIntegrationTests || this.Started)
            {
                return;
            }
            //if we are running on CI and not started dump elasticsearch stdout/err
            //before the started notification to help debug failures to start
            if (this.RunningOnCI && !this.Started)
            {
                if (consoleOut.Error)
                {
                    Console.Error.WriteLine(consoleOut.Data);
                }
                else
                {
                    Console.WriteLine(consoleOut.Data);
                }
            }

            if (consoleOut.Error && !this.Started && !string.IsNullOrWhiteSpace(consoleOut.Data))
            {
                throw new Exception(consoleOut.Data);
            }

            string version;
            int?   pid;
            int    port;

            if (this.ProcessId == null && consoleOut.TryParseNodeInfo(out version, out pid))
            {
                var startedVersion = ElasticsearchVersion.GetOrAdd(version);
                this.ProcessId = pid;
                if (this.Version != startedVersion)
                {
                    throw new Exception($"Booted elasticsearch is version {startedVersion} but the test config dictates {this.Version}");
                }
            }
            else if (consoleOut.TryGetPortNumber(out port))
            {
                this.Port = port;
            }
            else if (consoleOut.TryGetStartedConfirmation())
            {
                this.Started = true;
                handle.Set();
            }
        }
Ejemplo n.º 2
0
        private void HandleConsoleMessage(ElasticsearchConsoleOut consoleOut, XplatManualResetEvent handle)
        {
            Console.WriteLine(consoleOut.Data);
            //no need to snoop for metadata if we already started
            if (!this._config.RunIntegrationTests || this.Started)
            {
                return;
            }

            if (consoleOut.Error && !this.Started && !string.IsNullOrWhiteSpace(consoleOut.Data))
            {
                throw new Exception("Error out:" + consoleOut.Data);
            }

            string version;
            int?   pid;
            int    port;

            if (this.ProcessId == null && consoleOut.TryParseNodeInfo(out version, out pid))
            {
                var startedVersion = new ElasticsearchVersion(version);
                this.ProcessId = pid;
                if (this.Version != startedVersion)
                {
                    throw new Exception($"Booted elasticsearch is version {startedVersion} but the test config dictates {this.Version}");
                }
            }
            else if (consoleOut.TryGetPortNumber(out port))
            {
                this.Port = port;
            }
            else if (consoleOut.TryGetStartedConfirmation())
            {
                this.Started = true;
                handle.Set();
            }
        }