mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
drop ioutil
The ioutil package is deprecated, with all of its functions having moved into os or io. Do the replacements so we stop having this impending.
This commit is contained in:
parent
cf94181c89
commit
c3b032d5cb
35 changed files with 191 additions and 218 deletions
9
api.go
9
api.go
|
|
@ -11,7 +11,6 @@ import (
|
|||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/url"
|
||||
"os"
|
||||
|
|
@ -803,7 +802,7 @@ func (api *API) FragmentBlockData(ctx context.Context, body io.Reader) (_ []byte
|
|||
return nil, errors.Wrap(err, "validating api method")
|
||||
}
|
||||
|
||||
reqBytes, err := ioutil.ReadAll(body)
|
||||
reqBytes, err := io.ReadAll(body)
|
||||
if err != nil {
|
||||
return nil, NewBadRequestError(errors.Wrap(err, "read body error"))
|
||||
}
|
||||
|
|
@ -1016,7 +1015,7 @@ func (api *API) ClusterMessage(ctx context.Context, reqBody io.Reader) error {
|
|||
}
|
||||
|
||||
// Read entire body.
|
||||
body, err := ioutil.ReadAll(reqBody)
|
||||
body, err := io.ReadAll(reqBody)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading body")
|
||||
}
|
||||
|
|
@ -2417,7 +2416,7 @@ func (api *API) TranslateIndexIDs(ctx context.Context, indexName string, ids []u
|
|||
// ErrTranslatingKeyNotFound error will be swallowed here, so the empty response will be returned.
|
||||
func (api *API) TranslateKeys(ctx context.Context, r io.Reader) (_ []byte, err error) {
|
||||
var req TranslateKeysRequest
|
||||
buf, err := ioutil.ReadAll(r)
|
||||
buf, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, NewBadRequestError(errors.Wrap(err, "read translate keys request error"))
|
||||
} else if err := api.Serializer.Unmarshal(buf, &req); err != nil {
|
||||
|
|
@ -2454,7 +2453,7 @@ func (api *API) TranslateKeys(ctx context.Context, r io.Reader) (_ []byte, err e
|
|||
// TranslateIDs handles a TranslateIDRequest.
|
||||
func (api *API) TranslateIDs(ctx context.Context, r io.Reader) (_ []byte, err error) {
|
||||
var req TranslateIDsRequest
|
||||
if buf, err := ioutil.ReadAll(r); err != nil {
|
||||
if buf, err := io.ReadAll(r); err != nil {
|
||||
return nil, NewBadRequestError(errors.Wrap(err, "read translate ids request error"))
|
||||
} else if err := api.Serializer.Unmarshal(buf, &req); err != nil {
|
||||
return nil, NewBadRequestError(errors.Wrap(err, "unmarshal translate ids request error"))
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ package authz
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/molecula/featurebase/v3/authn"
|
||||
|
||||
|
|
@ -54,7 +53,7 @@ func (p Permission) Satisfies(b Permission) bool {
|
|||
}
|
||||
|
||||
func (p *GroupPermissions) ReadPermissionsFile(permsFile io.Reader) (err error) {
|
||||
permsData, err := ioutil.ReadAll(permsFile)
|
||||
permsData, err := io.ReadAll(permsFile)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading permissions failed with error: %s", err)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ package client
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -670,7 +670,7 @@ func TestClientAgainstCluster(t *testing.T) {
|
|||
r, err := cli.ExportField(testFieldExport)
|
||||
require.NoErrorf(t, err, "ExportField")
|
||||
|
||||
b, err := ioutil.ReadAll(r)
|
||||
b, err := io.ReadAll(r)
|
||||
require.NoError(t, err)
|
||||
|
||||
target := "1,1\n1,10\n2,1048577\n"
|
||||
|
|
@ -695,7 +695,7 @@ func TestClientAgainstCluster(t *testing.T) {
|
|||
r, err := cli.ExportField(testFieldExport)
|
||||
require.NoErrorf(t, err, "ExportField")
|
||||
|
||||
b, err := ioutil.ReadAll(r)
|
||||
b, err := io.ReadAll(r)
|
||||
require.NoError(t, err)
|
||||
|
||||
target := "1,one\n1,ten\n2,big-number\n"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ package client
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
|
@ -92,7 +91,7 @@ func TestEncodeDecode(t *testing.T) {
|
|||
|
||||
})
|
||||
}
|
||||
buf, err := ioutil.TempFile("", "")
|
||||
buf, err := os.CreateTemp("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("getting temp file: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ package cmd_test
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
|
@ -33,7 +32,7 @@ func tExec(t *testing.T, cmd *cobra.Command, out io.Reader, w io.WriteCloser) (o
|
|||
done := make(chan struct{})
|
||||
var readErr error
|
||||
go func() {
|
||||
output, readErr = ioutil.ReadAll(out)
|
||||
output, readErr = io.ReadAll(out)
|
||||
close(done)
|
||||
}()
|
||||
err = cmd.Execute()
|
||||
|
|
@ -142,7 +141,7 @@ func (ct *commandTest) setupCommand(t *testing.T) *cobra.Command {
|
|||
os.Setenv("PILOSA_POSTGRES_BIND", "")
|
||||
|
||||
// make command and set args
|
||||
rc := cmd.NewRootCommand(strings.NewReader(""), ioutil.Discard, ioutil.Discard)
|
||||
rc := cmd.NewRootCommand(strings.NewReader(""), io.Discard, io.Discard)
|
||||
rc.SetArgs(ct.args)
|
||||
|
||||
err = cfgFile.Close()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
|
@ -193,7 +192,7 @@ func (cmd *BackupCommand) backupSchema(ctx context.Context, schema *pilosa.Schem
|
|||
return fmt.Errorf("marshaling schema: %w", err)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(filepath.Join(cmd.OutputDir, "schema"), buf, 0600); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(cmd.OutputDir, "schema"), buf, 0600); err != nil {
|
||||
return fmt.Errorf("writing schema: %w", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -188,7 +187,7 @@ func (cmd *CLICommand) executeCommands(ctx context.Context) error {
|
|||
}
|
||||
|
||||
var sqlResponse response
|
||||
fullbod, err := ioutil.ReadAll(resp.Body)
|
||||
fullbod, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading response")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
|
|
@ -302,7 +301,7 @@ func TestImportCommand_KeyReplication(t *testing.T) {
|
|||
|
||||
// Read body and unmarshal response.
|
||||
exp := `{"results":[50]}` + "\n"
|
||||
if body, err := ioutil.ReadAll(resp.Body); err != nil {
|
||||
if body, err := io.ReadAll(resp.Body); err != nil {
|
||||
return fmt.Errorf("reading: %s", err)
|
||||
} else if !reflect.DeepEqual(body, []byte(exp)) {
|
||||
return fmt.Errorf("expected: %s, but got: %s", exp, body)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
gohttp "net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
|
@ -171,7 +170,7 @@ func (cmd *RestoreTarCommand) Run(ctx context.Context) (err error) {
|
|||
return fmt.Errorf("no fragmentNodes available")
|
||||
}
|
||||
|
||||
shardBytes, err := ioutil.ReadAll(tarReader) // this feels wrong but works for now
|
||||
shardBytes, err := io.ReadAll(tarReader) // this feels wrong but works for now
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -200,7 +199,7 @@ func (cmd *RestoreTarCommand) Run(ctx context.Context) (err error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
shardBytes, err := ioutil.ReadAll(tarReader) // this feels wrong but works for now
|
||||
shardBytes, err := io.ReadAll(tarReader) // this feels wrong but works for now
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -228,7 +227,7 @@ func (cmd *RestoreTarCommand) Run(ctx context.Context) (err error) {
|
|||
case "translate":
|
||||
logger.Printf("field keys %v %v", indexName, fieldName)
|
||||
//needs to go to all nodes
|
||||
shardBytes, err := ioutil.ReadAll(tarReader) // this feels wrong but works for now
|
||||
shardBytes, err := io.ReadAll(tarReader) // this feels wrong but works for now
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/rand"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
|
@ -6884,7 +6884,7 @@ func TestExecutor_Execute_NoIndex(t *testing.T) {
|
|||
func TestExecutor_Execute_CountDistinct(t *testing.T) {
|
||||
// This schema has indexes named e, p, and s. We can then
|
||||
// use c.Idx(e) or Sprintf(%e, idx) to match these names up.
|
||||
data, err := ioutil.ReadFile("testdata/schema.json")
|
||||
data, err := os.ReadFile("testdata/schema.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -7124,7 +7124,7 @@ func TestExecutor_BareDistinct(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExecutor_Execute_TopNDistinct(t *testing.T) {
|
||||
data, err := ioutil.ReadFile("testdata/schema.json")
|
||||
data, err := os.ReadFile("testdata/schema.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -7204,7 +7204,7 @@ func Test_Executor_Execute_UnionRows(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTimelessClearRegression(t *testing.T) {
|
||||
data, err := ioutil.ReadFile("testdata/timeRegressionSchema.json")
|
||||
data, err := os.ReadFile("testdata/timeRegressionSchema.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
15
fragment.go
15
fragment.go
|
|
@ -10,7 +10,6 @@ import (
|
|||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/bits"
|
||||
"os"
|
||||
|
|
@ -227,7 +226,7 @@ func (f *fragment) openCache() error {
|
|||
|
||||
// Read cache data from disk.
|
||||
path := f.cachePath()
|
||||
buf, err := ioutil.ReadFile(path)
|
||||
buf, err := os.ReadFile(path)
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
|
|
@ -2578,7 +2577,7 @@ func (f *fragment) flushCache() error {
|
|||
return errors.Wrap(err, "mkdir")
|
||||
}
|
||||
// Write to disk.
|
||||
if err := ioutil.WriteFile(f.cachePath(), buf, 0600); err != nil {
|
||||
if err := os.WriteFile(f.cachePath(), buf, 0600); err != nil {
|
||||
return errors.Wrap(err, "writing")
|
||||
}
|
||||
|
||||
|
|
@ -2641,7 +2640,7 @@ func (f *fragment) writeCacheToArchive(tw *tar.Writer) error {
|
|||
defer f.mu.Unlock()
|
||||
|
||||
// Read cache into buffer.
|
||||
buf, err := ioutil.ReadFile(f.cachePath())
|
||||
buf, err := os.ReadFile(f.cachePath())
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
|
|
@ -2710,9 +2709,9 @@ func (f *fragment) fillFragmentFromArchive(tx Tx, r io.Reader) error {
|
|||
|
||||
// this is reading from inside a tarball, so definitely no need
|
||||
// to close it here.
|
||||
data, err := ioutil.ReadAll(r)
|
||||
data, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fillFragmentFromArchive ioutil.ReadAll(r)")
|
||||
return errors.Wrap(err, "fillFragmentFromArchive io.ReadAll(r)")
|
||||
}
|
||||
if len(data) == 0 {
|
||||
return nil
|
||||
|
|
@ -2737,10 +2736,10 @@ func (f *fragment) fillFragmentFromArchive(tx Tx, r io.Reader) error {
|
|||
|
||||
func (f *fragment) readCacheFromArchive(r io.Reader) error {
|
||||
// Slurp data from reader and write to disk.
|
||||
buf, err := ioutil.ReadAll(r)
|
||||
buf, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading")
|
||||
} else if err := ioutil.WriteFile(f.cachePath(), buf, 0600); err != nil {
|
||||
} else if err := os.WriteFile(f.cachePath(), buf, 0600); err != nil {
|
||||
return errors.Wrap(err, "writing")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ package hash
|
|||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
|
@ -54,19 +53,19 @@ func TestHashOfDir(t *testing.T) {
|
|||
}
|
||||
|
||||
bmessage := []byte("hello B\n")
|
||||
if err := ioutil.WriteFile(path.Join(b, "b_content"), bmessage, 0644); err != nil {
|
||||
if err := os.WriteFile(path.Join(b, "b_content"), bmessage, 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cmessage := []byte("hello C\n")
|
||||
if err := ioutil.WriteFile(path.Join(c, "c_content"), cmessage, 0644); err != nil {
|
||||
if err := os.WriteFile(path.Join(c, "c_content"), cmessage, 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
hsh := HashOfDir(dir)
|
||||
|
||||
c2message := []byte("hello C2\n")
|
||||
if err := ioutil.WriteFile(path.Join(c, "c_content"), c2message, 0644); err != nil {
|
||||
if err := os.WriteFile(path.Join(c, "c_content"), c2message, 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3438,7 +3438,7 @@ func (h *Handler) handlePostImportRoaring(w http.ResponseWriter, r *http.Request
|
|||
ctx := r.Context()
|
||||
|
||||
// Read entire body.
|
||||
span, _ := tracing.StartSpanFromContext(ctx, "ioutil.ReadAll-Body")
|
||||
span, _ := tracing.StartSpanFromContext(ctx, "io.ReadAll-Body")
|
||||
body, err := readBody(r)
|
||||
span.LogKV("bodySize", len(body))
|
||||
span.Finish()
|
||||
|
|
@ -3511,7 +3511,7 @@ func (h *Handler) handlePostShardImportRoaring(w http.ResponseWriter, r *http.Re
|
|||
ctx := r.Context()
|
||||
|
||||
// Read entire body.
|
||||
span, _ := tracing.StartSpanFromContext(ctx, "ioutil.ReadAll-Body")
|
||||
span, _ := tracing.StartSpanFromContext(ctx, "io.ReadAll-Body")
|
||||
body, err := readBody(r)
|
||||
span.LogKV("bodySize", len(body))
|
||||
span.Finish()
|
||||
|
|
@ -3580,7 +3580,7 @@ func (h *Handler) handlePostIngestNode(w http.ResponseWriter, r *http.Request) {
|
|||
ctx := r.Context()
|
||||
|
||||
// Read entire body.
|
||||
span, _ := tracing.StartSpanFromContext(ctx, "ioutil.ReadAll-Body")
|
||||
span, _ := tracing.StartSpanFromContext(ctx, "io.ReadAll-Body")
|
||||
body, err := readBody(r)
|
||||
span.LogKV("bodySize", len(body))
|
||||
span.Finish()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
|
|
@ -186,7 +186,7 @@ func TestFieldOptionValidation(t *testing.T) {
|
|||
func readResponse(w *httptest.ResponseRecorder) ([]byte, error) {
|
||||
res := w.Result()
|
||||
defer res.Body.Close()
|
||||
return ioutil.ReadAll(res.Body)
|
||||
return io.ReadAll(res.Body)
|
||||
}
|
||||
|
||||
// common variables used for testing auth
|
||||
|
|
@ -703,7 +703,7 @@ func TestChkAuthN(t *testing.T) {
|
|||
r.Header.Add("Authorization", test.token)
|
||||
test.handler(w, r)
|
||||
resp := w.Result()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
gohttp "net/http"
|
||||
|
|
@ -762,7 +762,7 @@ admin: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe"`
|
|||
|
||||
tmpDir := t.TempDir()
|
||||
permissionsPath := path.Join(tmpDir, "test-permissions.yaml")
|
||||
err := ioutil.WriteFile(permissionsPath, []byte(permissions1), 0600)
|
||||
err := os.WriteFile(permissionsPath, []byte(permissions1), 0600)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to write permissions file: %v", err)
|
||||
}
|
||||
|
|
@ -924,7 +924,7 @@ admin: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe"`
|
|||
}
|
||||
|
||||
if ipTest.StatusCode == 200 {
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("reading resp body :%v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
|
@ -108,7 +107,7 @@ func (r *HTTPTranslateEntryReader) Open() error {
|
|||
r.body.Close()
|
||||
return ErrNotImplemented
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
r.body.Close()
|
||||
return fmt.Errorf("http: invalid translate store endpoint status: code=%d url=%s body=%q", resp.StatusCode, r.URL, bytes.TrimSpace(body))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/bits"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
@ -377,7 +376,7 @@ func (ps *pilosaIDManager) reserve(ctx context.Context, reserveReq pilosacore.ID
|
|||
err = errors.Wrap(cerr, "closing ID reservation request body")
|
||||
}
|
||||
}()
|
||||
body, err = ioutil.ReadAll(resp.Body)
|
||||
body, err = io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading ID reservation request body")
|
||||
}
|
||||
|
|
@ -442,7 +441,7 @@ func (ps *pilosaIDManager) commit(ctx context.Context, commitRequest pilosacore.
|
|||
err = errors.Wrap(cerr, "closing ID reservation request body")
|
||||
}
|
||||
}()
|
||||
body, err = ioutil.ReadAll(resp.Body)
|
||||
body, err = io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading ID reservation request body")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -436,7 +435,7 @@ func TestIngesterServesPrometheusEndpoint(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("request error: %v", err)
|
||||
}
|
||||
contents, err := ioutil.ReadAll(response.Body)
|
||||
contents, err := io.ReadAll(response.Body)
|
||||
defer response.Body.Close()
|
||||
if err != nil {
|
||||
t.Errorf("read error: %v", err)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package idk
|
|||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
|
@ -148,7 +147,7 @@ func getCertPool(capath string) (*x509.CertPool, error) {
|
|||
)
|
||||
caCertData = []byte(capath)
|
||||
} else {
|
||||
caCertData, err = ioutil.ReadFile(capath)
|
||||
caCertData, err = os.ReadFile(capath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "loading tls ca key")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
|
@ -747,7 +746,7 @@ func (codec *JSONCodec) ParseOperation(data []byte, seq int) (op *Operation, err
|
|||
// Parse reads a request, but does not sort the results at all or divide
|
||||
// them into shards.
|
||||
func (codec *JSONCodec) Parse(r io.Reader) (req *Request, err error) {
|
||||
data, err := ioutil.ReadAll(r)
|
||||
data, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
|
@ -233,7 +232,7 @@ func testQueries(t *testing.T, ctx context.Context, cmd *test.Command, index str
|
|||
|
||||
// testOneIngestTestcase runs a set of actions, then cleans up after itself
|
||||
func testOneIngestTestcase(t *testing.T, ctx context.Context, cmd *test.Command, tcpath string) {
|
||||
data, err := ioutil.ReadFile(tcpath)
|
||||
data, err := os.ReadFile(tcpath)
|
||||
if err != nil {
|
||||
t.Fatalf("reading %q: %v", tcpath, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
|
@ -421,7 +420,7 @@ func (c *InternalClient) IngestSchema(ctx context.Context, uri *pnet.URI, buf []
|
|||
return nil, errors.Wrap(err, "executing request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
buf, err = ioutil.ReadAll(resp.Body)
|
||||
buf, err = io.ReadAll(resp.Body)
|
||||
if resp.StatusCode != 200 {
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "bad status '%s' and err reading body", resp.Status)
|
||||
|
|
@ -439,7 +438,7 @@ func (c *InternalClient) IngestSchema(ctx context.Context, uri *pnet.URI, buf []
|
|||
}
|
||||
return nil, errors.Errorf("against %s %s: '%s'", req.URL.String(), resp.Status, msg)
|
||||
}
|
||||
// this is the err from ioutil.ReadAll, but in the case where resp.StatusCode
|
||||
// this is the err from io.ReadAll, but in the case where resp.StatusCode
|
||||
// was 2xx, so we don't have a bad status.
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error reading response body")
|
||||
|
|
@ -728,7 +727,7 @@ func (c *InternalClient) QueryNode(ctx context.Context, uri *pnet.URI, index str
|
|||
defer resp.Body.Close()
|
||||
|
||||
// Read body and unmarshal response.
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading")
|
||||
}
|
||||
|
|
@ -816,7 +815,7 @@ func (c *InternalClient) importNode(ctx context.Context, node *disco.Node, index
|
|||
defer resp.Body.Close()
|
||||
|
||||
// Read body and unmarshal response.
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading")
|
||||
}
|
||||
|
|
@ -1339,7 +1338,7 @@ func (c *InternalClient) BlockData(ctx context.Context, uri *pnet.URI, index, fi
|
|||
|
||||
// Decode response object.
|
||||
var rsp BlockDataResponse
|
||||
if body, err := ioutil.ReadAll(resp.Body); err != nil {
|
||||
if body, err := io.ReadAll(resp.Body); err != nil {
|
||||
return nil, nil, errors.Wrap(err, "reading")
|
||||
} else if err := c.serializer.Unmarshal(body, &rsp); err != nil {
|
||||
return nil, nil, errors.Wrap(err, "unmarshalling")
|
||||
|
|
@ -1372,7 +1371,7 @@ func (c *InternalClient) SendMessage(ctx context.Context, uri *pnet.URI, msg []b
|
|||
return errors.Wrap(err, "executing request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
_, err = io.Copy(ioutil.Discard, resp.Body)
|
||||
_, err = io.Copy(io.Discard, resp.Body)
|
||||
return errors.Wrap(err, "draining SendMessage response body")
|
||||
}
|
||||
|
||||
|
|
@ -1421,7 +1420,7 @@ func (c *InternalClient) TranslateKeysNode(ctx context.Context, uri *pnet.URI, i
|
|||
defer resp.Body.Close()
|
||||
|
||||
// Read body and unmarshal response.
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading")
|
||||
}
|
||||
|
|
@ -1473,7 +1472,7 @@ func (c *InternalClient) TranslateIDsNode(ctx context.Context, uri *pnet.URI, in
|
|||
defer resp.Body.Close()
|
||||
|
||||
// Read body and unmarshal response.
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading")
|
||||
}
|
||||
|
|
@ -1505,7 +1504,7 @@ func (c *InternalClient) GetPastQueries(ctx context.Context, uri *pnet.URI) ([]P
|
|||
defer resp.Body.Close()
|
||||
|
||||
// Read body and unmarshal response.
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading")
|
||||
}
|
||||
|
|
@ -1552,7 +1551,7 @@ func (c *InternalClient) FindIndexKeysNode(ctx context.Context, uri *pnet.URI, i
|
|||
}()
|
||||
|
||||
// Read the response body.
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
result, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading response")
|
||||
}
|
||||
|
|
@ -1601,7 +1600,7 @@ func (c *InternalClient) FindFieldKeysNode(ctx context.Context, uri *pnet.URI, i
|
|||
}()
|
||||
|
||||
// Read the response body.
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
result, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading response")
|
||||
}
|
||||
|
|
@ -1651,7 +1650,7 @@ func (c *InternalClient) CreateIndexKeysNode(ctx context.Context, uri *pnet.URI,
|
|||
}()
|
||||
|
||||
// Read the response body.
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
result, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading response")
|
||||
}
|
||||
|
|
@ -1704,7 +1703,7 @@ func (c *InternalClient) CreateFieldKeysNode(ctx context.Context, uri *pnet.URI,
|
|||
}()
|
||||
|
||||
// Read the response body.
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
result, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading response")
|
||||
}
|
||||
|
|
@ -1749,7 +1748,7 @@ func (c *InternalClient) MatchFieldKeysNode(ctx context.Context, uri *pnet.URI,
|
|||
}()
|
||||
|
||||
// Read the response body.
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
result, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading response")
|
||||
}
|
||||
|
|
@ -1781,7 +1780,7 @@ func (c *InternalClient) Transactions(ctx context.Context) (map[string]*Transact
|
|||
return nil, errors.Wrap(err, "executing request")
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(ioutil.Discard, resp.Body)
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
trnsMap := make(map[string]*Transaction)
|
||||
|
|
@ -1820,7 +1819,7 @@ func (c *InternalClient) StartTransaction(ctx context.Context, id string, timeou
|
|||
return nil, errors.Wrap(err, "executing request")
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(ioutil.Discard, resp.Body)
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
tr := &TransactionResponse{}
|
||||
|
|
@ -1855,7 +1854,7 @@ func (c *InternalClient) FinishTransaction(ctx context.Context, id string) (*Tra
|
|||
return nil, errors.Wrap(err, "executing request")
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(ioutil.Discard, resp.Body)
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
tr := &TransactionResponse{}
|
||||
|
|
@ -1892,7 +1891,7 @@ func (c *InternalClient) GetTransaction(ctx context.Context, id string) (*Transa
|
|||
return nil, errors.Wrap(err, "executing request")
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(ioutil.Discard, resp.Body)
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
tr := &TransactionResponse{}
|
||||
|
|
@ -1994,7 +1993,7 @@ func (c *InternalClient) handleResponse(req *http.Request, eo *executeOpts, resp
|
|||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
defer resp.Body.Close()
|
||||
buf, err := ioutil.ReadAll(resp.Body)
|
||||
buf, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return resp, errors.Wrapf(err, "bad status '%s' and err reading body", resp.Status)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
|
@ -35,14 +34,13 @@ import (
|
|||
|
||||
// TestReopenAppend -- make sure we always append to an existing file
|
||||
//
|
||||
// 1. Create a sample file using normal means
|
||||
// 2. Open a ioreopen.File
|
||||
// write line 1
|
||||
// 3. call Reopen
|
||||
// write line 2
|
||||
// 4. close file
|
||||
// 5. read file, make sure it contains line0,line1,line2
|
||||
//
|
||||
// 1. Create a sample file using normal means
|
||||
// 2. Open a ioreopen.File
|
||||
// write line 1
|
||||
// 3. call Reopen
|
||||
// write line 2
|
||||
// 4. close file
|
||||
// 5. read file, make sure it contains line0,line1,line2
|
||||
func TestReopenAppend(t *testing.T) {
|
||||
forig, err := testhook.TempFile(t, "logger-reopen")
|
||||
if err != nil {
|
||||
|
|
@ -83,7 +81,7 @@ func TestReopenAppend(t *testing.T) {
|
|||
t.Errorf("Got closing error for %s: %s", fname, err)
|
||||
}
|
||||
|
||||
out, err := ioutil.ReadFile(fname)
|
||||
out, err := os.ReadFile(fname)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable read in final file %s: %s", fname, err)
|
||||
}
|
||||
|
|
@ -152,7 +150,7 @@ func TestChangeInode(t *testing.T) {
|
|||
t.Errorf("Got closing error for %s: %s", fname, err)
|
||||
}
|
||||
|
||||
out, err := ioutil.ReadFile(fname)
|
||||
out, err := os.ReadFile(fname)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable read in final file %s: %s", fname, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -257,5 +256,5 @@ func (b *bufferLogger) Panicf(format string, v ...interface{}) {
|
|||
func (b *bufferLogger) ReadAll() ([]byte, error) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
return ioutil.ReadAll(b.buf)
|
||||
return io.ReadAll(b.buf)
|
||||
}
|
||||
|
|
|
|||
3
pb/pb.go
3
pb/pb.go
|
|
@ -3,7 +3,6 @@ package pb
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
|
@ -51,7 +50,7 @@ func NewDecoder(r io.Reader) *Decoder {
|
|||
|
||||
// Decode reads all bytes from the reader and unmarshals them into pb.
|
||||
func (dec *Decoder) Decode(pb proto.Message) error {
|
||||
buf, err := ioutil.ReadAll(dec.r)
|
||||
buf, err := io.ReadAll(dec.r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ package pql
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
|
@ -39,7 +38,7 @@ func ParseString(s string) (*Query, error) {
|
|||
|
||||
// Parse parses the next node in the query.
|
||||
func (p *parser) Parse() (*Query, error) {
|
||||
buf, err := ioutil.ReadAll(p.r)
|
||||
buf, err := io.ReadAll(p.r)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading buffer to parse")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ package roaring
|
|||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
|
|
@ -292,7 +291,7 @@ func bytesToUint64s(data []byte) []uint64 {
|
|||
// make sure filename is not already in the corpus.
|
||||
func addSliceToCorpus(slice []uint64, filename, path string) {
|
||||
data := uint64sToBytes(slice)
|
||||
err := ioutil.WriteFile(path+"/"+filename, data, 0750)
|
||||
err := os.WriteFile(path+"/"+filename, data, 0750)
|
||||
if err != nil {
|
||||
fmt.Printf("could not write to file: %v\n", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
|
@ -2021,7 +2021,7 @@ func TestXorArrayRun(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
//special case that didn't fit the xorrunrun table testing below.
|
||||
// special case that didn't fit the xorrunrun table testing below.
|
||||
func TestXorRunRun1(t *testing.T) {
|
||||
a := NewContainerRun([]Interval16{{Start: 4, Last: 10}})
|
||||
b := NewContainerRun([]Interval16{{Start: 5, Last: 10}})
|
||||
|
|
@ -3778,7 +3778,7 @@ func TestContainerCombinations(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
//func getFunc(func(a, b *container) *container, m, n *container) *container {
|
||||
// func getFunc(func(a, b *container) *container, m, n *container) *container {
|
||||
func runContainerFunc(f interface{}, c ...*Container) *Container {
|
||||
switch f := f.(type) {
|
||||
case func(*Container) *Container:
|
||||
|
|
@ -3821,7 +3821,7 @@ func TestUnmarshalRoaringWithNoErrors(t *testing.T) {
|
|||
t.Fatalf("hex decode %s", err)
|
||||
}
|
||||
} else {
|
||||
testContainer, _ = ioutil.ReadFile(testCase.roaringFileName)
|
||||
testContainer, _ = os.ReadFile(testCase.roaringFileName)
|
||||
}
|
||||
bm := NewBitmap()
|
||||
err = bm.UnmarshalBinary(testContainer)
|
||||
|
|
@ -3889,24 +3889,25 @@ func newTestBitmapContainer() *Container {
|
|||
/*
|
||||
// This function exercises an arcane edge case in dead code.
|
||||
// It doesn't need to be run right now.
|
||||
func TestEquals(t *testing.T) {
|
||||
bma := NewBitmap()
|
||||
bmr := NewBitmap()
|
||||
for i := uint64(0); i < 30; i++ {
|
||||
bma.Add(i)
|
||||
bmr.Add(i)
|
||||
|
||||
func TestEquals(t *testing.T) {
|
||||
bma := NewBitmap()
|
||||
bmr := NewBitmap()
|
||||
for i := uint64(0); i < 30; i++ {
|
||||
bma.Add(i)
|
||||
bmr.Add(i)
|
||||
}
|
||||
bmr.Optimize()
|
||||
bmi := bma.Intersect(bmr)
|
||||
err := bitmapsEqual(bmi, bma)
|
||||
if err != nil {
|
||||
t.Fatalf("expected intersection to equal array")
|
||||
}
|
||||
err = bitmapsEqual(bmi, bmr)
|
||||
if err != nil {
|
||||
t.Fatalf("expected intersection to equal run")
|
||||
}
|
||||
}
|
||||
bmr.Optimize()
|
||||
bmi := bma.Intersect(bmr)
|
||||
err := bitmapsEqual(bmi, bma)
|
||||
if err != nil {
|
||||
t.Fatalf("expected intersection to equal array")
|
||||
}
|
||||
err = bitmapsEqual(bmi, bmr)
|
||||
if err != nil {
|
||||
t.Fatalf("expected intersection to equal run")
|
||||
}
|
||||
}
|
||||
*/
|
||||
func TestShiftArray(t *testing.T) {
|
||||
tests := []struct {
|
||||
|
|
@ -4563,7 +4564,6 @@ func TestRoaringIteratorSkip(t *testing.T) {
|
|||
// large an run container, which was causing problems when
|
||||
// we write to the transactional backends. Verify that
|
||||
// unionRunRunInPlace() converts to bitmap if its too large.
|
||||
//
|
||||
func TestContainer_unionRunRunInPlace_TwoBigRunArrays(t *testing.T) {
|
||||
|
||||
a := NewContainerRun(nil)
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
gohttp "net/http"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"reflect"
|
||||
"sort"
|
||||
|
|
@ -37,8 +36,8 @@ func TestHandler_PostSchemaCluster(t *testing.T) {
|
|||
t.Run("PostSchema", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/schema", strings.NewReader(`{"indexes":[{"name":"blah","options":{"keys":false,"trackExistence":true},"fields":[{"name":"f1","options":{"type":"set","cacheType":"ranked","cacheSize":50000,"keys":false}}],"shardWidth":1048576}]}`)))
|
||||
if w.Code != gohttp.StatusNoContent {
|
||||
bod, err := ioutil.ReadAll(w.Result().Body)
|
||||
if w.Code != http.StatusNoContent {
|
||||
bod, err := io.ReadAll(w.Result().Body)
|
||||
if err != nil {
|
||||
t.Errorf("reading body: %v", err)
|
||||
}
|
||||
|
|
@ -80,7 +79,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Not Found", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/no_such_path", nil))
|
||||
if w.Code != gohttp.StatusNotFound {
|
||||
if w.Code != http.StatusNotFound {
|
||||
t.Fatalf("invalid status: %d", w.Code)
|
||||
}
|
||||
})
|
||||
|
|
@ -88,7 +87,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("SchemaEmpty", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
body := w.Body.String()
|
||||
|
|
@ -101,7 +100,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("SchemaDetailsEmpty", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema/details", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
body := w.Body.String()
|
||||
|
|
@ -114,8 +113,8 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("PostSchema", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/schema", strings.NewReader(`{"indexes":[{"name":"blah","options":{"keys":false,"trackExistence":true},"fields":[{"name":"f1","options":{"type":"set","cacheType":"ranked","cacheSize":50000,"keys":false}}],"shardWidth":1048576}]}`)))
|
||||
if w.Code != gohttp.StatusNoContent {
|
||||
bod, err := ioutil.ReadAll(w.Result().Body)
|
||||
if w.Code != http.StatusNoContent {
|
||||
bod, err := io.ReadAll(w.Result().Body)
|
||||
if err != nil {
|
||||
t.Errorf("reading body: %v", err)
|
||||
}
|
||||
|
|
@ -143,7 +142,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Info", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/info", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
var details map[string]interface{}
|
||||
|
|
@ -207,7 +206,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Schema", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +290,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("SchemaDetails", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema/details", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +464,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Status", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/status", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
ret := mustJSONDecode(t, w.Body)
|
||||
|
|
@ -481,7 +480,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
// This tests the response structure, not the cluster behavior.
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/ui/shard-distribution", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -506,7 +505,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Metrics", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/metrics", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
})
|
||||
|
|
@ -514,7 +513,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Metrics.json", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/metrics.json", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
mustJSONDecode(t, w.Body)
|
||||
|
|
@ -533,7 +532,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Max Shard", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/internal/shards/max", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"standard":{"i0":3,"i1":0,"i2":0}}`+"\n" {
|
||||
t.Fatalf("unexpected body: %s", body)
|
||||
|
|
@ -543,7 +542,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Shards args", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i0/query?shards=0,1", strings.NewReader("Count(Row(f0=30))")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d %s", w.Code, w.Body.String())
|
||||
} else if body := w.Body.String(); body != `{"results":[2]}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", body)
|
||||
|
|
@ -567,7 +566,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, req)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"results":[2]}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", body)
|
||||
|
|
@ -580,7 +579,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Query args error", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i0/query?shards=a,b", strings.NewReader("Count(Row(f0=30))")))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"invalid shard argument"}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", body)
|
||||
|
|
@ -590,7 +589,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Query params err", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i0/query?shards=0,1&db=sample", strings.NewReader("Count(Row(f0=30))")))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"db is not a valid argument"}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", body)
|
||||
|
|
@ -602,7 +601,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
r := test.MustNewHTTPRequest("POST", "/index/i0/query", strings.NewReader("Count(Row(f0=30))"))
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -619,7 +618,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Row JSON", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i0/query", strings.NewReader("Row(f0=30)")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != fmt.Sprintf(`{"results":[{"columns":[%d,%d,%d]}]}`, pilosa.ShardWidth+1, pilosa.ShardWidth+2, 3*pilosa.ShardWidth+4)+"\n" {
|
||||
t.Fatalf("unexpected body: %s", body)
|
||||
|
|
@ -631,7 +630,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
r := test.MustNewHTTPRequest("POST", "/index/i0/query", strings.NewReader("Row(f0=30)"))
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -646,7 +645,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Query Pairs JSON", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i0/query", strings.NewReader(`TopN(f0, n=2)`)))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"results":[[{"id":30,"key":"","count":3},{"id":31,"key":"","count":1}]]}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", body)
|
||||
|
|
@ -658,7 +657,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
r := test.MustNewHTTPRequest("POST", "/index/i0/query", strings.NewReader(`TopN(f0, n=2)`))
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -673,7 +672,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Query err JSON", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i0/query", strings.NewReader(`Row(row=30)`)))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"executing: translating call: validating value for field \"row\": field not found"}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", body)
|
||||
|
|
@ -685,7 +684,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
r := test.MustNewHTTPRequest("POST", "/index/i0/query", strings.NewReader(`Row(row=30)`))
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -710,12 +709,12 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
fieldName := "f-int-ubound"
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName),
|
||||
strings.NewReader(`{"options":{"type":"int"}}`)))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
w = httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", strings.NewReader("")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
rsp := getSchemaResponse{}
|
||||
|
|
@ -741,12 +740,12 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
fieldName := "f-int-ubound-min"
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName),
|
||||
strings.NewReader(`{"options":{"type":"int", "max": 10}}`)))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
w = httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", strings.NewReader("")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
rsp := getSchemaResponse{}
|
||||
|
|
@ -772,12 +771,12 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
fieldName := "f-int-ubound-max"
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName),
|
||||
strings.NewReader(`{"options":{"type":"int", "min": -10}}`)))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
w = httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", strings.NewReader("")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
rsp := getSchemaResponse{}
|
||||
|
|
@ -803,7 +802,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
fieldName := "f-int-ubound-err"
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName),
|
||||
strings.NewReader(`{"options":{"type":"int", "min": 10, "max": -10}}`)))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
})
|
||||
|
|
@ -813,12 +812,12 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
fieldName := "f-decimal-ubound"
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName),
|
||||
strings.NewReader(`{"options":{"type":"decimal", "scale": 0}}`)))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
w = httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", strings.NewReader("")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
rsp := getSchemaResponse{}
|
||||
|
|
@ -844,13 +843,13 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
fieldName := "f-decimal-ubound-min"
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName),
|
||||
strings.NewReader(`{"options":{"type":"decimal", "scale": 1, "max": 10.5}}`)))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
fmt.Println(w.Body.String())
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
w = httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", strings.NewReader("")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
rsp := getSchemaResponse{}
|
||||
|
|
@ -875,13 +874,13 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
fieldName := "f-decimal-scale-only"
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName),
|
||||
strings.NewReader(`{"options":{"type":"decimal", "scale": 2}}`)))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
fmt.Println(w.Body.String())
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
w = httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", strings.NewReader("")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
rsp := getSchemaResponse{}
|
||||
|
|
@ -909,7 +908,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName),
|
||||
strings.NewReader(`{"options":{"type":"decimal"}}`)))
|
||||
expErr := "decimal field requires a scale argument"
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if !strings.Contains(w.Body.String(), expErr) {
|
||||
t.Fatalf("expected error to contain: %s, but got: %s", expErr, w.Body.String())
|
||||
|
|
@ -919,7 +918,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Method not allowed", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/index/i0/query", nil))
|
||||
if w.Code != gohttp.StatusMethodNotAllowed {
|
||||
if w.Code != http.StatusMethodNotAllowed {
|
||||
t.Fatalf("invalid status: %d", w.Code)
|
||||
}
|
||||
})
|
||||
|
|
@ -927,7 +926,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Err Parse", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?shards=0,1", strings.NewReader("bad_fn(")))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"parsing: parsing: \nparse error near IDENT (line 1 symbol 1 - line 1 symbol 4):\n\"bad\"\n"}`+"\n" {
|
||||
t.Fatalf("unexpected body: %s", body)
|
||||
|
|
@ -938,7 +937,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("DELETE", "/index/i", strings.NewReader("")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d, body: %s", w.Code, w.Body.String())
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -963,7 +962,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
}
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("DELETE", "/index/i/field/f1", strings.NewReader("")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d, body: %s", w.Code, w.Body.String())
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -987,7 +986,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
r := test.MustNewHTTPRequest("GET", "/version", nil)
|
||||
h.ServeHTTP(w, r)
|
||||
version := strings.TrimPrefix(pilosa.Version, "v")
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if w.Body.String() != `{"version":"`+version+`"}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", w.Body.String())
|
||||
|
|
@ -998,7 +997,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w := httptest.NewRecorder()
|
||||
r := test.MustNewHTTPRequest("GET", "/internal/fragment/nodes?index=i&shard=0", nil)
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
body := mustJSONDecodeSlice(t, w.Body)
|
||||
|
|
@ -1011,7 +1010,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("GET", "/internal/fragment/nodes?db=X&shard=0", nil)
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -1019,7 +1018,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("GET", "/internal/fragment/nodes?shard=0", nil)
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
})
|
||||
|
|
@ -1028,7 +1027,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w := httptest.NewRecorder()
|
||||
r := test.MustNewHTTPRequest("GET", "/debug/vars", nil)
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
})
|
||||
|
|
@ -1036,7 +1035,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Run("Recalculate Caches", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/recalculate-caches", nil))
|
||||
if w.Code != gohttp.StatusNoContent {
|
||||
if w.Code != http.StatusNoContent {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
})
|
||||
|
|
@ -1077,7 +1076,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w := httptest.NewRecorder()
|
||||
r := test.MustNewHTTPRequest("POST", "/index/idx1", strings.NewReader(""))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1093,7 +1092,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/index/idx1", strings.NewReader(""))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusConflict {
|
||||
if w.Code != http.StatusConflict {
|
||||
t.Errorf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1111,7 +1110,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/index/idx1/field/fld1", strings.NewReader(""))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1129,7 +1128,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/index/idx1/field/fld1", strings.NewReader(""))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusConflict {
|
||||
if w.Code != http.StatusConflict {
|
||||
t.Errorf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1147,7 +1146,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("DELETE", "/index/idx1/field/fld1", strings.NewReader(""))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1163,7 +1162,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("DELETE", "/index/idx1/field/fld1", strings.NewReader(""))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusNotFound {
|
||||
if w.Code != http.StatusNotFound {
|
||||
t.Errorf("unexpected status code: %d", w.Code)
|
||||
} else if w.Body.String() != `{"success":false,"error":{"message":"deleting field: fld1: field not found"}}`+"\n" {
|
||||
t.Errorf("unexpected body: %q", w.Body.String())
|
||||
|
|
@ -1173,7 +1172,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("DELETE", "/index/idx1", strings.NewReader(""))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1189,7 +1188,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("DELETE", "/index/idx1", strings.NewReader(""))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusNotFound {
|
||||
if w.Code != http.StatusNotFound {
|
||||
t.Errorf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1207,7 +1206,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w := httptest.NewRecorder()
|
||||
r := test.MustNewHTTPRequest("POST", "/index/i1-tr", strings.NewReader(`{"options":{"keys":true}}`))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1223,7 +1222,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/index/i1-tr/field/f1", strings.NewReader(`{"options":{"keys":true}}`))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else {
|
||||
var resp struct {
|
||||
|
|
@ -1239,7 +1238,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/index/i1-tr/query", strings.NewReader(`Set("col1", f1="row1")`))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
|
|
@ -1257,7 +1256,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
r.Header.Set("Content-Type", "application/x-protobuf")
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
var target []uint64
|
||||
|
|
@ -1290,7 +1289,7 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
r.Header.Set("Content-Type", "application/x-protobuf")
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
target = []uint64{1, 2}
|
||||
|
|
@ -1433,12 +1432,12 @@ func TestQueryHistory(t *testing.T) {
|
|||
test.Do(t, "POST", cmd.URL()+"/index/i0/query", "TopN(f0)")
|
||||
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/query-history", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d %s", w.Code, w.Body.String())
|
||||
}
|
||||
|
||||
ret := make([]pilosa.PastQueryStatus, 4)
|
||||
b, err := ioutil.ReadAll(w.Body)
|
||||
b, err := io.ReadAll(w.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("reading: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net"
|
||||
|
|
@ -189,7 +188,7 @@ func (m *Command) doSetupResourceLimits() error {
|
|||
}
|
||||
// We don't have corresponding options for non-Linux right now, but probably should.
|
||||
if runtime.GOOS == "linux" {
|
||||
result, err := ioutil.ReadFile("/proc/sys/vm/max_map_count")
|
||||
result, err := os.ReadFile("/proc/sys/vm/max_map_count")
|
||||
if err != nil {
|
||||
m.logger.Infof("Tried unsuccessfully to check system mmap limit: %w", err)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
nethttp "net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
|
@ -697,7 +697,7 @@ func TestMain_ImportTimestamp(t *testing.T) {
|
|||
}
|
||||
// Ensure the correct views were created.
|
||||
dir := fmt.Sprintf("%s/%s/%s/%s/%s/views", m.Config.DataDir, pilosa.IndexesDir, indexName, pilosa.FieldsDir, fieldName)
|
||||
files, err := ioutil.ReadDir(dir)
|
||||
files, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -753,7 +753,7 @@ func TestMain_ImportTimestampNoStandardView(t *testing.T) {
|
|||
|
||||
// Ensure the correct views were created.
|
||||
dir := fmt.Sprintf("%s/%s/%s/%s/%s/views", m.Config.DataDir, pilosa.IndexesDir, indexName, pilosa.FieldsDir, fieldName)
|
||||
files, err := ioutil.ReadDir(dir)
|
||||
files, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import (
|
|||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync"
|
||||
|
|
@ -135,7 +134,7 @@ func GetTLSConfig(tlsConfig *TLSConfig, logger logger.Logger) (TLSConfig *tls.Co
|
|||
}
|
||||
|
||||
if hasCA {
|
||||
b, err := ioutil.ReadFile(tlsConfig.CACertPath)
|
||||
b, err := os.ReadFile(tlsConfig.CACertPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "loading tls ca key")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
gohttp "net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
|
|
@ -19,7 +19,7 @@ import (
|
|||
"github.com/molecula/featurebase/v3/server"
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////////////////////
|
||||
// Command represents a test wrapper for server.Command.
|
||||
type Command struct {
|
||||
*server.Command
|
||||
|
|
@ -47,7 +47,7 @@ func newCommand(tb DirCleaner, opts ...server.CommandOption) *Command {
|
|||
}, opts...)
|
||||
|
||||
m := &Command{commandOptions: opts}
|
||||
m.Command = server.NewCommand(bytes.NewReader(nil), ioutil.Discard, ioutil.Discard, opts...)
|
||||
m.Command = server.NewCommand(bytes.NewReader(nil), io.Discard, io.Discard, opts...)
|
||||
// pick etcd ports using a socket rather than a real port
|
||||
err := GetPortsGenConfigs(tb, []*Command{m})
|
||||
if err != nil {
|
||||
|
|
@ -109,7 +109,7 @@ func (m *Command) Reopen() error {
|
|||
|
||||
// Create new main with the same config.
|
||||
config := m.Command.Config
|
||||
m.Command = server.NewCommand(bytes.NewReader(nil), ioutil.Discard, ioutil.Discard, m.commandOptions...)
|
||||
m.Command = server.NewCommand(bytes.NewReader(nil), io.Discard, io.Discard, m.commandOptions...)
|
||||
m.Command.Config = config
|
||||
|
||||
// Run new program.
|
||||
|
|
@ -235,7 +235,7 @@ func (m *Command) QueryProtobuf(indexName string, query string) (*pilosa.QueryRe
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
buf, err := ioutil.ReadAll(resp.Body)
|
||||
buf, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ func Do(t testing.TB, method, urlStr string, body string) *httpResponse {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
buf, err := ioutil.ReadAll(resp.Body)
|
||||
buf, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package testhook
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
|
|
@ -85,7 +84,7 @@ func RunTestsWithHooks(m *testing.M) {
|
|||
// TempDir creates a temp directory that will be automatically deleted when
|
||||
// this test completes, using go1.14's [TB].Cleanup() if available.
|
||||
func TempDir(tb testing.TB, pattern string) (path string, err error) {
|
||||
path, err = ioutil.TempDir("", pattern)
|
||||
path, err = os.MkdirTemp("", pattern)
|
||||
if err == nil {
|
||||
Cleanup(tb, func() {
|
||||
os.RemoveAll(path)
|
||||
|
|
@ -97,7 +96,7 @@ func TempDir(tb testing.TB, pattern string) (path string, err error) {
|
|||
// TempFile creates a temp file that will be automatically deleted when
|
||||
// this test completes, using go1.14's [TB].Cleanup() if available.
|
||||
func TempFile(tb testing.TB, pattern string) (file *os.File, err error) {
|
||||
file, err = ioutil.TempFile("", pattern)
|
||||
file, err = os.CreateTemp("", pattern)
|
||||
if err == nil {
|
||||
path := file.Name()
|
||||
Cleanup(tb, func() {
|
||||
|
|
@ -113,7 +112,7 @@ func TempFile(tb testing.TB, pattern string) (file *os.File, err error) {
|
|||
// path instead of the default Go TMPDIR. Only some tests use this, which is
|
||||
// possibly an error...
|
||||
func TempDirInDir(tb testing.TB, dir string, pattern string) (path string, err error) {
|
||||
path, err = ioutil.TempDir(dir, pattern)
|
||||
path, err = os.MkdirTemp(dir, pattern)
|
||||
if err == nil {
|
||||
Cleanup(tb, func() {
|
||||
os.RemoveAll(path)
|
||||
|
|
@ -127,7 +126,7 @@ func TempDirInDir(tb testing.TB, dir string, pattern string) (path string, err e
|
|||
// path instead of the default Go TMPDIR. Only some tests use this, which is
|
||||
// possibly an error...
|
||||
func TempFileInDir(tb testing.TB, dir string, pattern string) (file *os.File, err error) {
|
||||
file, err = ioutil.TempFile(dir, pattern)
|
||||
file, err = os.CreateTemp(dir, pattern)
|
||||
if err == nil {
|
||||
path := file.Name()
|
||||
Cleanup(tb, func() {
|
||||
|
|
|
|||
18
translate.go
18
translate.go
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
|
|
@ -34,13 +33,14 @@ var (
|
|||
|
||||
// TranslateStore is the storage for translation string-to-uint64 values.
|
||||
// For BoltDB implementation an empty string will be converted into the sentinel byte slice:
|
||||
// var emptyKey = []byte{
|
||||
// 0x00, 0x00, 0x00,
|
||||
// 0x4d, 0x54, 0x4d, 0x54, // MTMT
|
||||
// 0x00,
|
||||
// 0xc2, 0xa0, // NO-BREAK SPACE
|
||||
// 0x00,
|
||||
// }
|
||||
//
|
||||
// var emptyKey = []byte{
|
||||
// 0x00, 0x00, 0x00,
|
||||
// 0x4d, 0x54, 0x4d, 0x54, // MTMT
|
||||
// 0x00,
|
||||
// 0xc2, 0xa0, // NO-BREAK SPACE
|
||||
// 0x00,
|
||||
// }
|
||||
type TranslateStore interface { // TODO: refactor this interface; readonly should be part of the type and replication should be an impl detail
|
||||
io.Closer
|
||||
|
||||
|
|
@ -584,7 +584,7 @@ func (s *InMemTranslateStore) ReadFrom(r io.Reader) (count int64, err error) {
|
|||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
var bytes []byte
|
||||
bytes, err = ioutil.ReadAll(r)
|
||||
bytes, err = io.ReadAll(r)
|
||||
count = int64(len(bytes))
|
||||
if err != nil {
|
||||
return count, err
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue