Agent/Proxy: Formatting and test cases fix
This commit is contained in:
parent
f0af60612c
commit
0b50b84429
|
@ -427,7 +427,7 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (*
|
|||
}
|
||||
go s.Flood(nil, portFn, s.serfWAN)
|
||||
}
|
||||
|
||||
|
||||
// Start enterprise specific functionality
|
||||
if err := s.startEnterprise(); err != nil {
|
||||
s.Shutdown()
|
||||
|
|
|
@ -432,7 +432,10 @@ func (m *Manager) newProxy(mp *local.ManagedProxy) (Proxy, error) {
|
|||
if err := m.configureLogDir(id, &cmd); err != nil {
|
||||
return nil, fmt.Errorf("error configuring proxy logs: %s", err)
|
||||
}
|
||||
|
||||
// Pass in the environmental variables for this proxy process
|
||||
cmd.Env = os.Environ()
|
||||
|
||||
// Build the daemon structure
|
||||
proxy.Command = &cmd
|
||||
proxy.ProxyID = id
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -286,27 +285,24 @@ func TestEnvironproxy(t *testing.T) {
|
|||
go m.Run()
|
||||
|
||||
//Get the environmental variables from the OS
|
||||
//envCheck := os.Environ()
|
||||
var fileContent Bytes
|
||||
var fileContent []byte
|
||||
var err error
|
||||
var data Bytes
|
||||
var data []byte
|
||||
envData := os.Environ()
|
||||
sort.Strings(envData)
|
||||
for _, envVariable := range envData {
|
||||
data = append(data, envVariable...)
|
||||
data = append(data, "\n"...)
|
||||
}
|
||||
// t.Log(data)
|
||||
|
||||
// Check if the file written to from the spawned process
|
||||
// has the necessary environmental variable data
|
||||
retry.Run(t, func(r *retry.R) {
|
||||
if fileContent, err = ioutil.ReadFile(path); err != nil {
|
||||
r.Fatalf("No file ya dummy")
|
||||
}
|
||||
})
|
||||
|
||||
t.Logf("Len (data) : %d , Len (fileContent) : %d", len(data), len(fileContent))
|
||||
t.Logf("Type (data) : %s Type (fileContent) : %s", reflect.TypeOf(data), reflect.TypeOf(fileContent))
|
||||
// t.Logf("File content: \n %s", fileContent)
|
||||
// t.Logf("Data content: \n %s", data)
|
||||
require.Equal(fileContent, data)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,22 +19,6 @@ import (
|
|||
// *log.Logger instance.
|
||||
var testLogger = log.New(os.Stderr, "logger: ", log.LstdFlags)
|
||||
|
||||
//SOrting interface
|
||||
type Bytes []byte
|
||||
|
||||
//Length method for our Byte interface
|
||||
func (b Bytes) Len() int {
|
||||
return len(b)
|
||||
}
|
||||
|
||||
func (b Bytes) Swap(i, j int) {
|
||||
b[i], b[j] = b[j], b[i]
|
||||
}
|
||||
|
||||
func (b Bytes) Less(i, j int) bool {
|
||||
return b[i] < b[j]
|
||||
}
|
||||
|
||||
// testTempDir returns a temporary directory and a cleanup function.
|
||||
func testTempDir(t *testing.T) (string, func()) {
|
||||
t.Helper()
|
||||
|
@ -162,14 +146,17 @@ func TestHelperProcess(t *testing.T) {
|
|||
signal.Notify(stop, os.Interrupt)
|
||||
defer signal.Stop(stop)
|
||||
|
||||
//Write the environmental variables into the file
|
||||
//Get the path for the file to be written to
|
||||
path := args[0]
|
||||
var data Bytes
|
||||
// sort.Sort(data)
|
||||
var data []byte
|
||||
|
||||
//Get the environmental variables
|
||||
envData := os.Environ()
|
||||
|
||||
//Sort the env data for easier comparison
|
||||
sort.Strings(envData)
|
||||
for _, envVariable := range envData {
|
||||
if strings.Contains(envVariable, "CONNECT_PROXY") {
|
||||
if strings.HasPrefix(envVariable, "CONSUL") || strings.HasPrefix(envVariable, "CONNECT") {
|
||||
continue
|
||||
}
|
||||
data = append(data, envVariable...)
|
||||
|
@ -181,6 +168,7 @@ func TestHelperProcess(t *testing.T) {
|
|||
|
||||
// Clean up after we receive the signal to exit
|
||||
defer os.Remove(path)
|
||||
|
||||
<-stop
|
||||
|
||||
case "output":
|
||||
|
|
Loading…
Reference in New Issue