<commit_before>package redisutil

import (
	"crypto/rand"
	"fmt"
	"runtime"
	"sync"
	"testing"
	"time"

	assert "github.com/stretchr/testify/require"

	"go.skia.org/infra/go/testutils"
)

const (
	Q_NAME            = "mytype"
	Q_NAME_PRIMITIVES = "mytestq"
	N_TASKS           = 1000
	PACKAGE_SIZE      = 1024 * 512
)

// BytesCodec for testing.
type BytesCodec struct{}

func (b BytesCodec) Encode(data interface{}) ([]byte, error) {
	// Make a copy to simulate the generic case.
	return append([]byte(nil), data.([]byte)...), nil
}

func (b BytesCodec) Decode(byteData []byte) (interface{}, error) {
	// Make a copy to simulate the generic case.
	return append([]byte(nil), byteData...), nil
}

func TestReadThroughCache(t *testing.T) {
	testutils.SkipIfShort(t)

	rp := NewRedisPool(REDIS_SERVER_ADDRESS, REDIS_DB_RTCACHE)
	defer testutils.CloseInTest(t, rp)

	assert.NoError(t, rp.FlushDB())
	randBytes := make([]byte, PACKAGE_SIZE)
	_, err := rand.Read(randBytes)
	assert.NoError(t, err)

	worker := func(priority int64, id string) (interface{}, error) {
		// Create a unique version of the random array.
		return []byte(id + string(randBytes)), nil<commit_msg>Disabled Redis rtc test<commit_after>package redisutil

import (
	"crypto/rand"
	"fmt"
	"runtime"
	"sync"
	"testing"
	"time"

	assert "github.com/stretchr/testify/require"

	"go.skia.org/infra/go/testutils"
)

const (
	Q_NAME            = "mytype"
	Q_NAME_PRIMITIVES = "mytestq"
	N_TASKS           = 1000
	PACKAGE_SIZE      = 1024 * 512
)

// BytesCodec for testing.
type BytesCodec struct{}

func (b BytesCodec) Encode(data interface{}) ([]byte, error) {
	// Make a copy to simulate the generic case.
	return append([]byte(nil), data.([]byte)...), nil
}

func (b BytesCodec) Decode(byteData []byte) (interface{}, error) {
	// Make a copy to simulate the generic case.
	return append([]byte(nil), byteData...), nil
}

// TODO(stephana): Re-enable when test setup is stable.
func xTestReadThroughCache(t *testing.T) {
	testutils.SkipIfShort(t)

	rp := NewRedisPool(REDIS_SERVER_ADDRESS, REDIS_DB_RTCACHE)
	defer testutils.CloseInTest(t, rp)

	assert.NoError(t, rp.FlushDB())
	randBytes := make([]byte, PACKAGE_SIZE)
	_, err := rand.Read(randBytes)
	assert.NoError(t, err)

	worker := func(priority int64, id string) (interface{}, error) {
		// Create a unique version of the random array.
		return []byte(id + string(randBytes)), nil
{'fraction_non_alphanumeric': 0.1439299123904881, 'fraction_numerical': 0.01084689194826867, 'mean_word_length': 4.059071729957806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2816234', 'n_tokens_mistral': 914, 'n_tokens_neox': 877, 'n_words': 217}