2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-02-10 20:33:16 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/api"
|
|
|
|
"github.com/shoenig/test/must"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPlugins_WhenNotClientSkip(t *testing.T) {
|
|
|
|
s, _, _ := testServer(t, false, nil)
|
|
|
|
must.Nil(t, s.Agent.pluginSingletonLoader)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPlugins_WhenClientRun(t *testing.T) {
|
|
|
|
s, _, _ := testServer(t, true, nil)
|
|
|
|
must.NotNil(t, s.Agent.pluginSingletonLoader)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testServer(t *testing.T, runClient bool, cb func(*Config)) (*TestAgent, *api.Client, string) {
|
|
|
|
// Make a new test server
|
|
|
|
a := NewTestAgent(t, t.Name(), func(config *Config) {
|
|
|
|
config.Client.Enabled = runClient
|
|
|
|
|
|
|
|
if cb != nil {
|
|
|
|
cb(config)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Cleanup(a.Shutdown)
|
|
|
|
|
|
|
|
c := a.Client()
|
|
|
|
return a, c, a.HTTPAddr()
|
|
|
|
}
|