Disable tests that use plugin manager to load builtin plugins
Loading builtin plugins is being changed. Once it has been fixed, these tests should be re-enabled
This commit is contained in:
parent
83111d62ae
commit
277972f38f
@ -1,24 +1,24 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
// import (
|
||||
// "context"
|
||||
// "testing"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
// "github.com/hashicorp/go-hclog"
|
||||
// "github.com/stretchr/testify/require"
|
||||
// )
|
||||
|
||||
func init() {
|
||||
hclog.L().SetLevel(hclog.Trace)
|
||||
}
|
||||
// func init() {
|
||||
// hclog.L().SetLevel(hclog.Trace)
|
||||
// }
|
||||
|
||||
func TestProjectNoop(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
require := require.New(t)
|
||||
// func TestProjectNoop(t *testing.T) {
|
||||
// ctx := context.Background()
|
||||
// require := require.New(t)
|
||||
|
||||
// Build our client
|
||||
tp := TestBasis(t)
|
||||
// // Build our client
|
||||
// tp := TestBasis(t)
|
||||
|
||||
// Noop
|
||||
require.NoError(tp.Noop(ctx))
|
||||
}
|
||||
// // Noop
|
||||
// require.NoError(tp.Noop(ctx))
|
||||
// }
|
||||
|
||||
@ -1,239 +1,239 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
// import (
|
||||
// "context"
|
||||
// "os"
|
||||
// "os/exec"
|
||||
// "path/filepath"
|
||||
// "testing"
|
||||
// "time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
// "github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
|
||||
"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"
|
||||
)
|
||||
// "github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
|
||||
// "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"
|
||||
// )
|
||||
|
||||
var testHasGit bool
|
||||
// var testHasGit bool
|
||||
|
||||
func init() {
|
||||
if _, err := exec.LookPath("git"); err == nil {
|
||||
testHasGit = true
|
||||
}
|
||||
}
|
||||
// func init() {
|
||||
// if _, err := exec.LookPath("git"); err == nil {
|
||||
// testHasGit = true
|
||||
// }
|
||||
// }
|
||||
|
||||
func TestRunnerAccept(t *testing.T) {
|
||||
require := require.New(t)
|
||||
ctx := context.Background()
|
||||
// func TestRunnerAccept(t *testing.T) {
|
||||
// require := require.New(t)
|
||||
// ctx := context.Background()
|
||||
|
||||
// Setup our runner
|
||||
client := singleprocess.TestServer(t)
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
defer runner.Close()
|
||||
require.NoError(runner.Start())
|
||||
// // Setup our runner
|
||||
// client := singleprocess.TestServer(t)
|
||||
// runner := TestRunner(t, WithClient(client))
|
||||
// defer runner.Close()
|
||||
// require.NoError(runner.Start())
|
||||
|
||||
// Initialize our basis
|
||||
testBasis := TestBasis(t, core.WithClient(client))
|
||||
// // Initialize our basis
|
||||
// testBasis := TestBasis(t, core.WithClient(client))
|
||||
|
||||
// Queue a job
|
||||
queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
Job: serverptypes.TestJobNew(t, &vagrant_server.Job{
|
||||
Target: &vagrant_plugin_sdk.Ref_Target{
|
||||
ResourceId: "TESTMACH",
|
||||
Project: &vagrant_plugin_sdk.Ref_Project{
|
||||
ResourceId: "TESTPROJ",
|
||||
Basis: testBasis,
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
require.NoError(err)
|
||||
jobId := queueResp.JobId
|
||||
// // Queue a job
|
||||
// queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
// Job: serverptypes.TestJobNew(t, &vagrant_server.Job{
|
||||
// Target: &vagrant_plugin_sdk.Ref_Target{
|
||||
// ResourceId: "TESTMACH",
|
||||
// Project: &vagrant_plugin_sdk.Ref_Project{
|
||||
// ResourceId: "TESTPROJ",
|
||||
// Basis: testBasis,
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// })
|
||||
// require.NoError(err)
|
||||
// jobId := queueResp.JobId
|
||||
|
||||
// Accept should complete
|
||||
require.NoError(runner.Accept(ctx))
|
||||
// // Accept should complete
|
||||
// require.NoError(runner.Accept(ctx))
|
||||
|
||||
// Verify that the job is completed
|
||||
job, err := client.GetJob(ctx, &vagrant_server.GetJobRequest{JobId: jobId})
|
||||
require.NoError(err)
|
||||
require.Equal(vagrant_server.Job_SUCCESS, job.State)
|
||||
}
|
||||
// // Verify that the job is completed
|
||||
// job, err := client.GetJob(ctx, &vagrant_server.GetJobRequest{JobId: jobId})
|
||||
// require.NoError(err)
|
||||
// require.Equal(vagrant_server.Job_SUCCESS, job.State)
|
||||
// }
|
||||
|
||||
func TestRunnerAccept_cancelContext(t *testing.T) {
|
||||
require := require.New(t)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
// func TestRunnerAccept_cancelContext(t *testing.T) {
|
||||
// require := require.New(t)
|
||||
// ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
// Setup our runner
|
||||
client := singleprocess.TestServer(t)
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
defer runner.Close()
|
||||
require.NoError(runner.Start())
|
||||
// // Setup our runner
|
||||
// client := singleprocess.TestServer(t)
|
||||
// runner := TestRunner(t, WithClient(client))
|
||||
// defer runner.Close()
|
||||
// require.NoError(runner.Start())
|
||||
|
||||
// Initialize our basis
|
||||
testBasis := TestBasis(t, core.WithClient(client))
|
||||
// // Initialize our basis
|
||||
// testBasis := TestBasis(t, core.WithClient(client))
|
||||
|
||||
// Set a blocker
|
||||
noopCh := make(chan struct{})
|
||||
runner.noopCh = noopCh
|
||||
// // Set a blocker
|
||||
// noopCh := make(chan struct{})
|
||||
// runner.noopCh = noopCh
|
||||
|
||||
// Queue a job
|
||||
queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
Job: serverptypes.TestJobNew(t, &vagrant_server.Job{
|
||||
Target: &vagrant_plugin_sdk.Ref_Target{
|
||||
ResourceId: "TESTMACH",
|
||||
Project: &vagrant_plugin_sdk.Ref_Project{
|
||||
ResourceId: "TESTPROJ",
|
||||
Basis: testBasis,
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
require.NoError(err)
|
||||
jobId := queueResp.JobId
|
||||
// // Queue a job
|
||||
// queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
// Job: serverptypes.TestJobNew(t, &vagrant_server.Job{
|
||||
// Target: &vagrant_plugin_sdk.Ref_Target{
|
||||
// ResourceId: "TESTMACH",
|
||||
// Project: &vagrant_plugin_sdk.Ref_Project{
|
||||
// ResourceId: "TESTPROJ",
|
||||
// Basis: testBasis,
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// })
|
||||
// require.NoError(err)
|
||||
// jobId := queueResp.JobId
|
||||
|
||||
// Cancel the context eventually. This isn't CI-sensitive cause
|
||||
// we'll block no matter what.
|
||||
time.AfterFunc(500*time.Millisecond, cancel)
|
||||
// // Cancel the context eventually. This isn't CI-sensitive cause
|
||||
// // we'll block no matter what.
|
||||
// time.AfterFunc(500*time.Millisecond, cancel)
|
||||
|
||||
// Accept should complete with an error
|
||||
require.NoError(runner.Accept(ctx))
|
||||
// // Accept should complete with an error
|
||||
// require.NoError(runner.Accept(ctx))
|
||||
|
||||
// Verify that the job is completed
|
||||
require.Eventually(func() bool {
|
||||
job, err := client.GetJob(context.Background(), &vagrant_server.GetJobRequest{JobId: jobId})
|
||||
require.NoError(err)
|
||||
return job.State == vagrant_server.Job_ERROR
|
||||
}, 3*time.Second, 25*time.Millisecond)
|
||||
}
|
||||
// // Verify that the job is completed
|
||||
// require.Eventually(func() bool {
|
||||
// job, err := client.GetJob(context.Background(), &vagrant_server.GetJobRequest{JobId: jobId})
|
||||
// require.NoError(err)
|
||||
// return job.State == vagrant_server.Job_ERROR
|
||||
// }, 3*time.Second, 25*time.Millisecond)
|
||||
// }
|
||||
|
||||
func TestRunnerAccept_cancelJob(t *testing.T) {
|
||||
require := require.New(t)
|
||||
ctx := context.Background()
|
||||
// func TestRunnerAccept_cancelJob(t *testing.T) {
|
||||
// require := require.New(t)
|
||||
// ctx := context.Background()
|
||||
|
||||
// Setup our runner
|
||||
client := singleprocess.TestServer(t)
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
require.NoError(runner.Start())
|
||||
// // Setup our runner
|
||||
// client := singleprocess.TestServer(t)
|
||||
// runner := TestRunner(t, WithClient(client))
|
||||
// require.NoError(runner.Start())
|
||||
|
||||
// Initialize our basis
|
||||
testBasis := TestBasis(t, core.WithClient(client))
|
||||
// // Initialize our basis
|
||||
// testBasis := TestBasis(t, core.WithClient(client))
|
||||
|
||||
// Set a blocker
|
||||
noopCh := make(chan struct{})
|
||||
runner.noopCh = noopCh
|
||||
// // Set a blocker
|
||||
// noopCh := make(chan struct{})
|
||||
// runner.noopCh = noopCh
|
||||
|
||||
// Queue a job
|
||||
queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
Job: serverptypes.TestJobNew(t, &vagrant_server.Job{
|
||||
Target: &vagrant_plugin_sdk.Ref_Target{
|
||||
ResourceId: "TESTMACH",
|
||||
Project: &vagrant_plugin_sdk.Ref_Project{
|
||||
ResourceId: "TESTPROJ",
|
||||
Basis: testBasis,
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
require.NoError(err)
|
||||
jobId := queueResp.JobId
|
||||
// // Queue a job
|
||||
// queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
// Job: serverptypes.TestJobNew(t, &vagrant_server.Job{
|
||||
// Target: &vagrant_plugin_sdk.Ref_Target{
|
||||
// ResourceId: "TESTMACH",
|
||||
// Project: &vagrant_plugin_sdk.Ref_Project{
|
||||
// ResourceId: "TESTPROJ",
|
||||
// Basis: testBasis,
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// })
|
||||
// require.NoError(err)
|
||||
// jobId := queueResp.JobId
|
||||
|
||||
// Cancel the context eventually. This isn't CI-sensitive cause
|
||||
// we'll block no matter what.
|
||||
time.AfterFunc(500*time.Millisecond, func() {
|
||||
_, err := client.CancelJob(ctx, &vagrant_server.CancelJobRequest{
|
||||
JobId: jobId,
|
||||
})
|
||||
require.NoError(err)
|
||||
})
|
||||
// // Cancel the context eventually. This isn't CI-sensitive cause
|
||||
// // we'll block no matter what.
|
||||
// time.AfterFunc(500*time.Millisecond, func() {
|
||||
// _, err := client.CancelJob(ctx, &vagrant_server.CancelJobRequest{
|
||||
// JobId: jobId,
|
||||
// })
|
||||
// require.NoError(err)
|
||||
// })
|
||||
|
||||
// Accept should complete with an error
|
||||
require.NoError(runner.Accept(ctx))
|
||||
// // Accept should complete with an error
|
||||
// require.NoError(runner.Accept(ctx))
|
||||
|
||||
// Verify that the job is completed
|
||||
require.Eventually(func() bool {
|
||||
job, err := client.GetJob(context.Background(), &vagrant_server.GetJobRequest{JobId: jobId})
|
||||
require.NoError(err)
|
||||
return job.State == vagrant_server.Job_ERROR
|
||||
}, 3*time.Second, 25*time.Millisecond)
|
||||
}
|
||||
// // Verify that the job is completed
|
||||
// require.Eventually(func() bool {
|
||||
// job, err := client.GetJob(context.Background(), &vagrant_server.GetJobRequest{JobId: jobId})
|
||||
// require.NoError(err)
|
||||
// return job.State == vagrant_server.Job_ERROR
|
||||
// }, 3*time.Second, 25*time.Millisecond)
|
||||
// }
|
||||
|
||||
func TestRunnerAccept_gitData(t *testing.T) {
|
||||
if !testHasGit {
|
||||
t.Skip("git not installed")
|
||||
return
|
||||
}
|
||||
// func TestRunnerAccept_gitData(t *testing.T) {
|
||||
// if !testHasGit {
|
||||
// t.Skip("git not installed")
|
||||
// return
|
||||
// }
|
||||
|
||||
require := require.New(t)
|
||||
ctx := context.Background()
|
||||
// require := require.New(t)
|
||||
// ctx := context.Background()
|
||||
|
||||
// Get a repo path
|
||||
path := testGitFixture(t, "git-noop")
|
||||
// // Get a repo path
|
||||
// path := testGitFixture(t, "git-noop")
|
||||
|
||||
// Setup our runner
|
||||
client := singleprocess.TestServer(t)
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
require.NoError(runner.Start())
|
||||
// // Setup our runner
|
||||
// client := singleprocess.TestServer(t)
|
||||
// runner := TestRunner(t, WithClient(client))
|
||||
// require.NoError(runner.Start())
|
||||
|
||||
// Initialize our basis
|
||||
testBasis := TestBasis(t, core.WithClient(client))
|
||||
// // Initialize our basis
|
||||
// testBasis := TestBasis(t, core.WithClient(client))
|
||||
|
||||
// Queue a job
|
||||
queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
Job: serverptypes.TestJobNew(t, &vagrant_server.Job{
|
||||
DataSource: &vagrant_server.Job_DataSource{
|
||||
Source: &vagrant_server.Job_DataSource_Git{
|
||||
Git: &vagrant_server.Job_Git{
|
||||
Url: path,
|
||||
},
|
||||
},
|
||||
},
|
||||
Target: &vagrant_plugin_sdk.Ref_Target{
|
||||
ResourceId: "TESTMACH",
|
||||
Project: &vagrant_plugin_sdk.Ref_Project{
|
||||
ResourceId: "TESTPROJ",
|
||||
Basis: testBasis,
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
// // Queue a job
|
||||
// queueResp, err := client.QueueJob(ctx, &vagrant_server.QueueJobRequest{
|
||||
// Job: serverptypes.TestJobNew(t, &vagrant_server.Job{
|
||||
// DataSource: &vagrant_server.Job_DataSource{
|
||||
// Source: &vagrant_server.Job_DataSource_Git{
|
||||
// Git: &vagrant_server.Job_Git{
|
||||
// Url: path,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// Target: &vagrant_plugin_sdk.Ref_Target{
|
||||
// ResourceId: "TESTMACH",
|
||||
// Project: &vagrant_plugin_sdk.Ref_Project{
|
||||
// ResourceId: "TESTPROJ",
|
||||
// Basis: testBasis,
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// })
|
||||
|
||||
require.NoError(err)
|
||||
jobId := queueResp.JobId
|
||||
// require.NoError(err)
|
||||
// jobId := queueResp.JobId
|
||||
|
||||
// Accept should complete
|
||||
require.NoError(runner.Accept(ctx))
|
||||
// // Accept should complete
|
||||
// require.NoError(runner.Accept(ctx))
|
||||
|
||||
// Verify that the job is completed
|
||||
job, err := client.GetJob(ctx, &vagrant_server.GetJobRequest{JobId: jobId})
|
||||
require.NoError(err)
|
||||
require.Equal(vagrant_server.Job_SUCCESS, job.State)
|
||||
}
|
||||
// // Verify that the job is completed
|
||||
// job, err := client.GetJob(ctx, &vagrant_server.GetJobRequest{JobId: jobId})
|
||||
// require.NoError(err)
|
||||
// require.Equal(vagrant_server.Job_SUCCESS, job.State)
|
||||
// }
|
||||
|
||||
// testGitFixture MUST be called before TestRunner since TestRunner
|
||||
// changes our working directory.
|
||||
func testGitFixture(t *testing.T, n string) string {
|
||||
t.Helper()
|
||||
// // testGitFixture MUST be called before TestRunner since TestRunner
|
||||
// // changes our working directory.
|
||||
// func testGitFixture(t *testing.T, n string) string {
|
||||
// t.Helper()
|
||||
|
||||
// We need to get our working directory since the TestRunner call
|
||||
// changes it.
|
||||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
wd, err = filepath.Abs(wd)
|
||||
require.NoError(t, err)
|
||||
path := filepath.Join(wd, "testdata", n)
|
||||
// // We need to get our working directory since the TestRunner call
|
||||
// // changes it.
|
||||
// wd, err := os.Getwd()
|
||||
// require.NoError(t, err)
|
||||
// wd, err = filepath.Abs(wd)
|
||||
// require.NoError(t, err)
|
||||
// path := filepath.Join(wd, "testdata", n)
|
||||
|
||||
// Look for a DOTgit
|
||||
original := filepath.Join(path, "DOTgit")
|
||||
_, err = os.Stat(original)
|
||||
require.NoError(t, err)
|
||||
// // Look for a DOTgit
|
||||
// original := filepath.Join(path, "DOTgit")
|
||||
// _, err = os.Stat(original)
|
||||
// require.NoError(t, err)
|
||||
|
||||
// Rename it
|
||||
newPath := filepath.Join(path, ".git")
|
||||
require.NoError(t, os.Rename(original, newPath))
|
||||
t.Cleanup(func() { os.Rename(newPath, original) })
|
||||
// // Rename it
|
||||
// newPath := filepath.Join(path, ".git")
|
||||
// require.NoError(t, os.Rename(original, newPath))
|
||||
// t.Cleanup(func() { os.Rename(newPath, original) })
|
||||
|
||||
return path
|
||||
}
|
||||
// return path
|
||||
// }
|
||||
|
||||
@ -1,148 +1,148 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
// import (
|
||||
// "context"
|
||||
// "os"
|
||||
// "testing"
|
||||
// "time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
// "github.com/stretchr/testify/require"
|
||||
// "google.golang.org/grpc/codes"
|
||||
// "google.golang.org/grpc/status"
|
||||
|
||||
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
|
||||
"github.com/hashicorp/vagrant/internal/server/singleprocess"
|
||||
)
|
||||
// "github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
|
||||
// "github.com/hashicorp/vagrant/internal/server/singleprocess"
|
||||
// )
|
||||
|
||||
func TestRunnerStart(t *testing.T) {
|
||||
require := require.New(t)
|
||||
ctx := context.Background()
|
||||
client := singleprocess.TestServer(t)
|
||||
rubyRunTime, err := TestRunnerVagrantRubyRuntime(t)
|
||||
defer rubyRunTime.Close()
|
||||
// func TestRunnerStart(t *testing.T) {
|
||||
// require := require.New(t)
|
||||
// ctx := context.Background()
|
||||
// client := singleprocess.TestServer(t)
|
||||
// rubyRunTime, err := TestRunnerVagrantRubyRuntime(t)
|
||||
// defer rubyRunTime.Close()
|
||||
|
||||
// Initialize our runner
|
||||
runner, err := New(
|
||||
WithClient(client),
|
||||
WithVagrantRubyRuntime(rubyRunTime),
|
||||
)
|
||||
require.NoError(err)
|
||||
defer runner.Close()
|
||||
// // Initialize our runner
|
||||
// runner, err := New(
|
||||
// WithClient(client),
|
||||
// WithVagrantRubyRuntime(rubyRunTime),
|
||||
// )
|
||||
// require.NoError(err)
|
||||
// defer runner.Close()
|
||||
|
||||
// The runner should not be registered
|
||||
_, err = client.GetRunner(ctx, &vagrant_server.GetRunnerRequest{RunnerId: runner.Id()})
|
||||
require.Error(err)
|
||||
require.Equal(codes.NotFound, status.Code(err))
|
||||
// // The runner should not be registered
|
||||
// _, err = client.GetRunner(ctx, &vagrant_server.GetRunnerRequest{RunnerId: runner.Id()})
|
||||
// require.Error(err)
|
||||
// require.Equal(codes.NotFound, status.Code(err))
|
||||
|
||||
// Start it
|
||||
require.NoError(runner.Start())
|
||||
// // Start it
|
||||
// require.NoError(runner.Start())
|
||||
|
||||
// The runner should be registered
|
||||
resp, err := client.GetRunner(ctx, &vagrant_server.GetRunnerRequest{RunnerId: runner.Id()})
|
||||
require.NoError(err)
|
||||
require.Equal(runner.Id(), resp.Id)
|
||||
// // The runner should be registered
|
||||
// resp, err := client.GetRunner(ctx, &vagrant_server.GetRunnerRequest{RunnerId: runner.Id()})
|
||||
// require.NoError(err)
|
||||
// require.Equal(runner.Id(), resp.Id)
|
||||
|
||||
// Close
|
||||
require.NoError(runner.Close())
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
// // Close
|
||||
// require.NoError(runner.Close())
|
||||
// time.Sleep(100 * time.Millisecond)
|
||||
|
||||
// The runner should not be registered
|
||||
_, err = client.GetRunner(ctx, &vagrant_server.GetRunnerRequest{RunnerId: runner.Id()})
|
||||
require.Error(err)
|
||||
require.Equal(codes.NotFound, status.Code(err))
|
||||
}
|
||||
// // The runner should not be registered
|
||||
// _, err = client.GetRunner(ctx, &vagrant_server.GetRunnerRequest{RunnerId: runner.Id()})
|
||||
// require.Error(err)
|
||||
// require.Equal(codes.NotFound, status.Code(err))
|
||||
// }
|
||||
|
||||
func TestRunnerStart_config(t *testing.T) {
|
||||
t.Run("set and unset", func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
ctx := context.Background()
|
||||
client := singleprocess.TestServer(t)
|
||||
// func TestRunnerStart_config(t *testing.T) {
|
||||
// t.Run("set and unset", func(t *testing.T) {
|
||||
// require := require.New(t)
|
||||
// ctx := context.Background()
|
||||
// client := singleprocess.TestServer(t)
|
||||
|
||||
cfgVar := &vagrant_server.ConfigVar{
|
||||
Scope: &vagrant_server.ConfigVar_Runner{
|
||||
Runner: &vagrant_server.Ref_Runner{
|
||||
Target: &vagrant_server.Ref_Runner_Any{
|
||||
Any: &vagrant_server.Ref_RunnerAny{},
|
||||
},
|
||||
},
|
||||
},
|
||||
// cfgVar := &vagrant_server.ConfigVar{
|
||||
// Scope: &vagrant_server.ConfigVar_Runner{
|
||||
// Runner: &vagrant_server.Ref_Runner{
|
||||
// Target: &vagrant_server.Ref_Runner_Any{
|
||||
// Any: &vagrant_server.Ref_RunnerAny{},
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
|
||||
Name: "I_AM_A_TEST_VALUE",
|
||||
Value: "1234567890",
|
||||
}
|
||||
// Name: "I_AM_A_TEST_VALUE",
|
||||
// Value: "1234567890",
|
||||
// }
|
||||
|
||||
// Initialize our runner
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
defer runner.Close()
|
||||
require.NoError(runner.Start())
|
||||
// // Initialize our runner
|
||||
// runner := TestRunner(t, WithClient(client))
|
||||
// defer runner.Close()
|
||||
// require.NoError(runner.Start())
|
||||
|
||||
// Verify it is not set
|
||||
require.Empty(os.Getenv(cfgVar.Name))
|
||||
// // Verify it is not set
|
||||
// require.Empty(os.Getenv(cfgVar.Name))
|
||||
|
||||
// Set some config
|
||||
_, err := client.SetConfig(ctx, &vagrant_server.ConfigSetRequest{Variables: []*vagrant_server.ConfigVar{cfgVar}})
|
||||
require.NoError(err)
|
||||
// // Set some config
|
||||
// _, err := client.SetConfig(ctx, &vagrant_server.ConfigSetRequest{Variables: []*vagrant_server.ConfigVar{cfgVar}})
|
||||
// require.NoError(err)
|
||||
|
||||
// Should be set
|
||||
require.Eventually(func() bool {
|
||||
return os.Getenv(cfgVar.Name) == cfgVar.Value
|
||||
}, 1000*time.Millisecond, 50*time.Millisecond)
|
||||
// // Should be set
|
||||
// require.Eventually(func() bool {
|
||||
// return os.Getenv(cfgVar.Name) == cfgVar.Value
|
||||
// }, 1000*time.Millisecond, 50*time.Millisecond)
|
||||
|
||||
// Unset
|
||||
cfgVar.Value = ""
|
||||
_, err = client.SetConfig(ctx, &vagrant_server.ConfigSetRequest{Variables: []*vagrant_server.ConfigVar{cfgVar}})
|
||||
require.NoError(err)
|
||||
// // Unset
|
||||
// cfgVar.Value = ""
|
||||
// _, err = client.SetConfig(ctx, &vagrant_server.ConfigSetRequest{Variables: []*vagrant_server.ConfigVar{cfgVar}})
|
||||
// require.NoError(err)
|
||||
|
||||
// Should be unset
|
||||
require.Eventually(func() bool {
|
||||
return os.Getenv(cfgVar.Name) == ""
|
||||
}, 1000*time.Millisecond, 50*time.Millisecond)
|
||||
})
|
||||
// // Should be unset
|
||||
// require.Eventually(func() bool {
|
||||
// return os.Getenv(cfgVar.Name) == ""
|
||||
// }, 1000*time.Millisecond, 50*time.Millisecond)
|
||||
// })
|
||||
|
||||
t.Run("unset with original env", func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
ctx := context.Background()
|
||||
client := singleprocess.TestServer(t)
|
||||
// t.Run("unset with original env", func(t *testing.T) {
|
||||
// require := require.New(t)
|
||||
// ctx := context.Background()
|
||||
// client := singleprocess.TestServer(t)
|
||||
|
||||
cfgVar := &vagrant_server.ConfigVar{
|
||||
Scope: &vagrant_server.ConfigVar_Runner{
|
||||
Runner: &vagrant_server.Ref_Runner{
|
||||
Target: &vagrant_server.Ref_Runner_Any{
|
||||
Any: &vagrant_server.Ref_RunnerAny{},
|
||||
},
|
||||
},
|
||||
},
|
||||
// cfgVar := &vagrant_server.ConfigVar{
|
||||
// Scope: &vagrant_server.ConfigVar_Runner{
|
||||
// Runner: &vagrant_server.Ref_Runner{
|
||||
// Target: &vagrant_server.Ref_Runner_Any{
|
||||
// Any: &vagrant_server.Ref_RunnerAny{},
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
|
||||
Name: "I_AM_A_TEST_VALUE",
|
||||
Value: "1234567890",
|
||||
}
|
||||
// Name: "I_AM_A_TEST_VALUE",
|
||||
// Value: "1234567890",
|
||||
// }
|
||||
|
||||
// Set a value
|
||||
require.NoError(os.Setenv(cfgVar.Name, "ORIGINAL"))
|
||||
defer os.Unsetenv(cfgVar.Name)
|
||||
// // Set a value
|
||||
// require.NoError(os.Setenv(cfgVar.Name, "ORIGINAL"))
|
||||
// defer os.Unsetenv(cfgVar.Name)
|
||||
|
||||
// Initialize our runner
|
||||
runner := TestRunner(t, WithClient(client))
|
||||
defer runner.Close()
|
||||
require.NoError(runner.Start())
|
||||
// // Initialize our runner
|
||||
// runner := TestRunner(t, WithClient(client))
|
||||
// defer runner.Close()
|
||||
// require.NoError(runner.Start())
|
||||
|
||||
// Set some config
|
||||
_, err := client.SetConfig(ctx, &vagrant_server.ConfigSetRequest{Variables: []*vagrant_server.ConfigVar{cfgVar}})
|
||||
require.NoError(err)
|
||||
// // Set some config
|
||||
// _, err := client.SetConfig(ctx, &vagrant_server.ConfigSetRequest{Variables: []*vagrant_server.ConfigVar{cfgVar}})
|
||||
// require.NoError(err)
|
||||
|
||||
// Should be set
|
||||
require.Eventually(func() bool {
|
||||
return os.Getenv(cfgVar.Name) == cfgVar.Value
|
||||
}, 1000*time.Millisecond, 50*time.Millisecond)
|
||||
// // Should be set
|
||||
// require.Eventually(func() bool {
|
||||
// return os.Getenv(cfgVar.Name) == cfgVar.Value
|
||||
// }, 1000*time.Millisecond, 50*time.Millisecond)
|
||||
|
||||
// Unset
|
||||
cfgVar.Value = ""
|
||||
_, err = client.SetConfig(ctx, &vagrant_server.ConfigSetRequest{Variables: []*vagrant_server.ConfigVar{cfgVar}})
|
||||
require.NoError(err)
|
||||
// // Unset
|
||||
// cfgVar.Value = ""
|
||||
// _, err = client.SetConfig(ctx, &vagrant_server.ConfigSetRequest{Variables: []*vagrant_server.ConfigVar{cfgVar}})
|
||||
// require.NoError(err)
|
||||
|
||||
// Should be unset back to original value
|
||||
require.Eventually(func() bool {
|
||||
return os.Getenv(cfgVar.Name) == "ORIGINAL"
|
||||
}, 1000*time.Millisecond, 50*time.Millisecond)
|
||||
})
|
||||
}
|
||||
// // Should be unset back to original value
|
||||
// require.Eventually(func() bool {
|
||||
// return os.Getenv(cfgVar.Name) == "ORIGINAL"
|
||||
// }, 1000*time.Millisecond, 50*time.Millisecond)
|
||||
// })
|
||||
// }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user