コード例 #1
0
func TestPing(t *testing.T) {
	if testutil.RunningInCI() {
		t.Skip("Skipping volume client test because it looks like we're in the CI environment.")
	}
	runService(t)
	client := network.NewVolumeClient(volTestPort)
	require.NotNil(t, client)

	err := client.Ping(500)
	assert.Nil(t, err)
}
コード例 #2
0
ファイル: context.go プロジェクト: APTrust/exchange
/*
Creates and returns a new Context object. Because some
items are absolutely required by this object and the processes
that use it, this method will panic if it gets an invalid
config param from the command line, or if it cannot set up some
essential services, such as logging.

This object is meant to used as a singleton with any of the
stand-along processing services (bag_processor, bag_restorer,
cleanup, etc.).
*/
func NewContext(config *models.Config) (context *Context) {
	context = &Context{
		succeeded: int64(0),
		failed:    int64(0),
	}
	context.Config = config
	context.MessageLog, context.pathToLogFile = logger.InitLogger(config)
	context.JsonLog, context.pathToJsonLog = logger.InitJsonLogger(config)
	context.VolumeClient = network.NewVolumeClient(context.Config.VolumeServicePort)
	context.NSQClient = network.NewNSQClient(context.Config.NsqdHttpAddress)
	context.initPharosClient()
	return context
}
コード例 #3
0
func TestVolumeRelease(t *testing.T) {
	if testutil.RunningInCI() {
		t.Skip("Skipping volume client test because it looks like we're in the CI environment.")
	}
	runService(t)
	client := network.NewVolumeClient(volTestPort)
	require.NotNil(t, client)

	err := client.Release("/tmp/some_file")
	assert.Nil(t, err)

	err = client.Release("")
	assert.NotNil(t, err) // path required
}
コード例 #4
0
func TestVolumeReserve(t *testing.T) {
	if testutil.RunningInCI() {
		t.Skip("Skipping volume client test because it looks like we're in the CI environment.")
	}
	runService(t)
	client := network.NewVolumeClient(volTestPort)
	require.NotNil(t, client)

	ok, err := client.Reserve("/tmp/some_file", uint64(800))
	assert.Nil(t, err)
	assert.True(t, ok)

	ok, err = client.Reserve("", uint64(800))
	assert.NotNil(t, err) // path required
	assert.False(t, ok)

	ok, err = client.Reserve("", uint64(0))
	assert.NotNil(t, err) // > 0 bytes required
	assert.False(t, ok)
}
コード例 #5
0
func TestNewVolumeClient(t *testing.T) {
	client := network.NewVolumeClient(volTestPort)
	require.NotNil(t, client)
	expectedUrl := fmt.Sprintf("http://127.0.0.1:%d", volTestPort)
	assert.Equal(t, expectedUrl, client.BaseURL())
}