<commit_before>// +build order

package dev_test

import (
	"fmt"
	"sync"
	"testing"

	qc "github.com/relab/gorums/dev"
	"github.com/relab/gorums/internal/leakcheck"
	"golang.org/x/net/context"
)

func TestQuorumCallOrdering(t *testing.T) {
	defer leakcheck.Check(t)
	failMsg := make(chan string)
	servers, dialOpts, stopGrpcServe, closeListeners := setup(
		t,
		[]storageServer{
			{impl: newStorageServerRequiringOrdering(failMsg)},
			{impl: newStorageServerRequiringOrdering(failMsg)},
			{impl: newStorageServerRequiringOrdering(failMsg)},
			{impl: newStorageServerRequiringOrdering(failMsg)},
			{impl: newStorageServerRequiringOrdering(failMsg)},
		},
		false,
		false,
	)
	defer closeListeners(allServers)
	defer stopGrpcServe(allServers)

	mgrOpts := []qc.ManagerOption{
		dialOpts,
	}
	mgr, err := qc.NewManager(
		servers.addrs(),
		mgrOpts...,
	)
	if err != nil {
		t.Fatalf("%v", err)
	}
	defer mgr.Close()

	ids := mgr.NodeIDs()

	// Quorum spec: rq=1 (not used), wq=3, n=5.
	qspec := NewStorageQSpec(1, 3)

	config, err := mgr.NewConfiguration(ids, qspec)
	if err != nil {
		t.Fatalf("error creating config: %v", err)
	}

	state := &qc.State{
		Value:     "42",
		Timestamp: 1, // Servers start at 0.
	}

	const maxNumberOfQCs = 1 << 18
<commit_msg>fixed failing ordering test; required WithDialTimeout as mgr opt<commit_after>// +build order

package dev_test

import (
	"fmt"
	"sync"
	"testing"
	"time"

	qc "github.com/relab/gorums/dev"
	"github.com/relab/gorums/internal/leakcheck"
	"golang.org/x/net/context"
)

func TestQuorumCallOrdering(t *testing.T) {
	defer leakcheck.Check(t)
	failMsg := make(chan string)
	servers, dialOpts, stopGrpcServe, closeListeners := setup(
		t,
		[]storageServer{
			{impl: newStorageServerRequiringOrdering(failMsg)},
			{impl: newStorageServerRequiringOrdering(failMsg)},
			{impl: newStorageServerRequiringOrdering(failMsg)},
			{impl: newStorageServerRequiringOrdering(failMsg)},
			{impl: newStorageServerRequiringOrdering(failMsg)},
		},
		false,
		false,
	)
	defer closeListeners(allServers)
	defer stopGrpcServe(allServers)

	mgr, err := qc.NewManager(servers.addrs(), dialOpts, qc.WithDialTimeout(time.Second))
	if err != nil {
		t.Fatalf("%v", err)
	}
	defer mgr.Close()

	ids := mgr.NodeIDs()

	// Quorum spec: rq=1 (not used), wq=3, n=5.
	qspec := NewStorageQSpec(1, 3)

	config, err := mgr.NewConfiguration(ids, qspec)
	if err != nil {
		t.Fatalf("error creating config: %v", err)
	}

	state := &qc.State{
		Value:     "42",
		Timestamp: 1, // Servers start at 0.
	}

	const maxNumberOfQCs = 1 << 18

{'fraction_non_alphanumeric': 0.1449162446435528, 'fraction_numerical': 0.009349435138293729, 'mean_word_length': 4.440677966101695, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7297959', 'n_tokens_mistral': 1044, 'n_tokens_neox': 994, 'n_words': 200}