Beispiel #1
0
func (p *plugin) kill(wg *sync.WaitGroup) error {
	defer wg.Done()
	if p.IsProcessRunning() {
		defer p.connection.Close()
		conn.SendProcessKillMessage(p.connection)

		exited := make(chan bool, 1)
		go func() {
			for {
				if p.IsProcessRunning() {
					time.Sleep(100 * time.Millisecond)
				} else {
					exited <- true
					return
				}
			}
		}()
		select {
		case done := <-exited:
			if done {
				logger.Debug("Plugin [%s] with pid [%d] has exited", p.descriptor.Name, p.pluginCmd.Process.Pid)
			}
		case <-time.After(config.PluginConnectionTimeout()):
			logger.Warning("Plugin [%s] with pid [%d] did not exit after %.2f seconds. Forcefully killing it.", p.descriptor.Name, p.pluginCmd.Process.Pid, config.PluginConnectionTimeout().Seconds())
			err := p.pluginCmd.Process.Kill()
			if err != nil {
				logger.Warning("Error while killing plugin %s : %s ", p.descriptor.Name, err.Error())
			}
			return err
		}
	}
	return nil
}
Beispiel #2
0
func (testRunner *TestRunner) Kill() error {
	if testRunner.IsProcessRunning() {
		defer testRunner.Connection.Close()
		conn.SendProcessKillMessage(testRunner.Connection)

		exited := make(chan bool, 1)
		go func() {
			for {
				if testRunner.IsProcessRunning() {
					time.Sleep(100 * time.Millisecond)
				} else {
					exited <- true
					return
				}
			}
		}()

		select {
		case done := <-exited:
			if done {
				return nil
			}
		case <-time.After(config.PluginKillTimeout()):
			logger.Warning("Killing runner with PID:%d forcefully", testRunner.Cmd.Process.Pid)
			return testRunner.killRunner()
		}
	}
	return nil
}
Beispiel #3
0
func InstallPluginZip(zipFile string, pluginName string) {
	if err := installPluginFromZip(zipFile, pluginName); err != nil {
		logger.Warning("Failed to install plugin. Invalid zip file : %s\n", err)
	} else {
		logger.Info("Successfully installed plugin from file.")
	}
}
Beispiel #4
0
func (plugin *plugin) kill(wg *sync.WaitGroup) error {
	defer wg.Done()
	if plugin.isStillRunning() {

		exited := make(chan bool, 1)
		go func() {
			for {
				if plugin.isStillRunning() {
					time.Sleep(100 * time.Millisecond)
				} else {
					exited <- true
					return
				}
			}
		}()

		select {
		case done := <-exited:
			if done {
				logger.Debug("Plugin [%s] with pid [%d] has exited", plugin.descriptor.Name, plugin.pluginCmd.Process.Pid)
			}
		case <-time.After(config.PluginConnectionTimeout()):
			logger.Warning("Plugin [%s] with pid [%d] did not exit after %.2f seconds. Forcefully killing it.", plugin.descriptor.Name, plugin.pluginCmd.Process.Pid, config.PluginConnectionTimeout().Seconds())
			return plugin.pluginCmd.Process.Kill()
		}
	}
	return nil
}
Beispiel #5
0
func downloadAndInstall(plugin, version string, successMessage string) error {
	result := InstallPlugin(plugin, version)
	if !result.Success {
		return fmt.Errorf("%s : %s\n", plugin, result.getMessage())
	}
	if result.Warning != "" {
		logger.Warning(result.Warning)
		return nil
	}
	logger.Info(successMessage)
	return nil
}
Beispiel #6
0
func AddConcepts(conceptFile string, conceptDictionary *ConceptDictionary) *ParseError {
	concepts, parseResults := new(ConceptParser).ParseFile(conceptFile)
	if parseResults != nil && parseResults.Warnings != nil {
		for _, warning := range parseResults.Warnings {
			logger.Warning(warning.String())
		}
	}
	if parseResults != nil && parseResults.Error != nil {
		return parseResults.Error
	}
	return conceptDictionary.Add(concepts, conceptFile)
}
Beispiel #7
0
func printRefactoringSummary(refactoringResult *refactoringResult) {
	exitCode := 0
	if !refactoringResult.Success {
		exitCode = 1
		for _, err := range refactoringResult.Errors {
			logger.Errorf("%s \n", err)
		}
	}
	for _, warning := range refactoringResult.warnings {
		logger.Warning("%s \n", warning)
	}
	logger.Info("%d specifications changed.\n", len(refactoringResult.specsChanged))
	logger.Info("%d concepts changed.\n", len(refactoringResult.conceptsChanged))
	logger.Info("%d files in code changed.\n", len(refactoringResult.runnerFilesChanged))
	os.Exit(exitCode)
}
Beispiel #8
0
func HandleParseResult(results ...*ParseResult) {
	var failed = false
	for _, result := range results {
		if !result.Ok {
			logger.Error(result.Error())
			failed = true
		}
		if result.Warnings != nil {
			for _, warning := range result.Warnings {
				logger.Warning("%s : %v", result.FileName, warning)
			}
		}
	}
	if failed {
		os.Exit(1)
	}
}
Beispiel #9
0
// HandleUpdateResult handles the result of plugin Installation
func HandleUpdateResult(result InstallResult, pluginName string, exitIfFailure bool) bool {
	if result.Warning != "" {
		logger.Warning(result.Warning)
	}
	if result.Skipped {
		return true
	}
	if !result.Success {
		logger.Errorf("Failed to update plugin '%s'.\nReason: %s", pluginName, result.getMessage())
		if exitIfFailure {
			os.Exit(1)
		}
		return false
	}
	logger.Info("Successfully updated plugin '%s'.", pluginName)
	return true
}
Beispiel #10
0
func AddConcepts(conceptFile string, conceptDictionary *gauge.ConceptDictionary) *ParseError {
	concepts, parseResults := new(ConceptParser).ParseFile(conceptFile)
	if parseResults != nil && parseResults.Warnings != nil {
		for _, warning := range parseResults.Warnings {
			logger.Warning(warning.String())
		}
	}
	if parseResults != nil && parseResults.Error != nil {
		return parseResults.Error
	}
	for _, conceptStep := range concepts {
		if _, exists := conceptDictionary.ConceptsMap[conceptStep.Value]; exists {
			return &ParseError{Message: "Duplicate concept definition found", LineNo: conceptStep.LineNo, LineText: conceptStep.LineText}
		}
		conceptDictionary.ReplaceNestedConceptSteps(conceptStep)
		conceptDictionary.ConceptsMap[conceptStep.Value] = &gauge.Concept{conceptStep, conceptFile}
	}
	conceptDictionary.UpdateLookupForNestedConcepts()
	return validateConcepts(conceptDictionary)
}
Beispiel #11
0
// Remove removes all the files and directories recursively for the given path
func Remove(dir string) {
	err := common.Remove(dir)
	if err != nil {
		logger.Warning("Failed to remove directory %s. Remove it manually. %s", dir, err.Error())
	}
}