Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
version_format: "${major}.${minor}.${patch}-${{ env.BRANCH_NAME }}${increment}"
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- run: make test-integration-docker
name: Run integration tests inside Docker
- run: make test
name: Unit tests
- run: make build
name: Build
- run: make test-integration-docker
name: Run integration tests inside Docker
- run: make build-plugins
name: Build Plugins
- name: Prerelease
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"go.buildTags": "integration",
"go.testTags": "integration"
}
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,24 @@ mock:
mockgen -source=internal/core/ports/services_ports.go -destination test/mock/services.go

test:
go test -v ./test
go test -v ./...

test_clean:
test-clean:
go clean -testcache
go test -v ./test

test-docker:
docker build . -f Dockerfile.testing -t druid-cli-test
docker run -v ./:/app --entrypoint=/bin/bash --rm druid-cli-test -c "go test -v ./..."


test-integration:
go test -timeout 1200s -v ./test/integration
go test -timeout 1200s -tags=integration ./test/integration

test-integration-docker:
docker build . -f Dockerfile.testing -t druid-cli-test
docker run -v ./:/app --entrypoint=/bin/bash --rm druid-cli-test -c "go test -timeout 1200s -v ./test/integration"
docker run -v ./:/app --entrypoint=/bin/bash --rm druid-cli-test -c "go test -timeout 1200s -v ./test/integration/commands"
docker run -v ./:/app --entrypoint=/bin/bash --rm druid-cli-test -c "go test -timeout 1200s -tags=integration -v ./test/integration"
docker run -v ./:/app --entrypoint=/bin/bash --rm druid-cli-test -c "go test -timeout 1200s -tags=integration -v ./test/integration/commands"

test-integration-docker-debug:
docker build . -f Dockerfile.testing -t druid-cli-test
Expand Down
2 changes: 1 addition & 1 deletion debug/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ func main() {

println("done")
<-cmdCtx.Done()
println("exit " + string(cmd.ProcessState.ExitCode()))
println(fmt.Sprintf("exit %d", cmd.ProcessState.ExitCode()))
}
1 change: 1 addition & 0 deletions internal/core/domain/queue_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package domain

type QueueItem struct {
Status ScrollLockStatus
Error error
UpdateLockStatus bool
RunAfterExecution func()
}
2 changes: 2 additions & 0 deletions internal/core/services/log_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func NewLogManager() *LogManager {
}

func (hm *LogManager) AddLine(stream string, line []byte) {

println("log: " + string(line))
if _, ok := hm.Streams[stream]; !ok {
hm.Streams[stream] = NewLog(100)
}
Expand Down
22 changes: 16 additions & 6 deletions internal/core/services/process_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func (po *ProcessManager) Run(commandName string, command []string, dir string)
zap.String("dir", dir),
)

println("Starting process", commandName, name, args, dir)

process.Cmd = exec.Command(name, args...)
process.Cmd.Dir = dir

Expand Down Expand Up @@ -177,6 +179,7 @@ func (po *ProcessManager) Run(commandName string, command []string, dir string)
for scanner.Scan() {
text := scanner.Text()
logger.Log().Debug(text)
println(text)
combinedChannel <- text + "\n"
}
}()
Expand All @@ -189,6 +192,7 @@ func (po *ProcessManager) Run(commandName string, command []string, dir string)
for scanner.Scan() {
text := scanner.Text()
logger.Log().Debug(text)
println(text)
combinedChannel <- text + "\n"
}

Expand All @@ -200,6 +204,7 @@ func (po *ProcessManager) Run(commandName string, command []string, dir string)
err = process.Cmd.Start()

if err != nil {
println("Error starting process", err)
cmdDone()
process.Cmd = nil
return nil, err
Expand All @@ -217,12 +222,17 @@ func (po *ProcessManager) Run(commandName string, command []string, dir string)
//stdReader := io.MultiReader(stdoutReader, stderrReader)

go func() {
_ = process.Cmd.Wait()
wg.Wait()

err := process.Cmd.Wait()
if err != nil {
logger.Log().Error("Error waiting for process", zap.Error(err))
}
cmdDone()

stderrReader.Close()
stdoutReader.Close()
stdin.Close()
//stderrReader.Close()
//stdoutReader.Close()
//stdin.Close()
}()

<-cmdCtx.Done()
Expand All @@ -231,9 +241,9 @@ func (po *ProcessManager) Run(commandName string, command []string, dir string)
po.RemoveProcess(commandName)
// Wait for goroutine to print everything (watchdog closes stdin)
exitCode := process.Cmd.ProcessState.ExitCode()
console.MarkExited(exitCode)

wg.Wait()
println("Exit code", exitCode)
console.MarkExited(exitCode)

close(combinedChannel)
//we wait, sothat we are sure all data is written to the console
Expand Down
35 changes: 33 additions & 2 deletions internal/core/services/queue_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (sc *QueueManager) RunQueue() {
}()
err := sc.workItem(c)
if err != nil {
sc.setStatus(c, domain.ScrollLockStatusError, i.UpdateLockStatus)
sc.setError(c, err, i.UpdateLockStatus)
logger.Log().Error("Error running command", zap.String("command", c), zap.Error(err))
return
}
Expand Down Expand Up @@ -342,7 +342,14 @@ func (sc *QueueManager) Shutdown() {
func (sc *QueueManager) WaitUntilEmpty() {
notifier := make(chan []string)
sc.notifierChan = append(sc.notifierChan, notifier)

println("WaitUntilEmpty")
for k, n := range sc.commandQueue {
if n.Status == domain.ScrollLockStatusError {
println(k + "---: " + string(n.Status) + " " + n.Error.Error())
} else {
println(k + "---: " + string(n.Status))
}
}
for {
cmds := <-notifier
if len(cmds) == 0 {
Expand All @@ -353,9 +360,17 @@ func (sc *QueueManager) WaitUntilEmpty() {
break
}
}
for k, n := range sc.commandQueue {
if n.Status == domain.ScrollLockStatusError {
println(k + ": " + string(n.Status) + " " + n.Error.Error())
} else {
println(k + ": " + string(n.Status))
}
}
return
}
}

}

func (sc *QueueManager) GetQueueItem(cmd string) *domain.QueueItem {
Expand All @@ -378,6 +393,22 @@ func (sc *QueueManager) getStatus(cmd string) domain.ScrollLockStatus {
return domain.ScrollLockStatusDone
}

func (sc *QueueManager) setError(cmd string, err error, writeLock bool) {
sc.mu.Lock()
defer sc.mu.Unlock()
if value, ok := sc.commandQueue[cmd]; ok {
value.Status = domain.ScrollLockStatusError
value.Error = err
}
if writeLock {
lock, err := sc.scrollService.GetLock()
if err != nil {
return
}
lock.SetStatus(cmd, domain.ScrollLockStatusError, nil)
}
}

func (sc *QueueManager) setStatus(cmd string, status domain.ScrollLockStatus, writeLock bool) {
sc.mu.Lock()
defer sc.mu.Unlock()
Expand Down
Loading