<commit_before>package nomad

import (
	"fmt"
	"testing"
)

func testClient(t *testing.T, cb func(c *Config)) *Client {
	// Setup the default settings
	config := DefaultConfig()
	config.Build = "unittest"
	config.DevMode = true
	config.NodeName = fmt.Sprintf("Client %d", config.RPCAddr.Port)

	// Invoke the callback if any
	if cb != nil {
		cb(config)
	}

	// Create client
	client, err := NewClient(config)
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	return client
}

func TestClient_StartStop(t *testing.T) {
	client := testClient(t, nil)
	if err := client.Shutdown(); err != nil {
		t.Fatalf("err: %v", err)
	}
}<commit_msg>nomad: test client RPC forwarding<commit_after>package nomad

import (
	"fmt"
	"testing"

	"github.com/hashicorp/nomad/testutil"
)

func testClient(t *testing.T, cb func(c *Config)) *Client {
	// Setup the default settings
	config := DefaultConfig()
	config.Build = "unittest"
	config.DevMode = true
	config.NodeName = fmt.Sprintf("Client %d", config.RPCAddr.Port)

	// Invoke the callback if any
	if cb != nil {
		cb(config)
	}

	// Create client
	client, err := NewClient(config)
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	return client
}

func TestClient_StartStop(t *testing.T) {
	client := testClient(t, nil)
	if err := client.Shutdown(); err != nil {
		t.Fatalf("err: %v", err)
	}
}

func TestClient_RPC(t *testing.T) {
	s1 := testServer(t, nil)
	defer s1.Shutdown()

	c1 := testClient(t, func(c *Config) {
		c.ServerAddress = []string{s1.config.RPCAddr.String()}
	})
	defer c1.Shutdown()

	// RPC should succeed
	testutil.WaitForResult(func() (bool, error) {
		var out struct{}
		err := c1.RPC("Status.Ping", struct{}{}, &out)
		return err == nil, err
	}, func(err error) {
		t.Fatalf("err: %v", err)
	})
}
{'fraction_non_alphanumeric': 0.1644774414620217, 'fraction_numerical': 0.0034266133637921186, 'mean_word_length': 3.8264462809917354, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5246187', 'n_tokens_mistral': 678, 'n_tokens_neox': 669, 'n_words': 167}