Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package fortio for openSUSE:Factory checked in at 2022-10-26 12:31:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/fortio (Old) and /work/SRC/openSUSE:Factory/.fortio.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "fortio" Wed Oct 26 12:31:59 2022 rev:23 rq:1031235 version:1.38.2 Changes: -------- --- /work/SRC/openSUSE:Factory/fortio/fortio.changes 2022-10-14 15:43:40.376031979 +0200 +++ /work/SRC/openSUSE:Factory/.fortio.new.2275/fortio.changes 2022-10-26 12:32:01.772342940 +0200 @@ -1,0 +2,6 @@ +Tue Oct 25 18:45:32 UTC 2022 - [email protected] + +- Update to version 1.38.2: + * Tests for slice/array returned from jrpc calls as well as a cleaner shortcut: `jrpc.GetArray()` (#634) + +------------------------------------------------------------------- Old: ---- fortio-1.38.1.tar.gz New: ---- fortio-1.38.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ fortio.spec ++++++ --- /var/tmp/diff_new_pack.cvR2Hz/_old 2022-10-26 12:32:02.468344428 +0200 +++ /var/tmp/diff_new_pack.cvR2Hz/_new 2022-10-26 12:32:02.472344437 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: fortio -Version: 1.38.1 +Version: 1.38.2 Release: 0 Summary: Load testing library, command line tool, advanced echo server and web UI License: Apache-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.cvR2Hz/_old 2022-10-26 12:32:02.520344540 +0200 +++ /var/tmp/diff_new_pack.cvR2Hz/_new 2022-10-26 12:32:02.524344548 +0200 @@ -3,7 +3,7 @@ <param name="url">https://github.com/fortio/fortio</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">v1.38.1</param> + <param name="revision">v1.38.2</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> @@ -17,7 +17,7 @@ <param name="compression">gz</param> </service> <service name="go_modules" mode="disabled"> - <param name="archive">fortio-1.38.1.tar.gz</param> + <param name="archive">fortio-1.38.2.tar.gz</param> </service> </services> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.cvR2Hz/_old 2022-10-26 12:32:02.552344608 +0200 +++ /var/tmp/diff_new_pack.cvR2Hz/_new 2022-10-26 12:32:02.556344616 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/fortio/fortio</param> - <param name="changesrevision">fbcebcb68e5799b357fd2f48289b2c69781d5001</param></service></servicedata> + <param name="changesrevision">d2a2d42f4f17df4c09e608353546ebd0d443747d</param></service></servicedata> (No newline at EOF) ++++++ fortio-1.38.1.tar.gz -> fortio-1.38.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fortio-1.38.1/README.md new/fortio-1.38.2/README.md --- old/fortio-1.38.1/README.md 2022-10-14 01:50:25.000000000 +0200 +++ new/fortio-1.38.2/README.md 2022-10-24 22:53:20.000000000 +0200 @@ -52,13 +52,13 @@ 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.38.1/fortio-linux_amd64-1.38.1.tgz \ +curl -L https://github.com/fortio/fortio/releases/download/v1.38.2/fortio-linux_amd64-1.38.2.tgz \ | sudo tar -C / -xvzpf - # or the debian package -wget https://github.com/fortio/fortio/releases/download/v1.38.1/fortio_1.38.1_amd64.deb -dpkg -i fortio_1.38.1_amd64.deb +wget https://github.com/fortio/fortio/releases/download/v1.38.2/fortio_1.38.2_amd64.deb +dpkg -i fortio_1.38.2_amd64.deb # or the rpm -rpm -i https://github.com/fortio/fortio/releases/download/v1.38.1/fortio-1.38.1-1.x86_64.rpm +rpm -i https://github.com/fortio/fortio/releases/download/v1.38.2/fortio-1.38.2-1.x86_64.rpm # and more, see assets in release page ``` @@ -68,7 +68,7 @@ brew install fortio ``` -On Windows, download https://github.com/fortio/fortio/releases/download/v1.38.1/fortio_win_1.38.1.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.38.2/fortio_win_1.38.2.zip and extract `fortio.exe` to any location, then using the Windows Command Prompt: ``` fortio.exe server ``` @@ -116,7 +116,7 @@ <details> <!-- use release/updateFlags.sh to update this section --> <pre> -???????????? 1.38.1 usage: +???????????? 1.38.2 usage: fortio command [flags] target where command is one of: load (load testing), server (starts ui, rest api, http-echo, redirect, proxies, tcp-echo and grpc ping servers), tcp-echo (only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fortio-1.38.1/jrpc/jrpcClient.go new/fortio-1.38.2/jrpc/jrpcClient.go --- old/fortio-1.38.1/jrpc/jrpcClient.go 2022-10-14 01:50:25.000000000 +0200 +++ new/fortio-1.38.2/jrpc/jrpcClient.go 2022-10-24 22:53:20.000000000 +0200 @@ -120,6 +120,16 @@ return Fetch[Q](url, []byte{}) } +// GetArray fetches and deseializes the JSON returned by the Destination into a slice of +// Q struct (ie the response is a json array). +func GetArray[Q any](url *Destination) ([]Q, error) { + slicePtr, err := Fetch[[]Q](url, []byte{}) + if slicePtr == nil { + return nil, err + } + return *slicePtr, err +} + // GetURL is Get without additional options (default timeout and headers). func GetURL[Q any](url string) (*Q, error) { return Get[Q](NewDestination(url)) @@ -162,7 +172,7 @@ if ok { return nil, err } - return nil, &FetchError{"deserialization error", code, err, bytes} + return nil, &FetchError{"non ok http result and deserialization error", code, err, bytes} } if !ok { // can still be "ok" for some callers, they can use the result object as it deserialized as expected. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fortio-1.38.1/jrpc/jrpc_test.go new/fortio-1.38.2/jrpc/jrpc_test.go --- old/fortio-1.38.1/jrpc/jrpc_test.go 2022-10-14 01:50:25.000000000 +0200 +++ new/fortio-1.38.2/jrpc/jrpc_test.go 2022-10-24 22:53:20.000000000 +0200 @@ -270,7 +270,7 @@ if unwrap.Error() != expected { t.Errorf("unwrapped error expected to be %q, got %v", expected, unwrap.Error()) } - expected = "deserialization error, code 747: " + expected + " (raw reply: {bad})" + expected = "non ok http result and deserialization error, code 747: " + expected + " (raw reply: {bad})" if err.Error() != expected { t.Errorf("error string expected %q, got %q", expected, err.Error()) } @@ -396,3 +396,96 @@ t.Errorf("expected %s, got %s", expected, str) } } + +// Testing slices + +type SliceRequest struct { + HowMany int +} + +type SliceOneResponse struct { + Index int + Data string +} + +func TestJPRCSlices(t *testing.T) { + mux, addr := fhttp.HTTPServer("test3", "0") + port := addr.(*net.TCPAddr).Port + mux.HandleFunc("/test-api-array", func(w http.ResponseWriter, r *http.Request) { + req, err := jrpc.HandleCall[SliceRequest](w, r) + if err != nil { + err = jrpc.ReplyError(w, "request error", err) + if err != nil { + t.Errorf("Error in replying error: %v", err) + } + return + } + n := req.HowMany + if n < 0 { + jrpc.ReplyError(w, "invalid negative count", nil) + return + } + if r.FormValue("errror") != "" { + jrpc.ReplyError(w, "error requested", nil) + return + } + if n == 0 { + n = 42 // for testing of GetArray + } + resp := make([]SliceOneResponse, n) + for i := 0; i < n; i++ { + resp[i] = SliceOneResponse{ + Index: i, + Data: fmt.Sprintf("data %d", i), + } + } + jrpc.ReplyOk(w, &resp) + }) + url := fmt.Sprintf("http://localhost:%d/test-api-array", port) + req := SliceRequest{10} + res, err := jrpc.CallURL[[]SliceOneResponse](url, &req) + if err != nil { + t.Errorf("failed Call: %v", err) + } + if res == nil { + t.Errorf("nil response") + return + } + slice := *res + if len(slice) != 10 { + t.Errorf("expected 10 results, got %d", len(slice)) + } + for i := 0; i < len(slice); i++ { + el := slice[i] + if el.Index != i { + t.Errorf("expected index %d, got %d", i, el.Index) + } + if el.Data != fmt.Sprintf("data %d", i) { + t.Errorf("expected data %d, got %s", i, el.Data) + } + } + slice, err = jrpc.GetArray[SliceOneResponse](jrpc.NewDestination(url)) + if err != nil { + t.Errorf("failed GetArray: %v", err) + } + if len(slice) != 42 { + t.Errorf("expected 42 results, got %d", len(slice)) + } + for i := 0; i < len(slice); i++ { + el := slice[i] + if el.Index != i { + t.Errorf("expected index %d, got %d", i, el.Index) + } + if el.Data != fmt.Sprintf("data %d", i) { + t.Errorf("expected data %d, got %s", i, el.Data) + } + } + // Empty slice/error + slice, err = jrpc.GetArray[SliceOneResponse](jrpc.NewDestination(url + "?errror=true")) + if err == nil { + t.Errorf("expected error, got nil") + } + if slice != nil { + t.Errorf("expected nil slice, got %v", slice) + } +} ++++++ vendor.tar.gz ++++++
