Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move exec-agent/process -> core/process #5184

Merged
merged 1 commit into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions agents/go-agents/core/activity/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
const threshold int64 = 60

var (
// ActivityTrackingEnabled defines whether activity tracking should be used
ActivityTrackingEnabled = false
// Tracker provides workspace activity notification client
Tracker WorkspaceActivityTracker = &NoOpActivityTracker{}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Codenvy, S.A. - initial API and implementation
//

package exec
package process

import (
"time"
Expand Down
16 changes: 9 additions & 7 deletions agents/go-agents/core/process/file_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ func (fl *FileLogger) writeLine(message *LogMessage) {
}

func (fl *FileLogger) doFlush() {
f, err := os.OpenFile(fl.filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
if err != nil {
log.Printf("Couldn't open file '%s' for flushing the buffer. %s \n", fl.filename, err.Error())
} else {
defer closeFile(f)
_, err = fl.buffer.WriteTo(f)
if fl.buffer.Len() > 0 {
f, err := os.OpenFile(fl.filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
if err != nil {
log.Printf("Error appears on flushing data to file '%s'. %s \n", fl.filename, err.Error())
log.Printf("Couldn't open file '%s' for flushing the buffer. %s \n", fl.filename, err.Error())
} else {
defer closeFile(f)
_, err = fl.buffer.WriteTo(f)
if err != nil {
log.Printf("Error appears on flushing data to file '%s'. %s \n", fl.filename, err.Error())
}
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions agents/go-agents/core/process/file_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ import (
"encoding/json"
"io/ioutil"
"log"
"math/rand"
"os"
"testing"
"time"

"github.com/eclipse/che/agents/go-agents/core/process"
)

var alphabet = []byte("abcdefgh123456789")

func TestFileLoggerCreatesFileWhenFileDoesNotExist(t *testing.T) {
filename := os.TempDir() + string(os.PathSeparator) + randomName(10)
defer removeFile(filename)
Expand Down Expand Up @@ -113,15 +110,6 @@ func TestLogsAreFlushedOnClose(t *testing.T) {
failIfDifferent(t, expectedStderr, stderr)
}

func randomName(length int) string {
rand.Seed(time.Now().UnixNano())
bytes := make([]byte, length)
for i := 0; i < length; i++ {
bytes[i] = alphabet[rand.Intn(len(alphabet))]
}
return string(bytes)
}

func removeFile(path string) {
if err := os.Remove(path); err != nil {
log.Printf("Can't remove file %s. Error: %s", path, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Codenvy, S.A. - initial API and implementation
//

package exec
package process

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Codenvy, S.A. - initial API and implementation
//

package exec_test
package process_test

import (
"fmt"
Expand All @@ -18,14 +18,14 @@ import (
"os"
"testing"

"github.com/eclipse/che/agents/go-agents/exec-agent/exec"
"github.com/eclipse/che/agents/go-agents/core/process"
)

func TestLogsDistributorCreatesSubdirectories(t *testing.T) {
baseDir := os.TempDir() + string(os.PathSeparator) + randomName(10)
defer removeAll(baseDir)

distributor := exec.DefaultLogsDistributor{
distributor := process.DefaultLogsDistributor{
MaxDirsCount: 4,
}

Expand All @@ -45,7 +45,7 @@ func TestLogsDistribution(t *testing.T) {
baseDir := os.TempDir() + string(os.PathSeparator) + randomName(10)
defer removeAll(baseDir)

distributor := exec.DefaultLogsDistributor{
distributor := process.DefaultLogsDistributor{
MaxDirsCount: 4,
}

Expand Down
Loading