<commit_before>// Copyright 2016 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
// Author: <NAME> (<EMAIL>)

package acceptance

import (
	"fmt"
	"math/rand"
	"testing"
	"time"

	"golang.org/x/net/context"

	"github.com/cockroachdb/cockroach/pkg/acceptance/cluster"
	"github.com/cockroachdb/cockroach/pkg/util/caller"
	"github.com/cockroachdb/cockroach/pkg/util/log"
	"github.com/cockroachdb/cockroach/pkg/util/stop"
	"github.com/cockroachdb/cockroach/pkg/util/timeutil"
	"github.com/pkg/errors"
)

func TestPartitionNemesis(t *testing.T) {
	t.Skip("only enabled for manually playing with the partitioning agent")
	SkipUnlessLocal(t)
	runTestOnConfigs(t, func(ctx context.Context, t *testing.T, c cluster.Cluster, cfg cluster.TestConfig) {
		stopper.RunWorker(func() {
			BidirectionalPartitionNemesis(ctx, t, c, stopper)
		})
		select {
		case <-time.After(*flagDuration):
		case <-stopper.ShouldStop():
		}
	})
}

func TestPartitionBank(t *testing.T) {
	SkipUnlessPrivileged(t)
	runTestOnConfigs(t, testBankWithNemesis(BidirectionalPartitionNemesis))
}

type Bank struct {
	cluster.Cluster
	*testing.T
	accounts, initialBalance int
}

func (b *Bank) must(err error) {
	if err != nil {
		f, l, _ := caller.Lookup(1)
		b.Fatal(errors.Wrapf(err, "%s:%d", f, l))
	}
}

// NewBank creates a Bank.
// TODO(tamird,tschottdorf): share this code with other bank test(s).
func NewBank(t *testing.T, c cluster.Cluster) *Bank {
	return &Bank{Cluster: c, T: t}
}

func (b *Bank) exec(ctx context.Context, query string, vars ...interface{}) error {
	db := makePGClient(b.T, b.PGUrl(ctx, 0))<commit_msg>acceptance: skip flaky TestPartitionBank - see #12654.<commit_after>// Copyright 2016 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
// Author: <NAME> (<EMAIL>)

package acceptance

import (
	"fmt"
	"math/rand"
	"testing"
	"time"

	"golang.org/x/net/context"

	"github.com/cockroachdb/cockroach/pkg/acceptance/cluster"
	"github.com/cockroachdb/cockroach/pkg/util/caller"
	"github.com/cockroachdb/cockroach/pkg/util/log"
	"github.com/cockroachdb/cockroach/pkg/util/stop"
	"github.com/cockroachdb/cockroach/pkg/util/timeutil"
	"github.com/pkg/errors"
)

func TestPartitionNemesis(t *testing.T) {
	t.Skip("only enabled for manually playing with the partitioning agent")
	SkipUnlessLocal(t)
	runTestOnConfigs(t, func(ctx context.Context, t *testing.T, c cluster.Cluster, cfg cluster.TestConfig) {
		stopper.RunWorker(func() {
			BidirectionalPartitionNemesis(ctx, t, c, stopper)
		})
		select {
		case <-time.After(*flagDuration):
		case <-stopper.ShouldStop():
		}
	})
}

func TestPartitionBank(t *testing.T) {
	t.Skip("#12654")
	SkipUnlessPrivileged(t)
	runTestOnConfigs(t, testBankWithNemesis(BidirectionalPartitionNemesis))
}

type Bank struct {
	cluster.Cluster
	*testing.T
	accounts, initialBalance int
}

func (b *Bank) must(err error) {
	if err != nil {
		f, l, _ := caller.Lookup(1)
		b.Fatal(errors.Wrapf(err, "%s:%d", f, l))
	}
}

// NewBank creates a Bank.
// TODO(tamird,tschottdorf): share this code with other bank test(s).
func NewBank(t *testing.T, c cluster.Cluster) *Bank {
	return &Bank{Cluster: c, T: t}
}

func (b *Bank) exec(ctx context.Context, query string, vars ...interface{}) error {
	db := makePGClient(b.T, b.PGUrl(ctx, 0))
{'fraction_non_alphanumeric': 0.13401344771620682, 'fraction_numerical': 0.006955715279387897, 'mean_word_length': 4.2101449275362315, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4764313', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1472, 'n_words': 403}