Ejemplo n.º 1
0
func NewRegistrar(registryFile string) (*Registrar, error) {

	r := &Registrar{
		registryFile: registryFile,
		done:         make(chan struct{}),
		state:        input.NewStates(),
		Channel:      make(chan []*FileEvent, 1),
		wg:           sync.WaitGroup{},
	}
	err := r.Init()

	return r, err
}
Ejemplo n.º 2
0
func TestProspectorDefaultConfigs(t *testing.T) {

	prospector, err := NewProspector(common.NewConfig(), *input.NewStates(), nil)
	assert.NoError(t, err)

	// Default values expected
	assert.Equal(t, DefaultIgnoreOlder, prospector.config.IgnoreOlder)
	assert.Equal(t, DefaultScanFrequency, prospector.config.ScanFrequency)
	assert.Equal(t, config.DefaultHarvesterBufferSize, prospector.config.Harvester.BufferSize)
	assert.Equal(t, config.DefaultTailFiles, prospector.config.Harvester.TailFiles)
	assert.Equal(t, config.DefaultBackoff, prospector.config.Harvester.BackoffDuration)
	assert.Equal(t, config.DefaultBackoffFactor, prospector.config.Harvester.BackoffFactor)
	assert.Equal(t, config.DefaultMaxBackoff, prospector.config.Harvester.MaxBackoffDuration)
	assert.Equal(t, config.DefaultForceCloseFiles, prospector.config.Harvester.ForceCloseFiles)
	assert.Equal(t, config.DefaultMaxBytes, prospector.config.Harvester.MaxBytes)
}
Ejemplo n.º 3
0
func TestProspectorInitInputTypeWrong(t *testing.T) {

	prospectorConfig := prospectorConfig{
		Harvester: harvester.HarvesterConfig{
			InputType: "wrong-type",
		},
	}

	prospector := Prospector{
		config: prospectorConfig,
		states: input.NewStates(),
	}

	err := prospector.Init()
	assert.Nil(t, err)
	assert.Equal(t, "log", prospector.config.Harvester.InputType)
}
Ejemplo n.º 4
0
func TestProspectorInitInputTypeLog(t *testing.T) {

	prospectorConfig := prospectorConfig{
		Paths: []string{"testpath1", "testpath2"},
		Harvester: harvester.HarvesterConfig{
			InputType: "log",
		},
	}

	prospector := Prospector{
		config: prospectorConfig,
		states: input.NewStates(),
	}

	err := prospector.Init()
	assert.Nil(t, err)
	assert.Equal(t, "log", prospector.config.Harvester.InputType)
}
Ejemplo n.º 5
0
func TestProspectorFileExclude(t *testing.T) {

	prospectorConfig := prospectorConfig{
		ExcludeFiles: []*regexp.Regexp{regexp.MustCompile(`\.gz$`)},
		Harvester: harvester.HarvesterConfig{
			BufferSize: 0,
		},
	}

	prospector := Prospector{
		config: prospectorConfig,
		states: input.NewStates(),
	}

	prospector.Init()
	prospectorer := prospector.prospectorer.(*ProspectorLog)

	assert.True(t, prospectorer.isFileExcluded("/tmp/log/logw.gz"))
	assert.False(t, prospectorer.isFileExcluded("/tmp/log/logw.log"))

}