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

Exposes nex node up to Darwin #280

Merged
merged 11 commits into from
Jun 14, 2024
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
28 changes: 14 additions & 14 deletions .github/workflows/ltb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
Expand All @@ -51,37 +51,37 @@ jobs:
name: Build agent
working-directory: ./agent/cmd/nex-agent
run: go build -tags netgo -ldflags '-extldflags "-static"'
-
name: Run unit tests
if: runner.os != 'Windows'
-
name: Run test suite
working-directory: .
run: |
if: runner.os == 'Linux'
run: |
go test $(go list ./... | grep -v spec)

go test -v -race $(go list ./... | grep -v spec)
-
name: Run spec suite
name: Run spec suite | Linux
working-directory: .
if: runner.os != 'Windows'
if: runner.os == 'Linux'
run: |
go install github.com/onsi/ginkgo/v2/[email protected]
go mod tidy
sudo $(go env GOPATH)/bin/ginkgo -r --randomize-all --randomize-suites --vv --trace --keep-going --output-interceptor-mode=none ./spec
-
name: Run spec suite
name: Run spec suite | Windows
working-directory: .
if: runner.os == 'Windows'
run: |
go install github.com/onsi/ginkgo/v2/[email protected]
go mod tidy
go run github.com/onsi/ginkgo/v2/ginkgo -r --randomize-all --randomize-suites --flake-attempts=5 --vv --trace --keep-going --output-interceptor-mode=none ./spec

-
name: Run test suite
name: Run spec suite | Darwin
working-directory: .
if: runner.os != 'Windows'
if: runner.os == 'macOS'
run: |
mv spec _spec
go test -v -race ./...
go install github.com/onsi/ginkgo/v2/[email protected]
go mod tidy
sudo $(go env GOPATH)/bin/ginkgo -r --randomize-all --randomize-suites --vv --trace --keep-going --output-interceptor-mode=none ./spec

build:
timeout-minutes: 10
Expand Down
4 changes: 2 additions & 2 deletions internal/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func LoadNodeConfiguration(configFilepath string) (*models.NodeConfiguration, er
config.WorkloadTypes = []controlapi.NexWorkload{controlapi.NexWorkloadNative}
}

if strings.EqualFold(runtime.GOOS, "windows") && !config.NoSandbox {
return nil, errors.New("windows host must be configured to run in no sandbox mode")
if (strings.EqualFold(runtime.GOOS, "windows") || strings.EqualFold(runtime.GOOS, "darwin")) && !config.NoSandbox {
return nil, errors.New("host must be configured to run in no sandbox mode")
}

if config.KernelFilepath == "" && config.DefaultResourceDir != "" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build linux || darwin

package nexnode

Expand Down
6 changes: 3 additions & 3 deletions internal/node/prereq.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ type fileSpec struct {
// and required prerequisites are automatically installed to configured paths
// if they are otherwise missing when paired with config.ForceDepInstall.
func CheckPrerequisites(config *models.NodeConfiguration, noninteractive bool, logger *slog.Logger) error {
if strings.EqualFold(runtime.GOOS, "windows") {
if strings.EqualFold(runtime.GOOS, "windows") || strings.EqualFold(runtime.GOOS, "darwin") {
if !config.NoSandbox {
fmt.Print("\t⛔ Windows host must be configured to run in no sandbox mode\n")
return errors.New("windows host must be configured to run in no sandbox mode")
fmt.Print("\t⛔ Host must be configured to run in no sandbox mode\n")
return errors.New("host must be configured to run in no sandbox mode")
}

if !noninteractive {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows || darwin

package processmanager

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build linux || darwin

package processmanager

Expand Down
2 changes: 0 additions & 2 deletions internal/node/processmanager/spawn_procman_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build windows

package processmanager

import (
Expand Down
2 changes: 0 additions & 2 deletions nex/node.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build linux || windows

package main

import (
Expand Down
23 changes: 0 additions & 23 deletions nex/node_darwin.go

This file was deleted.

61 changes: 48 additions & 13 deletions spec/node_windows_test.go → spec/node_nofc_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows
//go:build windows || darwin

package spec

Expand All @@ -13,6 +13,7 @@ import (
"os/signal"
"path"
"path/filepath"
"runtime"
"strings"
"sync"
"syscall"
Expand Down Expand Up @@ -70,14 +71,25 @@ var _ = Describe("nex node", func() {
})

snapshotAgentRootFSPathOnce.Do(func() {
// require the nex-agent binary to be built... FIXME-- build it here insteaad of relying on the Taskfile
_, err := os.Stat(filepath.Join("..", "agent", "cmd", "nex-agent", "nex-agent.exe"))
Expect(err).To(BeNil())
// require the nex-agent binary to be built... FIXME-- build it here instead of relying on the Taskfile
switch runtime.GOOS {
case "windows":
_, err := os.Stat(filepath.Join("..", "agent", "cmd", "nex-agent", "nex-agent.exe"))
Expect(err).To(BeNil())
case "darwin":
_, err := os.Stat(filepath.Join("..", "agent", "cmd", "nex-agent", "nex-agent"))
Expect(err).To(BeNil())
}

agentPath, err := filepath.Abs(filepath.Join("..", "agent", "cmd", "nex-agent"))
Expect(err).To(BeNil())

_ = os.Setenv("PATH", fmt.Sprintf("%s;%s", os.Getenv("PATH"), agentPath))
switch runtime.GOOS {
case "windows":
_ = os.Setenv("PATH", fmt.Sprintf("%s;%s", os.Getenv("PATH"), agentPath))
case "darwin":
_ = os.Setenv("PATH", fmt.Sprintf("%s:%s", os.Getenv("PATH"), agentPath))
}
})
})

Expand All @@ -90,8 +102,14 @@ var _ = Describe("nex node", func() {
})

It("should not return an error", func(ctx SpecContext) {
err := nexnode.CmdPreflight(opts, nodeOpts, ctxx, cancel, log)
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("open %s: The system cannot find the file specified", nodeOpts.ConfigFilepath)))
switch runtime.GOOS {
case "windows":
err := nexnode.CmdPreflight(opts, nodeOpts, ctxx, cancel, log)
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("open %s: The system cannot find the file specified", nodeOpts.ConfigFilepath)))
case "darwin":
err := nexnode.CmdPreflight(opts, nodeOpts, ctxx, cancel, log)
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("failed to load configuration file: open %s: no such file or directory", nodeOpts.ConfigFilepath)))
}
})
})

Expand Down Expand Up @@ -155,7 +173,7 @@ var _ = Describe("nex node", func() {
It("should return an error", func(ctx SpecContext) {
err := nexnode.CmdPreflight(opts, nodeOpts, ctxx, cancel, log)
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(ContainSubstring("windows host must be configured to run in no sandbox mode"))
Expect(err.Error()).To(ContainSubstring("host must be configured to run in no sandbox mode"))
})
})
})
Expand All @@ -172,8 +190,14 @@ var _ = Describe("nex node", func() {

It("should return an error", func(ctx SpecContext) {
err := nexnode.CmdUp(opts, nodeOpts, ctxx, cancel, nodeKey, log)
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("open %s: The system cannot find the file specified", nodeOpts.ConfigFilepath)))
switch runtime.GOOS {
case "windows":
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("open %s: The system cannot find the file specified", nodeOpts.ConfigFilepath)))
case "darwin":
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("failed to initialize node: failed to create node: open %s: no such file or directory", nodeOpts.ConfigFilepath)))
}
})
})

Expand Down Expand Up @@ -334,12 +358,23 @@ var _ = Describe("nex node", func() {
var err error

AfterEach(func() {
os.Remove("./echoservice.exe")
switch runtime.GOOS {
case "windows":
os.Remove("./echoservice.exe")
case "darwin":
os.Remove("./echoservice")
}
})

JustBeforeEach(func() {
deployRequest, err = newDeployRequest(*nodeID, "echoservice", "nex example echoservice", "./echoservice.exe", map[string]string{"NATS_URL": "nats://127.0.0.1:4222"}, []string{}, log)
Expect(err).To(BeNil())
switch runtime.GOOS {
case "windows":
deployRequest, err = newDeployRequest(*nodeID, "echoservice", "nex example echoservice", "./echoservice.exe", map[string]string{"NATS_URL": "nats://127.0.0.1:4222"}, []string{}, log)
Expect(err).To(BeNil())
case "darwin":
deployRequest, err = newDeployRequest(*nodeID, "echoservice", "nex example echoservice", "./echoservice", map[string]string{"NATS_URL": "nats://127.0.0.1:4222"}, []string{}, log)
Expect(err).To(BeNil())
}

nodeClient := controlapi.NewApiClientWithNamespace(_fixtures.natsConn, time.Millisecond*1000, "default", log)
_, err = nodeClient.StartWorkload(deployRequest)
Expand Down
Loading