Skip to content

Commit

Permalink
Updated build image with go1.21.4, dep updates, linter related fixes (#…
Browse files Browse the repository at this point in the history
…858)

* updated build image with go1.21.4

* linters...

* might as well go get -u ./... too

* prep for 1.61.0 release
  • Loading branch information
ldemailly committed Nov 15, 2023
1 parent 181f066 commit f35afd8
Show file tree
Hide file tree
Showing 28 changed files with 101 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defaultEnv:
&defaultEnv
docker:
# specify the version
- image: docker.io/fortio/fortio.build:v64@sha256:4a9a3a4e93375b8efaba213cb8ded9d5ace9683961cb44d0d26688f0ec005569
- image: docker.io/fortio/fortio.build:v65@sha256:0b39aa58b72f8594581ef02cfd1d3c493096335e5e33a49b94390a695ff9efbb
working_directory: /build/fortio

jobs:
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ issues:
- forcetypeassert
- nosnakecase
- noctx
- goconst

# Exclude lll issues for long lines with go:generate
- linters:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the binaries in larger image
FROM docker.io/fortio/fortio.build:v64@sha256:4a9a3a4e93375b8efaba213cb8ded9d5ace9683961cb44d0d26688f0ec005569 as build
FROM docker.io/fortio/fortio.build:v65@sha256:0b39aa58b72f8594581ef02cfd1d3c493096335e5e33a49b94390a695ff9efbb as build
WORKDIR /build
COPY --chown=build:build . fortio
ARG MODE=install
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dependencies and linters for build:
FROM golang:1.20.10@sha256:9351b562453570a9957c9bd642ed9d1eca842e878c58ab488b9846f345c3edcc
FROM golang:1.21.4@sha256:81cd210ae58a6529d832af2892db822b30d84f817a671b8e1c15cff0b271a3db
# Need gcc for -race test (and some linters though those work with CGO_ENABLED=0)
RUN apt-get -y update && \
apt-get --no-install-recommends -y upgrade && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.echosrv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the binaries in larger image
FROM docker.io/fortio/fortio.build:v64@sha256:4a9a3a4e93375b8efaba213cb8ded9d5ace9683961cb44d0d26688f0ec005569 as build
FROM docker.io/fortio/fortio.build:v65@sha256:0b39aa58b72f8594581ef02cfd1d3c493096335e5e33a49b94390a695ff9efbb as build
WORKDIR /build
COPY . fortio
RUN make -C fortio official-build-version BUILD_DIR=/build OFFICIAL_TARGET=fortio.org/fortio/echosrv
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.fcurl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the binaries in larger image
FROM docker.io/fortio/fortio.build:v64@sha256:4a9a3a4e93375b8efaba213cb8ded9d5ace9683961cb44d0d26688f0ec005569 as build
FROM docker.io/fortio/fortio.build:v65@sha256:0b39aa58b72f8594581ef02cfd1d3c493096335e5e33a49b94390a695ff9efbb as build
WORKDIR /build
COPY . fortio
RUN make -C fortio official-build-version BUILD_DIR=/build OFFICIAL_TARGET=fortio.org/fortio/fcurl
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
IMAGES=echosrv fcurl # plus the combo image / Dockerfile without ext.

DOCKER_PREFIX := docker.io/fortio/fortio
BUILD_IMAGE_TAG := v64@sha256:4a9a3a4e93375b8efaba213cb8ded9d5ace9683961cb44d0d26688f0ec005569
BUILD_IMAGE_TAG := v65@sha256:0b39aa58b72f8594581ef02cfd1d3c493096335e5e33a49b94390a695ff9efbb
BUILDX_PLATFORMS := linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
BUILDX_POSTFIX :=
ifeq '$(shell echo $(BUILDX_PLATFORMS) | awk -F "," "{print NF-1}")' '0'
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- 1.60.3 -->
<!-- 1.61.0 -->
# Fortio

[![Awesome Go](https://fortio.org/mentioned-badge.svg)](https://github.com/avelino/awesome-go#networking)
Expand Down Expand Up @@ -60,13 +60,13 @@ You can install from source:
The [releases](https://github.com/fortio/fortio/releases) page has binaries for many OS/architecture combinations (see assets):

```shell
curl -L https://github.com/fortio/fortio/releases/download/v1.60.3/fortio-linux_amd64-1.60.3.tgz \
curl -L https://github.com/fortio/fortio/releases/download/v1.61.0/fortio-linux_amd64-1.61.0.tgz \
| sudo tar -C / -xvzpf -
# or the debian package
wget https://github.com/fortio/fortio/releases/download/v1.60.3/fortio_1.60.3_amd64.deb
dpkg -i fortio_1.60.3_amd64.deb
wget https://github.com/fortio/fortio/releases/download/v1.61.0/fortio_1.61.0_amd64.deb
dpkg -i fortio_1.61.0_amd64.deb
# or the rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.60.3/fortio-1.60.3-1.x86_64.rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.61.0/fortio-1.61.0-1.x86_64.rpm
# and more, see assets in release page
```

Expand All @@ -76,7 +76,7 @@ On a MacOS you can also install Fortio using [Homebrew](https://brew.sh/):
brew install fortio
```

On Windows, download https://github.com/fortio/fortio/releases/download/v1.60.3/fortio_win_1.60.3.zip and extract `fortio.exe` to any location, then using the Windows Command Prompt:
On Windows, download https://github.com/fortio/fortio/releases/download/v1.61.0/fortio_win_1.61.0.zip and extract `fortio.exe` to any location, then using the Windows Command Prompt:
```
fortio.exe server
```
Expand Down Expand Up @@ -128,7 +128,7 @@ Full list of command line flags (`fortio help`):
<!-- use release/updateFlags.sh to update this section -->
<pre>
<!-- USAGE_START -->
Φορτίο 1.60.3 usage:
Φορτίο 1.61.0 usage:
fortio command [flags] target
where command is one of: load (load testing), server (starts ui, rest api,
http-echo, redirect, proxies, tcp-echo, udp-echo and grpc ping servers),
Expand Down
2 changes: 1 addition & 1 deletion Webtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fi
PPROF_URL="$BASE_URL/debug/pprof/heap?debug=1"
$CURL "$PPROF_URL" | grep -i TotalAlloc # should find this in memory profile
# creating dummy container to hold a volume for test certs due to remote docker bind mount limitation.
DOCKERCURLID=$(docker run -d -v $TEST_CERT_VOL --net host --name $DOCKERSECVOLNAME docker.io/fortio/fortio.build:v64@sha256:4a9a3a4e93375b8efaba213cb8ded9d5ace9683961cb44d0d26688f0ec005569 sleep 120)
DOCKERCURLID=$(docker run -d -v $TEST_CERT_VOL --net host --name $DOCKERSECVOLNAME docker.io/fortio/fortio.build:v65@sha256:0b39aa58b72f8594581ef02cfd1d3c493096335e5e33a49b94390a695ff9efbb sleep 120)
# while we have something with actual curl binary do
# Test for h2c upgrade (#562)
docker exec $DOCKERSECVOLNAME /usr/bin/curl -v --http2 -m 10 -d foo42 http://localhost:8080/debug | tee >(cat 1>&2) | grep foo42
Expand Down
5 changes: 3 additions & 2 deletions cli/fortio_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"fortio.org/fortio/fhttp"
"fortio.org/fortio/fnet"
"fortio.org/fortio/periodic"
"fortio.org/fortio/rapi"
"fortio.org/fortio/stats"
"fortio.org/fortio/tcprunner"
"fortio.org/fortio/udprunner"
Expand Down Expand Up @@ -406,7 +407,7 @@ func fortioLoad(justCurl bool, percList []float64, hook bincommon.FortioHook) {
if labels == "" {
hname, _ := os.Hostname()
shortURL := url
for _, p := range []string{"https://", "http://"} {
for _, p := range []string{fnet.PrefixHTTPS, fnet.PrefixHTTP} {
if strings.HasPrefix(url, p) {
shortURL = url[len(p):]
break
Expand Down Expand Up @@ -508,7 +509,7 @@ func fortioLoad(justCurl bool, percList []float64, hook bincommon.FortioHook) {
jsonFileName = "stdout"
} else {
if len(jsonFileName) == 0 {
jsonFileName = path.Join(*dataDirFlag, rr.ID+".json")
jsonFileName = path.Join(*dataDirFlag, rr.ID+rapi.JSONExtension)
}
f, err = os.Create(jsonFileName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion fgrpc/grpcrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (grpcstate *GRPCRunnerResults) Run(outCtx context.Context, t periodic.Threa
var r *grpc_health_v1.HealthCheckResponse
r, err = grpcstate.clientH.Check(outCtx, &grpcstate.reqH)
if r != nil {
status = r.Status
status = r.GetStatus()
res = r
}
}
Expand Down
10 changes: 5 additions & 5 deletions fgrpc/pingsrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (s *pingSrv) Ping(c context.Context, in *PingMessage) (*PingMessage, error)
log.LogVf("Ping called %+v (meta %+v)", *in, md)
out := *in // copy the input including the payload etc
out.Ts = time.Now().UnixNano()
if in.DelayNanos > 0 {
s := time.Duration(in.DelayNanos)
if in.GetDelayNanos() > 0 {
s := time.Duration(in.GetDelayNanos())
log.LogVf("GRPC ping: sleeping for %v", s)
time.Sleep(s)
}
Expand Down Expand Up @@ -149,10 +149,10 @@ func PingClientCall(serverAddr string, n int, payload string, delay time.Duratio
log.Errf("grpc error from Ping1 iter %d: %v", i, err)
return -1, err
}
t1b := res1.Ts
t1b := res1.GetTs()
res2, err := cli.Ping(outCtx, msg)
t3a := time.Now().UnixNano()
t2b := res2.Ts
t2b := res2.GetTs()
if err != nil {
log.Errf("grpc error from Ping2 iter %d: %v", i, err)
return -1, err
Expand Down Expand Up @@ -207,7 +207,7 @@ func GrpcHealthCheck(serverAddr, svcname string, n int, tlsOpts *fhttp.TLSOption
log.Errf("grpc error from Check %v", err)
return nil, err
}
statuses[res.Status.String()]++
statuses[res.GetStatus().String()]++
rttHistogram.Record(dur.Seconds() * 1000000.)
}
rttHistogram.Print(os.Stdout, "RTT histogram usec", []float64{50})
Expand Down
4 changes: 2 additions & 2 deletions fgrpc/pingsrv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func TestPingServer(t *testing.T) {
if latency, err := PingClientCall(iAddr, 1, "", 0, TLSSecure, nil); err == nil {
t.Errorf("Should have had an error instead of result %f for secure ping to insecure port", latency)
}
if _, err := PingClientCall("https://"+sAddr, 1, "", 0, TLSInsecure, nil); err != nil {
if _, err := PingClientCall(fnet.PrefixHTTPS+sAddr, 1, "", 0, TLSInsecure, nil); err != nil {
t.Errorf("Should have had no error for secure with bad cert and insecure flag: %v", err)
}
if latency, err := PingClientCall("https://"+sAddr, 1, "", 0, TLSSecureMissingCert, nil); err == nil {
if latency, err := PingClientCall(fnet.PrefixHTTPS+sAddr, 1, "", 0, TLSSecureMissingCert, nil); err == nil {
t.Errorf("Should have had error for secure with bad cert and no insecure flag: %v", latency)
}
if latency, err := PingClientCall(sAddr, 1, "", 0, TLSInsecure, nil); err == nil {
Expand Down
10 changes: 5 additions & 5 deletions fhttp/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ type Fetcher interface {
// Fetch returns http code, data, offset of body (for client which returns
// headers)
// Deprecated: use StreamFetch with a DataWriter (nil if you don't need the data) instead.
Fetch(context.Context) (int, []byte, int)
Fetch(ctx context.Context) (int, []byte, int)
// StreamFetch returns http code and body bytes read
// (body is streamed to Dest writer or null),and header size for the fast client.
StreamFetch(context.Context) (int, int64, uint)
StreamFetch(ctx context.Context) (int, int64, uint)
// HasBuffer is true for the fast client and false for golang standard library based client.
// it's used to know if calling Fetch() is actually better (fast client with headers to stderr)
HasBuffer() bool
Expand Down Expand Up @@ -157,7 +157,7 @@ func (h *HTTPOptions) URLSchemeCheck() {
log.Infof("H2 requested, switching to std client")
h.DisableFastClient = true
}
hs := "https://" // longer of the 2 prefixes
hs := fnet.PrefixHTTPS // longer of the 2 prefixes
lcURL := h.URL
if len(lcURL) > len(hs) {
lcURL = strings.ToLower(h.URL[:len(hs)]) // no need to tolower more than we check
Expand All @@ -166,9 +166,9 @@ func (h *HTTPOptions) URLSchemeCheck() {
h.https = true
return // url is good
}
if !strings.HasPrefix(lcURL, "http://") {
if !strings.HasPrefix(lcURL, fnet.PrefixHTTP) {
log.Warnf("Assuming http:// on missing scheme for '%s'", h.URL)
h.URL = "http://" + h.URL
h.URL = fnet.PrefixHTTP + h.URL
}
}

Expand Down
4 changes: 2 additions & 2 deletions fhttp/http_forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ func MultiServer(port string, cfg *MultiServerConfig) (*http.ServeMux, net.Addr)
if t.MirrorOrigin {
t.Destination = strings.TrimSuffix(t.Destination, "/") // remove trailing / because we will concatenate the request URI
}
if !strings.HasPrefix(t.Destination, "https://") && !strings.HasPrefix(t.Destination, "http://") {
if !strings.HasPrefix(t.Destination, fnet.PrefixHTTPS) && !strings.HasPrefix(t.Destination, fnet.PrefixHTTP) {
log.Infof("Assuming http:// on missing scheme for '%s'", t.Destination)
t.Destination = "http://" + t.Destination
t.Destination = fnet.PrefixHTTP + t.Destination
}
}
log.Infof("Multi-server on %s running with %+v", aStr, cfg)
Expand Down
6 changes: 3 additions & 3 deletions fhttp/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ func FetcherHandler2(w http.ResponseWriter, r *http.Request) {
http.Error(w, "missing url value", http.StatusBadRequest)
return
}
if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") {
url = "http://" + url
if !strings.HasPrefix(url, fnet.PrefixHTTP) && !strings.HasPrefix(url, fnet.PrefixHTTPS) {
url = fnet.PrefixHTTP + url
}
req, opts := MakeSimpleRequest(url, r, Fetch2CopiesAllHeader.Get())
if req == nil {
Expand Down Expand Up @@ -590,7 +590,7 @@ func FetcherHandler(w http.ResponseWriter, r *http.Request) {

// RedirectToHTTPSHandler handler sends a redirect to same URL with https.
func RedirectToHTTPSHandler(w http.ResponseWriter, r *http.Request) {
dest := "https://" + r.Host + r.URL.String()
dest := fnet.PrefixHTTPS + r.Host + r.URL.String()
log.LogRequest(r, "Redirecting to "+dest)
http.Redirect(w, r, dest, http.StatusSeeOther)
}
Expand Down
12 changes: 6 additions & 6 deletions fhttp/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ func TestSchemeCheck(t *testing.T) {
{"www.google.com", "http://www.google.com"},
{"hTTps://foo.bar:123/ab/cd", "hTTps://foo.bar:123/ab/cd"}, // not double http:
{"HTTP://foo.bar:124/ab/cd", "HTTP://foo.bar:124/ab/cd"}, // not double http:
{"", ""}, // and error in the logs
{"x", "http://x"}, // should not crash because url is shorter than prefix
{"http:/", "http://http:/"}, // boundary
{"http://", "http://"}, // boundary
{"https://", "https://"}, // boundary
{"https:/", "http://https:/"}, // boundary
{"", ""}, // and error in the logs
{"x", "http://x"}, // should not crash because url is shorter than prefix
{"http:/", "http://http:/"}, // boundary
{fnet.PrefixHTTP, fnet.PrefixHTTP}, // boundary
{fnet.PrefixHTTPS, fnet.PrefixHTTPS}, // boundary
{"https:/", "http://https:/"}, // boundary
}
for _, tst := range tests {
o := NewHTTPOptions(tst.input)
Expand Down
4 changes: 2 additions & 2 deletions fhttp/http_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ func OnBehalfOfRequest(to *http.Request, from *http.Request) {
}
}

// AddHTTPS replaces "http://" in url with "https://" or prepends "https://"
// if url does not contain prefix "http://".
// AddHTTPS replaces http:// in url with https:// or prepends https:///
// if url does not contain the http:// prefix.
func AddHTTPS(url string) string {
if len(url) > len(fnet.PrefixHTTP) {
if strings.EqualFold(url[:len(fnet.PrefixHTTP)], fnet.PrefixHTTP) {
Expand Down
6 changes: 3 additions & 3 deletions fnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,11 @@ func GeneratePayload(payloadFilePath string, payloadSize int, payload string) []
return nil
}
return p
} else if payloadSize > 0 {
}
if payloadSize > 0 {
return GenerateRandomPayload(payloadSize)
} else {
return []byte(payload)
}
return []byte(payload)
}

// GetUniqueUnixDomainPath returns a path to be used for unix domain socket.
Expand Down
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ go 1.18
require (
fortio.org/assert v1.2.0
fortio.org/cli v1.4.2
fortio.org/dflag v1.6.0
fortio.org/dflag v1.7.0
fortio.org/log v1.11.0
fortio.org/scli v1.12.0
fortio.org/scli v1.12.1
fortio.org/sets v1.0.3
fortio.org/testscript v0.3.1
fortio.org/version v1.0.3
github.com/golang/protobuf v1.5.3
github.com/google/uuid v1.3.1
golang.org/x/net v0.17.0
google.golang.org/grpc v1.58.3
github.com/google/uuid v1.4.0
golang.org/x/net v0.18.0
google.golang.org/grpc v1.59.0
)

// Local dev of dependencies changes
Expand All @@ -28,11 +28,11 @@ require (
//)

require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

0 comments on commit f35afd8

Please sign in to comment.