Skip to content

Commit

Permalink
upgrade Go to 1.20.6 (#36000)
Browse files Browse the repository at this point in the history
* upgrade Go to 1.20.5

* ignore known issue with go tool cover

* capture cover output and check it for errors

* debug

* wip

* move ragel files to root directory

the //line directives used to point to the original "ragel" files were creating problems for the coverage tool. They were being reported without the 'parser/' directory. Causing the go tool cover to look for the wrong files and therefore failing.
Moving it all to the root directory fixes the problem.

* upgrade to go1.20.6

* .

* Revert "move ragel files to root directory"

This reverts commit 2b6a159.

* remove debug

* disable //line directives

* goimport
  • Loading branch information
AndersonQ authored Jul 28, 2023
1 parent 739e381 commit a278734
Show file tree
Hide file tree
Showing 23 changed files with 253 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.19.10
1.20.6
9 changes: 4 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ linters-settings:

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.19.10"
go: "1.20.6"

nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
Expand All @@ -127,19 +127,19 @@ linters-settings:

staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.19.10"
go: "1.20.6"
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.19.10"
go: "1.20.6"
# Disabled:
# ST1005: error strings should not be capitalized
checks: ["all", "-ST1005"]

unused:
# Select the Go version to target. The default is '1.13'.
go: "1.19.10"
go: "1.20.6"

gosec:
excludes:
Expand All @@ -162,4 +162,3 @@ linters-settings:
# Report pre-allocation suggestions on for loops.
# Default: false
for-loops: true

3 changes: 2 additions & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
==== Breaking changes

*Affecting all Beats*

- Fix status reporting to Elastic-Agent when output configuration is invalid running under Elastic-Agent {pull}35719[35719]
- Upgrade Go to 1.20.6 {pull}36000[36000]

*Auditbeat*

Expand Down
44 changes: 44 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,48 @@ Vagrant.configure("2") do |config|
end
end

config.vm.define "beats" do |nodeconfig|
nodeconfig.vm.box = "ubuntu/jammy64"

# We deliberately set a fully-qualified domain name for the VM; it helps
# test the FQDN feature flag.
nodeconfig.vm.hostname = "beats-dev.elastic.dev.internal"

nodeconfig.vm.network "private_network",
hostname: true,
ip: "192.168.56.44" # only 192.168.56.0/21 range allowed: https://www.virtualbox.org/manual/ch06.html#network_hostonly
nodeconfig.vm.network "forwarded_port",
guest: 4244,
host: 4244,
id: "delve"

nodeconfig.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
vb.customize ["modifyvm", :id, "--vram", "128"]
# Customize the amount of memory on the VM:
vb.memory = "4096"
end

nodeconfig.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y \
build-essential \
curl \
delve \
make \
unzip
vim \
wget
curl -sL -o /tmp/go#{GO_VERSION}.linux-amd64.tar.gz https://go.dev/dl/go#{GO_VERSION}.linux-amd64.tar.gz
tar -C /usr/local -xzf /tmp/go#{GO_VERSION}.linux-amd64.tar.gz
curl -sL -o /tmp/mage_1.15.0_Linux-64bit.tar.gz https://github.com/magefile/mage/releases/download/v1.15.0/mage_1.15.0_Linux-64bit.tar.gz
tar -C /tmp -xf /tmp/mage_1.15.0_Linux-64bit.tar.gz
mv /tmp/mage /usr/local/bin/mage
echo "alias ll='ls -la'" > /etc/profile.d/ll.sh
echo 'export PATH=$PATH:/usr/local/go/bin' > /etc/profile.d/go.sh
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> /etc/profile.d/go.sh
SHELL
end

end
4 changes: 2 additions & 2 deletions auditbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.10
FROM golang:1.20.6

RUN \
apt-get update \
Expand All @@ -11,7 +11,7 @@ RUN \
&& rm -rf /var/lib/apt/lists/*

# Use a virtualenv to avoid the PEP668 "externally managed environment" error caused by conflicts
# with the system Python installation. golang:1.19.10 uses Debian 12 which now enforces PEP668.
# with the system Python installation. golang:1.20.6 uses Debian 12 which now enforces PEP668.
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/kubernetes/filebeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.10 as builder
FROM golang:1.20.6 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/kubernetes/heartbeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.10 as builder
FROM golang:1.20.6 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/kubernetes/metricbeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.10 as builder
FROM golang:1.20.6 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

Expand Down
7 changes: 5 additions & 2 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func DefaultTestBinaryArgs() TestBinaryArgs {
}

// GoTestIntegrationForModule executes the Go integration tests sequentially.
// Currently all test cases must be present under "./module" directory.
// Currently, all test cases must be present under "./module" directory.
//
// Motivation: previous implementation executed all integration tests at once,
// causing high CPU load, high memory usage and resulted in timeouts.
Expand Down Expand Up @@ -307,12 +307,15 @@ func GoTest(ctx context.Context, params GoTestArgs) error {
// Generate a HTML code coverage report.
var htmlCoverReport string
if params.CoverageProfileFile != "" {

htmlCoverReport = strings.TrimSuffix(params.CoverageProfileFile,
filepath.Ext(params.CoverageProfileFile)) + ".html"

coverToHTML := sh.RunCmd("go", "tool", "cover",
"-html="+params.CoverageProfileFile,
"-o", htmlCoverReport)
if err = coverToHTML(); err != nil {

if err := coverToHTML(); err != nil {
return fmt.Errorf("failed to write HTML code coverage report: %w", err)
}
}
Expand Down
20 changes: 10 additions & 10 deletions dev-tools/mage/gotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,41 +210,41 @@ var wantTestAssertOutput = `(?sm:
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_fails.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_fails .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/assert_with_message .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_with_message.*
Messages: My message.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_with_message .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/assert_with_messagef .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_with_messagef.*
Messages: My message with arguments: 42.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_with_messagef .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_fails .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_fails.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_fails .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_with_message .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_with_message.*
Messages: My message.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_with_message .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_with_messagef .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_with_messagef.*
Messages: My message with arguments: 42.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_with_messagef .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/equals_map .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Expand Down Expand Up @@ -306,17 +306,17 @@ var wantTestLogOutput = `(?sm:
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail.*
gotest_test.go:\d+: Log should fail with printf style log: 23.*
--- FAIL: TestGoTest_Helper_LogOutput/on_error.*
=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/on_fatal.*
gotest_test.go:\d+: Log message should be printed.*
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail.*
--- FAIL: TestGoTest_Helper_LogOutput/on_fatal.*
=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/on_fatalf.*
gotest_test.go:\d+: Log message should be printed.*
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail with printf style log: 42.*
--- FAIL: TestGoTest_Helper_LogOutput/on_fatalf.*
=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/with_newlines.*
gotest_test.go:\d+: Log.*
message.*
Expand All @@ -336,7 +336,7 @@ var wantTestLogOutput = `(?sm:
style.*
log:.*
42.*
--- FAIL: TestGoTest_Helper_LogOutput/with_newlines.*
=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput.*
DONE 5 tests, 5 failures in.*
)`
Expand Down
8 changes: 4 additions & 4 deletions filebeat/input/syslog/format_check.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a278734

Please sign in to comment.