Skip to content

Commit

Permalink
Fix TestSystemLogsCanUseLogInput and run it on all OSes
Browse files Browse the repository at this point in the history
Fix TestSystemLogsCanUseLogInput and move it to a file without the
linux build constraint so it can run on all OSes supported by the
system integration.
  • Loading branch information
belimawr committed Oct 23, 2024
1 parent 980d283 commit 59974d2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"testing"
"time"
Expand Down Expand Up @@ -150,32 +149,6 @@ func findFilesetNames(t *testing.T, outputGlob string) func() bool {
return f
}

func TestSystemLogsCanUseLogInput(t *testing.T) {
filebeat := integration.NewBeat(
t,
"filebeat",
"../../filebeat.test",
)
workDir := filebeat.TempDir()
copyModulesDir(t, workDir)

logFilePath := path.Join(workDir, "syslog")
integration.GenerateLogFile(t, logFilePath, 5, false)
yamlCfg := fmt.Sprintf(systemModuleCfg, logFilePath, workDir)

filebeat.WriteConfigFile(yamlCfg)
filebeat.Start()

filebeat.WaitForLogs(
"using log input because file(s) was(were) found",
10*time.Second,
"system-logs did not select the log input")
filebeat.WaitForLogs(
"Harvester started for paths:",
10*time.Second,
"system-logs did not start the log input")
}

func copyModulesDir(t *testing.T, dst string) {
pwd, err := os.Getwd()
if err != nil {
Expand Down
55 changes: 55 additions & 0 deletions filebeat/tests/integration/systemlogs_other_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

//go:build integration

package integration

import (
"fmt"
"path"
"testing"
"time"

"github.com/elastic/beats/v7/libbeat/tests/integration"
)

func TestSystemLogsCanUseLogInput(t *testing.T) {
filebeat := integration.NewBeat(
t,
"filebeat",
"../../filebeat.test",
)
workDir := filebeat.TempDir()
copyModulesDir(t, workDir)

logFilePath := path.Join(workDir, "syslog")
integration.GenerateLogFile(t, logFilePath, 5, false)
yamlCfg := fmt.Sprintf(systemModuleCfg, logFilePath, logFilePath, workDir)

filebeat.WriteConfigFile(yamlCfg)
filebeat.Start()

filebeat.WaitForLogs(
"using log input because file(s) was(were) found",
10*time.Second,
"system-logs did not select the log input")
filebeat.WaitForLogs(
"Harvester started for paths:",
10*time.Second,
"system-logs did not start the log input")
}

0 comments on commit 59974d2

Please sign in to comment.