mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-04 05:51:25 +02:00
Orchard Controller: implement an SSH server that acts as a jump host (#179)
* proxy.Connections(): require io.ReadWriteCloser instead of net.Conn * Orchard Controller: implement an SSH server that acts as a jump host * Issue a warning if the name used will be invalid in the future * Further restrict uppercase characters in names in the future The rationale is similar to https://github.com/kubernetes/kubernetes/issues/71140. We won't want to munge the user's input and introduce subtle bugs doing lowercase comparisons.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package devcontroller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/cirruslabs/orchard/internal/command/dev"
|
||||
"github.com/cirruslabs/orchard/internal/controller"
|
||||
"github.com/cirruslabs/orchard/internal/worker"
|
||||
"github.com/cirruslabs/orchard/pkg/client"
|
||||
"github.com/stretchr/testify/require"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func StartIntegrationTestEnvironment(t *testing.T) (*client.Client, *controller.Controller, *worker.Worker) {
|
||||
return StartIntegrationTestEnvironmentWithAdditionalOpts(t, nil, nil)
|
||||
}
|
||||
|
||||
func StartIntegrationTestEnvironmentWithAdditionalOpts(
|
||||
t *testing.T,
|
||||
additionalControllerOpts []controller.Option,
|
||||
additionalWorkerOpts []worker.Option,
|
||||
) (*client.Client, *controller.Controller, *worker.Worker) {
|
||||
t.Setenv("ORCHARD_HOME", t.TempDir())
|
||||
|
||||
devController, devWorker, err := dev.CreateDevControllerAndWorker(t.TempDir(),
|
||||
":0", nil, additionalControllerOpts, additionalWorkerOpts)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
_ = devWorker.Close()
|
||||
})
|
||||
|
||||
devContext, cancelDevFunc := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancelDevFunc)
|
||||
|
||||
go func() {
|
||||
err := devController.Run(devContext)
|
||||
if err != nil && !errors.Is(err, context.Canceled) && !errors.Is(err, http.ErrServerClosed) {
|
||||
t.Errorf("dev controller failed: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
err := devWorker.Run(devContext)
|
||||
if err != nil && !errors.Is(err, context.Canceled) {
|
||||
t.Errorf("dev worker failed: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
devClient, err := client.New(client.WithAddress(devController.Address()))
|
||||
require.NoError(t, err)
|
||||
|
||||
return devClient, devController, devWorker
|
||||
}
|
||||
Reference in New Issue
Block a user