-
Notifications
You must be signed in to change notification settings - Fork 131
RSDK-13980: Enable cli windows tests #6022
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
base: main
Are you sure you want to change the base?
Changes from 17 commits
00e9d60
779741a
8fcd488
c7c20e3
e63c51d
36bad1a
0548b63
19cc0dc
4fe1149
e0e8f7e
34ca37c
5b09200
40d4025
1fab8bc
47e91d7
7cd39ac
d0ebc74
6622778
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ import ( | |
| commonpb "go.viam.com/api/common/v1" | ||
| "go.viam.com/test" | ||
| "go.viam.com/utils/protoutils" | ||
| "go.viam.com/utils/rpc" | ||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/codes" | ||
| "google.golang.org/grpc/status" | ||
|
|
@@ -38,6 +39,7 @@ import ( | |
| robotconfig "go.viam.com/rdk/config" | ||
| "go.viam.com/rdk/logging" | ||
| "go.viam.com/rdk/resource" | ||
| "go.viam.com/rdk/robot/client" | ||
| robotimpl "go.viam.com/rdk/robot/impl" | ||
| "go.viam.com/rdk/services/shell" | ||
| _ "go.viam.com/rdk/services/shell/register" | ||
|
|
@@ -220,6 +222,12 @@ func setupWithRunningPart( | |
| ac.baseURL, _, err = utils.ParseBaseURL(ac.conf.BaseURL, false) | ||
| test.That(t, err, test.ShouldBeNil) | ||
|
|
||
| ac.dialOverride = func(ctx context.Context, fqdn string, rpcOpts []rpc.DialOption, logger logging.Logger) (*client.RobotClient, error) { | ||
| return client.New(ctx, addr, logger, | ||
| client.WithDialOptions(append(rpcOpts, rpc.WithForceDirectGRPC())...), | ||
| ) | ||
| } | ||
|
|
||
| t.Cleanup(func() { | ||
| test.That(t, r.Close(context.Background()), test.ShouldBeNil) | ||
| }) | ||
|
|
@@ -635,7 +643,7 @@ func TestDataExportTabularAction(t *testing.T) { | |
| // Test that the data.ndjson file was removed. | ||
| filePath := utils.ResolveFile(dataFileName) | ||
| _, err = os.ReadFile(filePath) | ||
| test.That(t, err, test.ShouldBeError, fmt.Errorf("open %s: no such file or directory", filePath)) | ||
| test.That(t, errors.Is(err, fs.ErrNotExist), test.ShouldBeTrue) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. windows has slightly diff error string, so just check errNotExist instead of specific string |
||
| }) | ||
| } | ||
|
|
||
|
|
@@ -975,6 +983,9 @@ func TestMachinesPartHistoryAction(t *testing.T) { | |
| } | ||
|
|
||
| func TestShellFileCopy(t *testing.T) { | ||
| if runtime.GOOS == "windows" { | ||
| t.Skip("RSDK-11617") | ||
| } | ||
| logger := logging.NewTestLogger(t) | ||
|
|
||
| listOrganizationsFunc := func(ctx context.Context, in *apppb.ListOrganizationsRequest, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |
| "io" | ||
| "os" | ||
| "path/filepath" | ||
| "runtime" | ||
| "sort" | ||
| "strings" | ||
| "testing" | ||
|
|
@@ -265,23 +266,25 @@ func TestLocalBuild(t *testing.T) { | |
| testDir := t.TempDir() | ||
| testChdir(t, testDir) | ||
|
|
||
| // write manifest and setup.sh | ||
| // the manifest contains a: | ||
| // "setup": "./setup.sh" | ||
| // and a "build": "make build" | ||
| manifestPath := createTestManifest(t, "", nil) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default test manifest is set up for mac, need windows specifics like .bat instead of .sh |
||
| err := os.WriteFile( | ||
| filepath.Join(testDir, "setup.sh"), | ||
| []byte("echo setup step msg"), | ||
| 0o700, | ||
| ) | ||
| setupScriptCmd, setupFile, setupContent := "./setup.sh", "setup.sh", "echo setup step msg" | ||
| buildCmd, buildFile, buildContent := "make build", "Makefile", "make build:\n\techo build step msg" | ||
| if runtime.GOOS == "windows" { | ||
| setupScriptCmd, setupFile, setupContent = "setup.bat", "setup.bat", "@echo setup step msg" | ||
| buildCmd, buildFile, buildContent = "build.bat", "build.bat", "@echo build step msg" | ||
| } | ||
|
|
||
| manifestPath := createTestManifest(t, "", map[string]any{ | ||
| "build": map[string]any{ | ||
| "setup": setupScriptCmd, | ||
| "build": buildCmd, | ||
| "path": "module", | ||
| "arch": []any{"linux/amd64"}, | ||
| }, | ||
| }) | ||
| err := os.WriteFile(filepath.Join(testDir, setupFile), []byte(setupContent), 0o700) | ||
| test.That(t, err, test.ShouldBeNil) | ||
|
|
||
| err = os.WriteFile( | ||
| filepath.Join(testDir, "Makefile"), | ||
| []byte("make build:\n\techo build step msg"), | ||
| 0o700, | ||
| ) | ||
| err = os.WriteFile(filepath.Join(testDir, buildFile), []byte(buildContent), 0o700) | ||
| test.That(t, err, test.ShouldBeNil) | ||
|
|
||
| // run the build local action | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -885,6 +885,7 @@ func writeManifest(manifestPath string, manifest ModuleManifest) error { | |
| if err != nil { | ||
| return errors.Wrapf(err, "failed to create %s", manifestPath) | ||
| } | ||
| defer func() { vutils.UncheckedError(manifestFile.Close()) }() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on windows, all open files need to be explicitly closed |
||
| if _, err := manifestFile.Write(manifestBytes); err != nil { | ||
| return errors.Wrapf(err, "failed to write manifest to %s", manifestPath) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,7 +267,7 @@ func TestGetMarkdownContent(t *testing.T) { | |
| name: "non-existent file", | ||
| filepath: "non_existent_file.md", | ||
| shouldContain: []string{}, | ||
| shouldErrorWith: "failed to read markdown file at non_existent_file.md: open non_existent_file.md: no such file or directory", | ||
| shouldErrorWith: "failed to read markdown file at non_existent_file.md: open non_existent_file.md:", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. windows different error string |
||
| totalChars: 0, | ||
| }, | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -379,6 +379,7 @@ func TestResolvePartId(t *testing.T) { | |
| test.That(t, err, test.ShouldBeNil) | ||
| _, err = fi.WriteString(`{"cloud":{"app_address":"https://app.viam.com:443","id":"JSON-PART","secret":"SECRET"}}`) | ||
| test.That(t, err, test.ShouldBeNil) | ||
| test.That(t, fi.Close(), test.ShouldBeNil) | ||
| partID, err = resolvePartID(c.String(generalFlagPartID), path) | ||
| test.That(t, err, test.ShouldBeNil) | ||
| test.That(t, partID, test.ShouldEqual, "JSON-PART") | ||
|
|
@@ -399,7 +400,9 @@ func TestMutateModuleConfig(t *testing.T) { | |
| } | ||
| expectedName := "viam-labs_test-module_from_reload" | ||
| expectedVersion := "latest-with-prerelease" | ||
| remoteReloadPath := ".viam/packages-local/viam-labs_test-module_from_reload-module.tar.gz" | ||
| expectedEntrypoint, err := filepath.Abs(manifest.Entrypoint) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. forward slash issues on windows |
||
| test.That(t, err, test.ShouldBeNil) | ||
| remoteReloadPath := filepath.Join(".viam", "packages-local", "viam-labs_test-module_from_reload-module.tar.gz") | ||
| testUser := "test@viam.com" | ||
| testReloadUnixTS := time.Date(2024, 3, 18, 12, 0, 0, 0, time.UTC).Unix() | ||
|
|
||
|
|
@@ -448,7 +451,7 @@ func TestMutateModuleConfig(t *testing.T) { | |
| test.That(t, err, test.ShouldBeNil) | ||
| test.That(t, dirty, test.ShouldBeTrue) | ||
| test.That(t, needsRestart, test.ShouldBeFalse) | ||
| test.That(t, modules[0]["reload_path"], test.ShouldEqual, manifest.Entrypoint) | ||
| test.That(t, modules[0]["reload_path"], test.ShouldEqual, expectedEntrypoint) | ||
| test.That(t, modules[0]["reload_enabled"], test.ShouldBeTrue) | ||
| test.That(t, modules[0]["reload_user"], test.ShouldEqual, testUser) | ||
| test.That(t, modules[0]["reload_time"], test.ShouldNotBeEmpty) | ||
|
|
@@ -464,7 +467,7 @@ func TestMutateModuleConfig(t *testing.T) { | |
| test.That(t, err, test.ShouldBeNil) | ||
| test.That(t, dirty, test.ShouldBeTrue) | ||
| test.That(t, needsRestart, test.ShouldBeFalse) | ||
| test.That(t, modules[0]["reload_path"], test.ShouldEqual, manifest.Entrypoint) | ||
| test.That(t, modules[0]["reload_path"], test.ShouldEqual, expectedEntrypoint) | ||
| test.That(t, modules[0]["reload_enabled"], test.ShouldBeTrue) | ||
| test.That(t, modules[0]["reload_user"], test.ShouldEqual, testUser) | ||
| test.That(t, modules[0]["reload_time"], test.ShouldNotBeEmpty) | ||
|
|
@@ -475,7 +478,7 @@ func TestMutateModuleConfig(t *testing.T) { | |
| modules, _, _, _ = mutateModuleConfig(c, modules, manifest, true, false, testUser, "", testReloadUnixTS) | ||
| test.That(t, modules[0]["module_id"], test.ShouldEqual, manifest.ModuleID) | ||
| test.That(t, modules[0]["name"], test.ShouldEqual, expectedName) | ||
| test.That(t, modules[0]["reload_path"], test.ShouldEqual, manifest.Entrypoint) | ||
| test.That(t, modules[0]["reload_path"], test.ShouldEqual, expectedEntrypoint) | ||
| test.That(t, modules[0]["reload_enabled"], test.ShouldBeTrue) | ||
| test.That(t, modules[0]["version"], test.ShouldEqual, expectedVersion) | ||
| test.That(t, modules[0]["reload_user"], test.ShouldEqual, testUser) | ||
|
|
@@ -490,7 +493,7 @@ func TestMutateModuleConfig(t *testing.T) { | |
| }} | ||
| updatedModules, _, _, _ := mutateModuleConfig(c, modules, manifest, true, false, testUser, "", testReloadUnixTS) | ||
| test.That(t, len(updatedModules), test.ShouldEqual, 2) | ||
| test.That(t, updatedModules[1]["reload_path"], test.ShouldEqual, manifest.Entrypoint) | ||
| test.That(t, updatedModules[1]["reload_path"], test.ShouldEqual, expectedEntrypoint) | ||
| test.That(t, updatedModules[1]["reload_enabled"], test.ShouldBeTrue) | ||
| test.That(t, updatedModules[1]["version"], test.ShouldEqual, expectedVersion) | ||
| test.That(t, updatedModules[1]["reload_user"], test.ShouldEqual, testUser) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.md text eol=lf | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Windows GitHub Actions runners default to core.autocrlf=true, which converts LF → CRLF on checkout. CRLF adds 1 byte per line. So a 167-char file checked out on Linux becomes ~171 chars on Windows, and the test fails the byte-count assertions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. windows test will fail without it |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,11 +243,9 @@ func validateOutputWritable(outputPath string) error { | |
| if err != nil { | ||
| return err | ||
| } | ||
| defer func() { | ||
| if closeErr := f.Close(); closeErr != nil { | ||
| err = closeErr | ||
| } | ||
| }() | ||
| if err := f.Close(); err != nil { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to close before removing |
||
| return err | ||
| } | ||
|
|
||
| // Remove empty test file (don't leave artifacts if we just created it) | ||
| if info, statErr := os.Stat(outputPath); statErr == nil && info.Size() == 0 { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestShellFileCopy/from/single_file (540.05s) hangs with
rpc/dial.go:144 trying mDNS {"address":"99823048-4cba-4b40-823e-a26f7362d4a3"}
rpc/server.go:550 mDNS setup failed; continuing with mDNS disabled {"error":"no positive MTU found"}
by adding this, we can skip the mDNS setup that will likely fail on windows and go straight to direct grpc with the actual robot data from the test