Skip to content

Commit

Permalink
fix run dag (#1339)
Browse files Browse the repository at this point in the history
* fix run dag

* add test

* fix test
  • Loading branch information
sunkickr authored Aug 3, 2023
1 parent abde86f commit ccb6ef2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion airflow/docker_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ func (d *DockerImage) Run(dagID, envFile, settingsFile, containerName, dagFile,
if settingsFileExist {
cmdArgs = append(cmdArgs, []string{"./" + settingsFile}...)
}
args = append(args, cmdArgs...)

if executionDate != "" {
cmdArgs = append(cmdArgs, []string{"--execution-date", executionDate}...)
Expand All @@ -498,6 +497,8 @@ func (d *DockerImage) Run(dagID, envFile, settingsFile, containerName, dagFile,

fmt.Println("\nStarting a DAG run for " + dagID + "...")
fmt.Println("\nLoading DAGs...")
log.Debug("args passed to docker command:")
log.Debug(args)

cmdErr := cmdExec(dockerCommand, stdout, stderr, args...)
// add back later fmt.Println("\nSee the output of this command for errors. To view task logs, use the '--task-logs' flag.")
Expand Down
17 changes: 17 additions & 0 deletions airflow/docker_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package airflow
import (
"bytes"
"errors"
"fmt"
"io"
"os"
"testing"
Expand Down Expand Up @@ -547,6 +548,7 @@ func TestUseBash(t *testing.T) {
}

func TestDockerImageRun(t *testing.T) {
testUtil.InitTestConfig(testUtil.LocalPlatform)
handler := DockerImage{
imageName: "testing",
}
Expand All @@ -562,6 +564,21 @@ func TestDockerImageRun(t *testing.T) {

t.Run("run success without container", func(t *testing.T) {
cmdExec = func(cmd string, stdout, stderr io.Writer, args ...string) error {
if args[0] == "run" {
expectedArgs := []string{
"run_dag",
"./dags/", "",
"./", "--verbose",
}
for i := 0; i < 5; i++ {
if expectedArgs[i] != args[i+15] {
fmt.Println(args[i+15])
fmt.Println(expectedArgs[i])
return errMock // Elements from index 0 to 4 in slice1 are not equal to elements from index 5 to 9 in slice2
}
}
}

return nil
}

Expand Down

0 comments on commit ccb6ef2

Please sign in to comment.