<commit_before>// +build integration

package memcached

import (
	"os"
	"strings"
	"sync"
	"testing"
	"time"

	"github.com/go-kit/kit/log"

	"github.com/weaveworks/flux/image"
	"github.com/weaveworks/flux/registry"
	"github.com/weaveworks/flux/registry/cache"
	"github.com/weaveworks/flux/registry/middleware"
)

// memcachedIPs flag from memcached_test.go

// This tests a real memcached cache and a request to a real docker
// repository. It is intended to be an end-to-end integration test for
// the warmer since I had a few bugs introduced when refactoring. This
// should cover against these bugs.
func TestWarming_WarmerWriteCacheRead(t *testing.T) {
	mc := NewFixedServerMemcacheClient(MemcacheConfig{
		Timeout:        time.Second,
		UpdateInterval: 1 * time.Minute,
		Logger:         log.With(log.NewLogfmtLogger(os.Stderr), "component", "memcached"),
	}, strings.Fields(*memcachedIPs)...)

	id, _ := image.ParseRef("alpine")

	logger := log.NewLogfmtLogger(os.Stderr)

	remote := &registry.RemoteClientFactory{
		Logger:   log.With(logger, "component", "client"),
		Limiters: &middleware.RateLimiters{RPS: 200, Burst: 10},
		Trace:    true,
	}

	r := &cache.Cache{mc}

	w, _ := cache.NewWarmer(remote, mc, 125)
	shutdown := make(chan struct{})
	shutdownWg := &sync.WaitGroup{}
	defer func() {
		close(shutdown)
		shutdownWg.Wait()
	}()<commit_msg>Switch to busybox for integration test<commit_after>// +build integration

package memcached

import (
	"os"
	"strings"
	"sync"
	"testing"
	"time"

	"github.com/go-kit/kit/log"

	"github.com/weaveworks/flux/image"
	"github.com/weaveworks/flux/registry"
	"github.com/weaveworks/flux/registry/cache"
	"github.com/weaveworks/flux/registry/middleware"
)

// memcachedIPs flag from memcached_test.go

// This tests a real memcached cache and a request to a real docker
// repository. It is intended to be an end-to-end integration test for
// the warmer since I had a few bugs introduced when refactoring. This
// should cover against these bugs.
func TestWarming_WarmerWriteCacheRead(t *testing.T) {
	mc := NewFixedServerMemcacheClient(MemcacheConfig{
		Timeout:        time.Second,
		UpdateInterval: 1 * time.Minute,
		Logger:         log.With(log.NewLogfmtLogger(os.Stderr), "component", "memcached"),
	}, strings.Fields(*memcachedIPs)...)

	id, _ := image.ParseRef("busybox")

	logger := log.NewLogfmtLogger(os.Stderr)

	remote := &registry.RemoteClientFactory{
		Logger:   log.With(logger, "component", "client"),
		Limiters: &middleware.RateLimiters{RPS: 200, Burst: 10},
		Trace:    true,
	}

	r := &cache.Cache{mc}

	w, _ := cache.NewWarmer(remote, mc, 125)
	shutdown := make(chan struct{})
	shutdownWg := &sync.WaitGroup{}
	defer func() {
		close(shutdown)
		shutdownWg.Wait()
	}()
{'fraction_non_alphanumeric': 0.13629737609329445, 'fraction_numerical': 0.006559766763848397, 'mean_word_length': 4.218631178707224, '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': '5926786', 'n_tokens_mistral': 1009, 'n_tokens_neox': 945, 'n_words': 221}