1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
//go:build !integration
// +build !integration
package ssh
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"gitlab.com/gitlab-org/gitlab-runner/common"
"gitlab.com/gitlab-org/gitlab-runner/executors"
sshHelpers "gitlab.com/gitlab-org/gitlab-runner/helpers/ssh"
)
var (
executorOptions = executors.ExecutorOptions{
SharedBuildsDir: false,
DefaultBuildsDir: "builds",
DefaultCacheDir: "cache",
Shell: common.ShellScriptInfo{
Shell: "bash",
Type: common.NormalShell,
RunnerCommand: "/usr/bin/gitlab-runner-helper",
},
ShowHostname: true,
}
)
func TestPrepare(t *testing.T) {
runnerConfig := &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "ssh",
SSH: &sshHelpers.Config{User: "user", Password: "pass", Host: "127.0.0.1"},
},
}
build := &common.Build{
JobResponse: common.JobResponse{
GitInfo: common.GitInfo{
Sha: "1234567890",
},
},
Runner: &common.RunnerConfig{},
}
sshConfig := runnerConfig.RunnerSettings.SSH
server, err := sshHelpers.NewStubServer(sshConfig.User, sshConfig.Password)
assert.NoError(t, err)
defer server.Stop()
sshConfig.Port = server.Port()
e := &executor{
AbstractExecutor: executors.AbstractExecutor{
ExecutorOptions: executorOptions,
},
}
prepareOptions := common.ExecutorPrepareOptions{
Config: runnerConfig,
Build: build,
Context: context.TODO(),
}
err = e.Prepare(prepareOptions)
assert.NoError(t, err)
}
func TestSharedEnv(t *testing.T) {
provider := common.GetExecutorProvider("ssh")
features := &common.FeaturesInfo{}
_ = provider.GetFeatures(features)
assert.True(t, features.Shared)
}
|