Exemple #1
0
func StartRunnerAndMakeConnection(manifest *manifest.Manifest, log *logger.GaugeLogger, killChannel chan bool) (*TestRunner, error) {
	port, err := conn.GetPortFromEnvironmentVariable(common.GaugePortEnvName)
	if err != nil {
		port = 0
	}
	gaugeConnectionHandler, connHandlerErr := conn.NewGaugeConnectionHandler(port, nil)
	if connHandlerErr != nil {
		return nil, connHandlerErr
	}
	testRunner, err := startRunner(manifest, strconv.Itoa(gaugeConnectionHandler.ConnectionPortNumber()), log, killChannel)
	if err != nil {
		return nil, err
	}

	runnerConnection, connectionError := gaugeConnectionHandler.AcceptConnection(config.RunnerConnectionTimeout(), testRunner.ErrorChannel)
	testRunner.Connection = runnerConnection
	if connectionError != nil {
		log.Debug("Runner connection error: %s", connectionError)
		err := testRunner.killRunner()
		if err != nil {
			log.Debug("Error while killing runner: %s", err)
		}
		return nil, connectionError
	}
	return testRunner, nil
}
Exemple #2
0
func waitAndGetErrorMessage(errChannel chan error, cmd *exec.Cmd, log *logger.GaugeLogger) {
	go func() {
		err := cmd.Wait()
		if err != nil {
			log.Debug("Runner exited with error: %s", err)
			errChannel <- errors.New(fmt.Sprintf("Runner exited with error: %s\n", err.Error()))
		}
	}()
}