Update runner testdata
This commit is contained in:
parent
62630004c2
commit
21938bf0b2
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/hashicorp/vagrant/internal/core"
|
||||
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
|
||||
serverptypes "github.com/hashicorp/vagrant/internal/server/ptypes"
|
||||
"github.com/hashicorp/vagrant/internal/server/singleprocess"
|
||||
@ -32,8 +33,8 @@ func TestRunnerAccept(t *testing.T) {
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
require.NoError(runner.Start())
|
||||
|
||||
// Initialize our app
|
||||
singleprocess.TestApp(t, client, serverptypes.TestJobNew(t, nil).Application)
|
||||
// Initialize our basis
|
||||
core.TestBasis(t)
|
||||
|
||||
// Queue a job
|
||||
queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
@ -60,8 +61,8 @@ func TestRunnerAccept_cancelContext(t *testing.T) {
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
require.NoError(runner.Start())
|
||||
|
||||
// Initialize our app
|
||||
singleprocess.TestApp(t, client, serverptypes.TestJobNew(t, nil).Application)
|
||||
// Initialize our basis
|
||||
core.TestBasis(t)
|
||||
|
||||
// Set a blocker
|
||||
noopCh := make(chan struct{})
|
||||
@ -98,8 +99,8 @@ func TestRunnerAccept_cancelJob(t *testing.T) {
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
require.NoError(runner.Start())
|
||||
|
||||
// Initialize our app
|
||||
singleprocess.TestApp(t, client, serverptypes.TestJobNew(t, nil).Application)
|
||||
// Initialize our basis
|
||||
core.TestBasis(t)
|
||||
|
||||
// Set a blocker
|
||||
noopCh := make(chan struct{})
|
||||
@ -149,8 +150,8 @@ func TestRunnerAccept_gitData(t *testing.T) {
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
require.NoError(runner.Start())
|
||||
|
||||
// Initialize our app
|
||||
singleprocess.TestApp(t, client, serverptypes.TestJobNew(t, nil).Application)
|
||||
// Initialize our basis
|
||||
core.TestBasis(t)
|
||||
|
||||
// Queue a job
|
||||
queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
|
||||
@ -99,7 +99,8 @@ func (r *Runner) executeJob(
|
||||
|
||||
// Determine the evaluation context we'll be using
|
||||
log.Trace("reading configuration", "path", path)
|
||||
cfg, err := configpkg.Load(path, filepath.Dir(path))
|
||||
pppp := filepath.Dir(path)
|
||||
cfg, err := configpkg.Load(path, pppp)
|
||||
if err != nil {
|
||||
log.Warn("failed here trying to read configuration", "path", path)
|
||||
cfg = &configpkg.Config{}
|
||||
|
||||
@ -1,8 +1 @@
|
||||
Fixes
|
||||
# Please enter the commit message for your changes. Lines starting
|
||||
# with '#' will be ignored, and an empty message aborts the commit.
|
||||
#
|
||||
# On branch master
|
||||
# Changes to be committed:
|
||||
# modified: vagrant.hcl
|
||||
#
|
||||
Add Vagrantfile for testing
|
||||
|
||||
BIN
internal/runner/testdata/git-noop/DOTgit/index
vendored
BIN
internal/runner/testdata/git-noop/DOTgit/index
vendored
Binary file not shown.
@ -1,2 +1,3 @@
|
||||
0000000000000000000000000000000000000000 1924b8606e1d56acb7e2059652ad059d4bac6f2e Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1597721732 -0700 commit (initial): Initial commit
|
||||
1924b8606e1d56acb7e2059652ad059d4bac6f2e b6bf15100c570f2be6a231a095d395ed16dfed81 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1597722255 -0700 commit: Fixes
|
||||
b6bf15100c570f2be6a231a095d395ed16dfed81 cfa0599445d5025a7798f8949c83da3899e953df sophia <scastellarin95@gmail.com> 1626733782 -0500 commit: Add Vagrantfile for testing
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
0000000000000000000000000000000000000000 1924b8606e1d56acb7e2059652ad059d4bac6f2e Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1597721732 -0700 commit (initial): Initial commit
|
||||
1924b8606e1d56acb7e2059652ad059d4bac6f2e b6bf15100c570f2be6a231a095d395ed16dfed81 Mitchell Hashimoto <mitchell.hashimoto@gmail.com> 1597722255 -0700 commit: Fixes
|
||||
b6bf15100c570f2be6a231a095d395ed16dfed81 cfa0599445d5025a7798f8949c83da3899e953df sophia <scastellarin95@gmail.com> 1626733782 -0500 commit: Add Vagrantfile for testing
|
||||
|
||||
BIN
internal/runner/testdata/git-noop/DOTgit/objects/b4/50d3da13b8f241226fca12ce3450b783d7038c
vendored
Normal file
BIN
internal/runner/testdata/git-noop/DOTgit/objects/b4/50d3da13b8f241226fca12ce3450b783d7038c
vendored
Normal file
Binary file not shown.
BIN
internal/runner/testdata/git-noop/DOTgit/objects/cf/a0599445d5025a7798f8949c83da3899e953df
vendored
Normal file
BIN
internal/runner/testdata/git-noop/DOTgit/objects/cf/a0599445d5025a7798f8949c83da3899e953df
vendored
Normal file
Binary file not shown.
BIN
internal/runner/testdata/git-noop/DOTgit/objects/ea/2549d66602a0a588e69f033c48944de5b7a45c
vendored
Normal file
BIN
internal/runner/testdata/git-noop/DOTgit/objects/ea/2549d66602a0a588e69f033c48944de5b7a45c
vendored
Normal file
Binary file not shown.
@ -1 +1 @@
|
||||
b6bf15100c570f2be6a231a095d395ed16dfed81
|
||||
cfa0599445d5025a7798f8949c83da3899e953df
|
||||
|
||||
3
internal/runner/testdata/git-noop/Vagrantfile
vendored
Normal file
3
internal/runner/testdata/git-noop/Vagrantfile
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "hashicorp/bionic64"
|
||||
end
|
||||
@ -1,54 +1,92 @@
|
||||
package runner
|
||||
|
||||
// import (
|
||||
// "io/ioutil"
|
||||
// "os"
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
// "github.com/mitchellh/go-testing-interface"
|
||||
// "github.com/stretchr/testify/require"
|
||||
"github.com/mitchellh/go-testing-interface"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
// configpkg "github.com/hashicorp/vagrant/internal/config"
|
||||
// "github.com/hashicorp/vagrant/internal/server/singleprocess"
|
||||
// )
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
configpkg "github.com/hashicorp/vagrant/internal/config"
|
||||
"github.com/hashicorp/vagrant/internal/server/singleprocess"
|
||||
"github.com/hashicorp/vagrant/internal/serverclient"
|
||||
)
|
||||
|
||||
// // TestRunner returns an initialized runner pointing to an in-memory test
|
||||
// // server. This will close automatically on test completion.
|
||||
// //
|
||||
// // This will also change the working directory to a temporary directory
|
||||
// // so that any side effect file creation doesn't impact the real working
|
||||
// // directory. If you need to use your working directory, query it before
|
||||
// // calling this.
|
||||
// func TestRunner(t testing.T, opts ...Option) *Runner {
|
||||
// require := require.New(t)
|
||||
// client := singleprocess.TestServer(t)
|
||||
// TestRunner returns an initialized runner pointing to an in-memory test
|
||||
// server. This will close automatically on test completion.
|
||||
//
|
||||
// This will also change the working directory to a temporary directory
|
||||
// so that any side effect file creation doesn't impact the real working
|
||||
// directory. If you need to use your working directory, query it before
|
||||
// calling this.
|
||||
func TestRunner(t testing.T, opts ...Option) *Runner {
|
||||
require := require.New(t)
|
||||
client := singleprocess.TestServer(t)
|
||||
rubyRunTime, err := TestRunnerVagrantRubyRuntime()
|
||||
|
||||
// // Initialize our runner
|
||||
// runner, err := New(append([]Option{
|
||||
// WithClient(client),
|
||||
// }, opts...)...)
|
||||
// require.NoError(err)
|
||||
// t.Cleanup(func() { runner.Close() })
|
||||
// Initialize our runner
|
||||
runner, err := New(append([]Option{
|
||||
WithClient(client),
|
||||
WithVagrantRubyRuntime(rubyRunTime),
|
||||
}, opts...)...)
|
||||
require.NoError(err)
|
||||
t.Cleanup(func() { runner.Close() })
|
||||
|
||||
// // Move into a temporary directory
|
||||
// td := testTempDir(t)
|
||||
// testChdir(t, td)
|
||||
// Move into a temporary directory
|
||||
td := testTempDir(t)
|
||||
testChdir(t, td)
|
||||
|
||||
// // Create a valid vagrant configuration file
|
||||
// configpkg.TestConfigFile(t, configpkg.TestSource(t))
|
||||
// Create a valid vagrant configuration file
|
||||
configpkg.TestConfigFile(t, configpkg.TestSource(t))
|
||||
|
||||
// return runner
|
||||
// }
|
||||
return runner
|
||||
}
|
||||
|
||||
// func testChdir(t testing.T, dir string) {
|
||||
// pwd, err := os.Getwd()
|
||||
// require.NoError(t, err)
|
||||
// require.NoError(t, os.Chdir(dir))
|
||||
// t.Cleanup(func() { require.NoError(t, os.Chdir(pwd)) })
|
||||
// }
|
||||
func TestRunnerVagrantRubyRuntime() (rubyRuntime plugin.ClientProtocol, err error) {
|
||||
// TODO: Update for actual release usage. This is dev only now.
|
||||
// TODO: We should also locate a free port on startup and use that port
|
||||
_, this_dir, _, _ := runtime.Caller(0)
|
||||
cmd := exec.Command(
|
||||
"bundle", "exec", "vagrant", "serve",
|
||||
)
|
||||
cmd.Env = []string{
|
||||
"BUNDLE_GEMFILE=" + filepath.Join(this_dir, "../../..", "Gemfile"),
|
||||
"VAGRANT_I_KNOW_WHAT_IM_DOING_PLEASE_BE_QUIET=true",
|
||||
"VAGRANT_LOG=debug",
|
||||
"VAGRANT_LOG_FILE=/tmp/vagrant.log",
|
||||
}
|
||||
|
||||
// func testTempDir(t testing.T) string {
|
||||
// dir, err := ioutil.TempDir("", "vagrant-test")
|
||||
// require.NoError(t, err)
|
||||
// t.Cleanup(func() { os.RemoveAll(dir) })
|
||||
// return dir
|
||||
// }
|
||||
config := serverclient.RubyVagrantPluginConfig(hclog.New(&hclog.LoggerOptions{Level: hclog.Trace}))
|
||||
config.Cmd = cmd
|
||||
c := plugin.NewClient(config)
|
||||
if _, err = c.Start(); err != nil {
|
||||
return
|
||||
}
|
||||
if rubyRuntime, err = c.Client(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure the plugin is halted when the basis is cleaned up
|
||||
// b.cleanup(func() { rubyRuntime.Close() })
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func testChdir(t testing.T, dir string) {
|
||||
pwd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, os.Chdir(dir))
|
||||
t.Cleanup(func() { require.NoError(t, os.Chdir(pwd)) })
|
||||
}
|
||||
|
||||
func testTempDir(t testing.T) string {
|
||||
dir, err := ioutil.TempDir("", "vagrant-test")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { os.RemoveAll(dir) })
|
||||
return dir
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user