Skip to content

Commit b6ad034

Browse files
Update dependencies and err msg (#13)
* Improve error message * Update dependencies * Fix tests
1 parent 69f190e commit b6ad034

File tree

6 files changed

+43
-22
lines changed

6 files changed

+43
-22
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ module go.flow.arcalot.io/pythondeployer
33
go 1.18
44

55
require (
6-
go.arcalot.io/assert v1.3.0
6+
go.arcalot.io/assert v1.4.0
77
go.arcalot.io/lang v1.0.0
88
)
99

1010
require (
11-
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
11+
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
1212
github.com/x448/float16 v0.8.4 // indirect
1313
)
1414

1515
require (
1616
go.arcalot.io/log/v2 v2.0.0
1717
go.flow.arcalot.io/deployer v0.2.0
18-
go.flow.arcalot.io/pluginsdk v0.1.3
18+
go.flow.arcalot.io/pluginsdk v0.4.1
1919
)

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
2-
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
1+
github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE=
2+
github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
33
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
44
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
5-
go.arcalot.io/assert v1.3.0 h1:+uQex4s9gezATpTyFxUY5dlAcrwI1Me5fSmdcydGHho=
6-
go.arcalot.io/assert v1.3.0/go.mod h1:Xy3ScX0p9IMY89gdsgexOKxnmDr0nGHG9dV7p8Uxg7w=
5+
go.arcalot.io/assert v1.4.0 h1:X7ptZSl4WrB+jUn53Kzvp3aPWCSsCgUp4iW2wdLEOv4=
6+
go.arcalot.io/assert v1.4.0/go.mod h1:Xy3ScX0p9IMY89gdsgexOKxnmDr0nGHG9dV7p8Uxg7w=
77
go.arcalot.io/lang v1.0.0 h1:mgDaieT4wWdZTnR4V7+/pgYRmzfU7VZZgIzHccuxAbY=
88
go.arcalot.io/lang v1.0.0/go.mod h1:ALqfYEhAzC2WoGLaycmJoNJd5NmkR7V1PSKp/c5D278=
99
go.arcalot.io/log/v2 v2.0.0 h1:mbmsWDVBXZNWrDzUh5JLzeGCQ59kTuMFs+pyfJGc1hk=
1010
go.arcalot.io/log/v2 v2.0.0/go.mod h1:1V8jnFIIGwh2CtcGkHNOmy1nCo7LbazQNkUcnKYNMn4=
1111
go.flow.arcalot.io/deployer v0.2.0 h1:CpkCYlB8NfpmELIEPdw3/al8XknCSfD/L2vie2lJBJo=
1212
go.flow.arcalot.io/deployer v0.2.0/go.mod h1:xVSB+svHVPmX6yTZIU0K4U/pDbs+rezsWa69vYA+E6k=
13-
go.flow.arcalot.io/pluginsdk v0.1.3 h1:o6v1YJmirRNcflh9ZQr5bMuhBavk8CzARjrNodU/XHA=
14-
go.flow.arcalot.io/pluginsdk v0.1.3/go.mod h1:ceY4HhUbnhZyQa3C7lXu25TNVCbsWGuYZapsV5RuIrk=
13+
go.flow.arcalot.io/pluginsdk v0.4.1 h1:sooyHRNCH/EIQJe+842qZJAgXHuffclFbc3hPMgbhCc=
14+
go.flow.arcalot.io/pluginsdk v0.4.1/go.mod h1:8Gp8Q0Eo0s+2I4nNl3uQ95jPi2zFKEX7JqyjhmK7BiI=
1515
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

internal/cliwrapper/cliwrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (p *cliWrapper) Deploy(fullModuleName string) (io.WriteCloser, io.ReadClose
161161

162162
func (p *cliWrapper) KillAndClean() error {
163163
if p.stdErrBuff.Len() > 0 {
164-
p.logger.Errorf("stderr present after plugin execution: %s", p.stdErrBuff.String())
164+
p.logger.Errorf("stderr present after plugin execution: '%s'", p.stdErrBuff.String())
165165
} else {
166166
p.logger.Infof("stderr empty")
167167
}

tests/cliwrapper_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package tests
22

33
import (
44
"fmt"
5-
"go.flow.arcalot.io/pythondeployer/internal/cliwrapper"
65
"go.arcalot.io/assert"
76
"go.arcalot.io/log/v2"
8-
"os/exec"
7+
"go.flow.arcalot.io/pythondeployer/internal/cliwrapper"
98
"testing"
109
)
1110

1211
func TestPullImage(t *testing.T) {
1312
module := "arcaflow-plugin-template-python@git+https://github.com/arcalot/arcaflow-plugin-template-python.git"
1413
workDir := createWorkdir(t)
15-
pythonPath, err := exec.LookPath("python")
14+
15+
pythonPath, err := getPythonPath()
1616
assert.NoError(t, err)
1717
logger := log.NewTestLogger(t)
1818
python := cliwrapper.NewCliWrapper(pythonPath, workDir, logger)
@@ -26,7 +26,7 @@ func TestPullImage(t *testing.T) {
2626
func TestImageExists(t *testing.T) {
2727
module := "arcaflow-plugin-template-python@git+https://github.com/arcalot/arcaflow-plugin-template-python.git"
2828
workDir := createWorkdir(t)
29-
pythonPath, err := exec.LookPath("python")
29+
pythonPath, err := getPythonPath()
3030
assert.NoError(t, err)
3131
logger := log.NewTestLogger(t)
3232
python := cliwrapper.NewCliWrapper(pythonPath, workDir, logger)
@@ -50,7 +50,7 @@ func TestImageFormatValidation(t *testing.T) {
5050
moduleWrongFormat := "https://arcalot.io"
5151
wrongFormatMessage := "wrong module name format, please use <module-name>@git+<repo_url>[@<commit_sha>]"
5252
workDir := createWorkdir(t)
53-
pythonPath, err := exec.LookPath("python")
53+
pythonPath, err := getPythonPath()
5454
assert.NoError(t, err)
5555
logger := log.NewTestLogger(t)
5656
wrapperGit := cliwrapper.NewCliWrapper(pythonPath, workDir, logger)

tests/connector_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"go.arcalot.io/assert"
77
"go.flow.arcalot.io/deployer"
88
"go.flow.arcalot.io/pluginsdk/atp"
9+
"go.flow.arcalot.io/pluginsdk/schema"
910
"os"
1011
"testing"
1112
)
@@ -87,8 +88,6 @@ func RunStep(t *testing.T, connector deployer.Connector, moduleName string) (*st
8788
stepID := "hello-world"
8889
input := map[string]any{"name": templatePluginInput}
8990

90-
ctx, cancel := context.WithCancel(context.Background())
91-
defer cancel()
9291
plugin, err := connector.Deploy(context.Background(), moduleName)
9392

9493
if err != nil {
@@ -112,7 +111,13 @@ func RunStep(t *testing.T, connector deployer.Connector, moduleName string) (*st
112111
assert.NoError(t, err)
113112

114113
// Executes the step and validates that the output is correct.
115-
outputID, outputData, err := atpClient.Execute(ctx, stepID, input)
114+
receivedSignals := make(chan schema.Input)
115+
emittedSignals := make(chan schema.Input)
116+
outputID, outputData, err := atpClient.Execute(
117+
schema.Input{ID: stepID, InputData: input},
118+
receivedSignals,
119+
emittedSignals,
120+
)
116121
return &outputID, outputData, err
117122

118123
}

tests/test_common.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,30 @@ package tests
33
import (
44
"encoding/json"
55
"fmt"
6-
pythondeployer "go.flow.arcalot.io/pythondeployer"
7-
wrapper "go.flow.arcalot.io/pythondeployer/internal/cliwrapper"
8-
"go.flow.arcalot.io/pythondeployer/internal/config"
96
"go.arcalot.io/assert"
107
"go.arcalot.io/log/v2"
118
"go.flow.arcalot.io/deployer"
9+
pythondeployer "go.flow.arcalot.io/pythondeployer"
10+
wrapper "go.flow.arcalot.io/pythondeployer/internal/cliwrapper"
11+
"go.flow.arcalot.io/pythondeployer/internal/config"
1212
"math/rand"
1313
"os"
14+
"os/exec"
1415
"testing"
1516
)
1617

18+
func getPythonPath() (string, error) {
19+
python3Path, errPython3 := exec.LookPath("python3")
20+
if errPython3 != nil {
21+
pythonPath, errPython := exec.LookPath("python")
22+
if errPython != nil {
23+
return "", fmt.Errorf("error getting Python3 (%s) and python (%s)", errPython3, errPython)
24+
}
25+
return pythonPath, nil
26+
}
27+
return python3Path, nil
28+
}
29+
1730
func createWorkdir(t *testing.T) string {
1831
workdir := fmt.Sprintf("/tmp/%s", randString(10))
1932
if _, err := os.Stat(workdir); !os.IsNotExist(err) {
@@ -52,7 +65,7 @@ func pullModule(python wrapper.CliWrapper, module string, workDir string, t *tes
5265
}
5366

5467
func getCliWrapper(t *testing.T, workdir string) wrapper.CliWrapper {
55-
workDir := workdir
68+
workDir := workdir
5669
pythonPath := "/usr/bin/python3.9"
5770
logger := log.NewTestLogger(t)
5871
return wrapper.NewCliWrapper(pythonPath, workDir, logger)
@@ -67,6 +80,9 @@ func getConnector(t *testing.T, configJSON string, workdir *string) (deployer.Co
6780
schema := factory.ConfigurationSchema()
6881
unserializedConfig, err := schema.UnserializeType(serializedConfig)
6982
assert.NoError(t, err)
83+
pythonPath, err := getPythonPath()
84+
assert.NoError(t, err)
85+
unserializedConfig.PythonPath = pythonPath
7086
// NOTE: randomizing Workdir to avoid parallel tests to
7187
// remove python folders while other tests are running
7288
// causing the test to fail

0 commit comments

Comments
 (0)