text stringlengths 93 16.4k | id stringlengths 20 40 | metadata dict | input_ids listlengths 45 2.05k | attention_mask listlengths 45 2.05k | complexity int64 1 9 |
|---|---|---|---|---|---|
func TestNewWallet(t *testing.T) {
skipIfShort(t)
w, done := setupWallet(t)
defer done()
var err error
address, err := w.NewWallet(ctx, "bls")
if err != nil {
t.Fatalf("failed to create new wallet: %v", err)
}
if len(address) < 1 {
t.Fatal("received empty address from NewWallet")
}
} | explode_data.jsonl/49705 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
3564,
38259,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
2679,
12472,
1155,
340,
6692,
11,
2814,
1669,
6505,
38259,
1155,
340,
16867,
2814,
2822,
2405,
1848,
1465,
198,
63202,
11,
1848,
1669,
289,
7121,
38259,
7502,
11,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestChannelListNoChannelsFound(t *testing.T) {
cClient := v1beta1.NewMockKnChannelsClient(t)
cRecorder := cClient.Recorder()
cRecorder.ListChannel(nil, nil)
out, err := executeChannelCommand(cClient, "list")
assert.NilError(t, err)
assert.Check(t, util.ContainsAll(out, "No channels found"))
cRecorder.Validate()
} | explode_data.jsonl/67289 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
9629,
852,
2753,
35925,
6650,
1155,
353,
8840,
836,
8,
341,
1444,
2959,
1669,
348,
16,
19127,
16,
7121,
11571,
36253,
35925,
2959,
1155,
340,
1444,
47023,
1669,
272,
2959,
20610,
1358,
741,
1444,
47023,
5814,
9629,
27907,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNotifications(t *testing.T) {
blocks, err := loadBlocks("blk_0_to_4.dat.bz2")
if err != nil {
t.Fatalf("Error loading file: %v\n", err)
}
// Create a new database and chain instance to run tests against.
chain, teardownFunc, err := chainSetup("notifications",
&chaincfg.MainNetParams)
if err != nil {
t.Fatalf("Failed to setup chain instance: %v", err)
}
defer teardownFunc()
notificationCount := 0
callback := func(notification *Notification) {
if notification.Type == NTBlockAccepted {
notificationCount++
}
}
// Register callback multiple times then assert it is called that many
// times.
const numSubscribers = 3
for i := 0; i < numSubscribers; i++ {
chain.Subscribe(callback)
}
_, _, err = chain.ProcessBlock(blocks[1], BFNone)
if err != nil {
t.Fatalf("ProcessBlock fail on block 1: %v\n", err)
}
if notificationCount != numSubscribers {
t.Fatalf("Expected notification callback to be executed %d "+
"times, found %d", numSubscribers, notificationCount)
}
} | explode_data.jsonl/37082 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 360
} | [
2830,
3393,
34736,
1155,
353,
8840,
836,
8,
341,
2233,
34936,
11,
1848,
1669,
2795,
29804,
445,
34989,
62,
15,
2346,
62,
19,
9915,
81374,
17,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
1454,
8277,
1034,
25,
1018,
85,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestResolveRepositoryName(t *testing.T) {
_, _, err := ResolveRepositoryName("https://github.com/docker/docker")
assertEqual(t, err, ErrInvalidRepositoryName, "Expected error invalid repo name")
ep, repo, err := ResolveRepositoryName("fooo/bar")
if err != nil {
t.Fatal(err)
}
assertEqual(t, ep, IndexServerAddress(), "Expected endpoint to be index server address")
assertEqual(t, repo, "fooo/bar", "Expected resolved repo to be foo/bar")
u := makeURL("")[7:]
ep, repo, err = ResolveRepositoryName(u + "/private/moonbase")
if err != nil {
t.Fatal(err)
}
assertEqual(t, ep, u, "Expected endpoint to be "+u)
assertEqual(t, repo, "private/moonbase", "Expected endpoint to be private/moonbase")
ep, repo, err = ResolveRepositoryName("ubuntu-12.04-base")
if err != nil {
t.Fatal(err)
}
assertEqual(t, ep, IndexServerAddress(), "Expected endpoint to be "+IndexServerAddress())
assertEqual(t, repo, "ubuntu-12.04-base", "Expected endpoint to be ubuntu-12.04-base")
} | explode_data.jsonl/78262 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
56808,
4624,
675,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
1848,
1669,
47302,
4624,
675,
445,
2428,
1110,
5204,
905,
61764,
61764,
1138,
6948,
2993,
1155,
11,
1848,
11,
15495,
7928,
4624,
675,
11,
330,
18896,
1465,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestGetNbrEntriesNilEntry(t *testing.T) {
svr := &NDPServer{}
svr.InitGlobalDS()
initServerBasic()
nextIdx, count, runTimeEntries := svr.GetNeighborEntries(0, TEST_NBR_ENTRIES)
if nextIdx != 0 || count != 0 || runTimeEntries != nil {
t.Error("Failed to return 0 entries")
}
svr.DeInitGlobalDS()
} | explode_data.jsonl/38851 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
1949,
45,
1323,
24533,
19064,
5874,
1155,
353,
8840,
836,
8,
341,
1903,
18920,
1669,
609,
8065,
5012,
2836,
16094,
1903,
18920,
26849,
11646,
5936,
741,
28248,
5475,
15944,
741,
28144,
11420,
11,
1760,
11,
1598,
1462,
24533,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestAppConfigDefaulterHandle(t *testing.T) {
decoder := decoder()
defaulter := &AppConfigWebhook{}
defaulter.InjectDecoder(decoder)
req := admission.Request{}
req.Object = runtime.RawExtension{Raw: readYaml2Json(t, "hello-conf.yaml")}
res := defaulter.Handle(context.TODO(), req)
assert.True(t, res.Allowed)
assert.NotEqual(t, 0, len(res.Patches))
} | explode_data.jsonl/33954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
2164,
2648,
2620,
4943,
465,
6999,
1155,
353,
8840,
836,
8,
341,
197,
48110,
1669,
24551,
741,
7452,
4943,
465,
1669,
609,
2164,
2648,
5981,
20873,
16094,
7452,
4943,
465,
41046,
20732,
35712,
4316,
340,
24395,
1669,
25293,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInit_MTU(t *testing.T) {
var fakeCmds []fakeexec.FakeCommandAction
{
// modprobe br-netfilter
fCmd := fakeexec.FakeCmd{
CombinedOutputScript: []fakeexec.FakeAction{
func() ([]byte, []byte, error) {
return make([]byte, 0), nil, nil
},
},
}
fakeCmds = append(fakeCmds, func(cmd string, args ...string) exec.Cmd {
return fakeexec.InitFakeCmd(&fCmd, cmd, args...)
})
}
fexec := &fakeexec.FakeExec{
CommandScript: fakeCmds,
LookPathFunc: func(file string) (string, error) {
return fmt.Sprintf("/fake-bin/%s", file), nil
},
}
fhost := nettest.NewFakeHost(nil)
ips := make(map[kubecontainer.ContainerID]utilsets.String)
kubenet := newFakeKubenetPlugin(ips, fexec, fhost)
kubenet.iptables = ipttest.NewFake()
sysctl := sysctltest.NewFake()
sysctl.Settings["net/bridge/bridge-nf-call-iptables"] = 0
kubenet.sysctl = sysctl
if err := kubenet.Init(nettest.NewFakeHost(nil), kubeletconfig.HairpinNone, "10.0.0.0/8", 1234); err != nil {
t.Fatalf("Unexpected error in Init: %v", err)
}
assert.Equal(t, 1234, kubenet.mtu, "kubenet.mtu should have been set")
assert.Equal(t, 1, sysctl.Settings["net/bridge/bridge-nf-call-iptables"], "net/bridge/bridge-nf-call-iptables sysctl should have been set")
} | explode_data.jsonl/4478 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 515
} | [
2830,
3393,
3803,
49047,
52,
1155,
353,
8840,
836,
8,
341,
2405,
12418,
15613,
82,
3056,
30570,
11748,
991,
726,
4062,
2512,
198,
197,
515,
197,
197,
322,
1463,
52329,
1411,
66496,
5315,
198,
197,
1166,
15613,
1669,
12418,
11748,
991,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInterfaceIndirect(t *testing.T) {
Register(&interfaceIndirectTestT{})
b := new(bytes.Buffer)
w := []interfaceIndirectTestI{&interfaceIndirectTestT{}}
err := NewEncoder(b).Encode(w)
if err != nil {
t.Fatal("encode error:", err)
}
var r []interfaceIndirectTestI
err = NewDecoder(b).Decode(&r)
if err != nil {
t.Fatal("decode error:", err)
}
} | explode_data.jsonl/43394 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
5051,
1425,
1226,
1155,
353,
8840,
836,
8,
341,
79096,
2099,
4970,
1425,
1226,
2271,
51,
37790,
2233,
1669,
501,
23158,
22622,
340,
6692,
1669,
3056,
4970,
1425,
1226,
2271,
40,
90,
5,
4970,
1425,
1226,
2271,
51,
6257,
532... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestInterfaceMethods(t *testing.T) {
gopClTest(t, `package main
func foo(v ...interface { Bar() }) {
}
func main() {
}`, `package main
func foo(v ...interface {
Bar()
}) {
}
func main() {
}
`)
} | explode_data.jsonl/73691 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
5051,
17856,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
1565,
1722,
1887,
271,
2830,
15229,
3747,
2503,
4970,
314,
4716,
368,
6413,
341,
630,
2830,
1887,
368,
341,
28350,
1565,
1722,
1887,
271,
2830,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestDMLQueryWithoutWhereClause(t *testing.T) {
config := tabletenv.NewDefaultConfig()
config.HotRowProtection.Mode = tabletenv.Enable
config.HotRowProtection.MaxConcurrency = 1
config.TxPool.Size = 2
db, tsv := setupTabletServerTestCustom(t, config, "")
defer tsv.StopService()
defer db.Close()
target := querypb.Target{TabletType: topodatapb.TabletType_PRIMARY}
q := "delete from test_table"
db.AddQuery(q+" limit 10001", &sqltypes.Result{})
_, txid, _, err := tsv.BeginExecute(ctx, &target, nil, q, nil, 0, nil)
require.NoError(t, err)
_, err = tsv.Commit(ctx, &target, txid)
require.NoError(t, err)
} | explode_data.jsonl/80004 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
35,
2668,
2859,
26040,
9064,
28482,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
1965,
1960,
85,
7121,
3675,
2648,
741,
25873,
3839,
354,
3102,
78998,
42852,
284,
1965,
1960,
85,
32287,
198,
25873,
3839,
354,
3102,
78998,
1453... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMarch(t *testing.T) {
for _, test := range []struct {
what string
fileSrcOnly []string
dirSrcOnly []string
fileDstOnly []string
dirDstOnly []string
fileMatch []string
dirMatch []string
}{
{
what: "source only",
fileSrcOnly: []string{"test", "test2", "test3", "sub dir/test4"},
dirSrcOnly: []string{"sub dir"},
},
{
what: "identical",
fileMatch: []string{"test", "test2", "sub dir/test3", "sub dir/sub sub dir/test4"},
dirMatch: []string{"sub dir", "sub dir/sub sub dir"},
},
{
what: "typical sync",
fileSrcOnly: []string{"srcOnly", "srcOnlyDir/sub"},
dirSrcOnly: []string{"srcOnlyDir"},
fileMatch: []string{"match", "matchDir/match file"},
dirMatch: []string{"matchDir"},
fileDstOnly: []string{"dstOnly", "dstOnlyDir/sub"},
dirDstOnly: []string{"dstOnlyDir"},
},
} {
t.Run(fmt.Sprintf("TestMarch-%s", test.what), func(t *testing.T) {
r := fstest.NewRun(t)
defer r.Finalise()
var srcOnly []fstest.Item
var dstOnly []fstest.Item
var match []fstest.Item
ctx, cancel := context.WithCancel(context.Background())
for _, f := range test.fileSrcOnly {
srcOnly = append(srcOnly, r.WriteFile(f, "hello world", t1))
}
for _, f := range test.fileDstOnly {
dstOnly = append(dstOnly, r.WriteObject(ctx, f, "hello world", t1))
}
for _, f := range test.fileMatch {
match = append(match, r.WriteBoth(ctx, f, "hello world", t1))
}
mt := &marchTester{
ctx: ctx,
cancel: cancel,
noTraverse: false,
}
fi := filter.GetConfig(ctx)
m := &March{
Ctx: ctx,
Fdst: r.Fremote,
Fsrc: r.Flocal,
Dir: "",
NoTraverse: mt.noTraverse,
Callback: mt,
DstIncludeAll: fi.Opt.DeleteExcluded,
}
mt.processError(m.Run(ctx))
mt.cancel()
err := mt.currentError()
require.NoError(t, err)
precision := fs.GetModifyWindow(ctx, r.Fremote, r.Flocal)
fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, precision, "srcOnly")
fstest.CompareItems(t, mt.dstOnly, dstOnly, test.dirDstOnly, precision, "dstOnly")
fstest.CompareItems(t, mt.match, match, test.dirMatch, precision, "match")
})
}
} | explode_data.jsonl/54650 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1058
} | [
2830,
3393,
27523,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
197,
12555,
286,
914,
198,
197,
17661,
20360,
7308,
3056,
917,
198,
197,
48532,
20360,
7308,
220,
3056,
917,
198,
197,
17661,
54600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestClusterAdminDeleteEmptyTopic(t *testing.T) {
seedBroker := NewMockBroker(t, 1)
defer seedBroker.Close()
seedBroker.SetHandlerByMap(map[string]MockResponse{
"MetadataRequest": NewMockMetadataResponse(t).
SetController(seedBroker.BrokerID()).
SetBroker(seedBroker.Addr(), seedBroker.BrokerID()),
"DeleteTopicsRequest": NewMockDeleteTopicsResponse(t),
})
config := NewTestConfig()
config.Version = V0_10_2_0
admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
if err != nil {
t.Fatal(err)
}
err = admin.DeleteTopic("")
if err != ErrInvalidTopic {
t.Fatal(err)
}
err = admin.Close()
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/40782 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 266
} | [
2830,
3393,
28678,
7210,
6435,
3522,
26406,
1155,
353,
8840,
836,
8,
341,
197,
22602,
65545,
1669,
1532,
11571,
65545,
1155,
11,
220,
16,
340,
16867,
10320,
65545,
10421,
2822,
197,
22602,
65545,
4202,
3050,
1359,
2227,
9147,
14032,
60,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDataEvent(t *testing.T) {
var (
tag = "tag"
data = "{}"
e, err = unmarshal([]string{
fmt.Sprintf("tag: %s", tag),
fmt.Sprintf(`data: {"tag": "%s", "data": %s}`, tag, data),
})
)
if err != nil {
t.Errorf("Unexpected failure while unmarshaling valid EventsResponse")
}
cond := e.Type == eventData
cond = cond && e.Tag == tag
cond = cond && e.Data == data
if !cond {
t.Errorf("Parsed event mismatches with input data")
}
} | explode_data.jsonl/78028 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 194
} | [
2830,
93200,
1556,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
60439,
262,
284,
330,
4578,
698,
197,
8924,
256,
284,
35503,
698,
197,
7727,
11,
1848,
284,
650,
27121,
10556,
917,
515,
298,
11009,
17305,
445,
4578,
25,
1018,
82,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestCheckMandatoryS3Fields(t *testing.T) {
cfg := model.FileSettings{}
err := CheckMandatoryS3Fields(&cfg)
if err == nil || err.Message != "api.admin.test_s3.missing_s3_bucket" {
t.Fatal("should've failed with missing s3 bucket")
}
cfg.AmazonS3Bucket = model.NewString("test-mm")
err = CheckMandatoryS3Fields(&cfg)
if err != nil {
t.Fatal("should've not failed")
}
cfg.AmazonS3Endpoint = model.NewString("")
err = CheckMandatoryS3Fields(&cfg)
if err != nil || *cfg.AmazonS3Endpoint != "s3.amazonaws.com" {
t.Fatal("should've not failed because it should set the endpoint to the default")
}
} | explode_data.jsonl/15378 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 231
} | [
2830,
3393,
3973,
44,
62088,
50,
18,
8941,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
1614,
8576,
6086,
31483,
9859,
1669,
4248,
44,
62088,
50,
18,
8941,
2099,
14072,
340,
743,
1848,
621,
2092,
1369,
1848,
8472,
961,
330,
2068,
18203,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestMetricGroupData_toSummaryPointEquivalence(t *testing.T) {
type scrape struct {
at int64
value float64
metric string
}
tests := []struct {
name string
labels labels.Labels
scrapes []*scrape
}{
{
name: "summary",
labels: labels.Labels{{Name: "a", Value: "A"}, {Name: "quantile", Value: "0.75"}, {Name: "b", Value: "B"}},
scrapes: []*scrape{
{at: 11, value: 10, metric: "summary_count"},
{at: 11, value: 1004.78, metric: "summary_sum"},
{at: 13, value: 33.7, metric: "value"},
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
mf := newMetricFamily(tt.name, mc, zap.NewNop()).(*metricFamily)
mp := newMetricFamilyPdata(tt.name, mc).(*metricFamilyPdata)
for _, tv := range tt.scrapes {
require.NoError(t, mp.Add(tv.metric, tt.labels.Copy(), tv.at, tv.value))
require.NoError(t, mf.Add(tv.metric, tt.labels.Copy(), tv.at, tv.value))
}
groupKey := mf.getGroupKey(tt.labels.Copy())
ocTimeseries := mf.groups[groupKey].toSummaryTimeSeries(mf.labelKeysOrdered)
sdpL := pdata.NewSummaryDataPointSlice()
require.True(t, mp.groups[groupKey].toSummaryPoint(mp.labelKeysOrdered, &sdpL))
require.Equal(t, len(ocTimeseries.Points), sdpL.Len(), "They should have the exact same number of points")
require.Equal(t, 1, sdpL.Len(), "Exactly one point expected")
ocPoint := ocTimeseries.Points[0]
pdataPoint := sdpL.At(0)
// 1. Ensure that the startTimestamps are equal.
require.Equal(t, ocTimeseries.GetStartTimestamp().AsTime(), pdataPoint.Timestamp().AsTime(), "The timestamp must be equal")
// 2. Ensure that the count is equal.
ocSummary := ocPoint.GetSummaryValue()
if false {
t.Logf("\nOcSummary: %#v\nPdSummary: %#v\n\nocPoint: %#v\n", ocSummary, pdataPoint, ocPoint.GetSummaryValue())
return
}
require.Equal(t, ocSummary.GetCount().GetValue(), int64(pdataPoint.Count()), "Count must be equal")
// 3. Ensure that the sum is equal.
require.Equal(t, ocSummary.GetSum().GetValue(), pdataPoint.Sum(), "Sum must be equal")
// 4. Ensure that the point's timestamp is equal to that from the OpenCensusProto data point.
require.Equal(t, ocPoint.GetTimestamp().AsTime(), pdataPoint.Timestamp().AsTime(), "Point timestamps must be equal")
// 5. Ensure that the labels all match up.
ocStringMap := pdata.NewStringMap()
for i, labelValue := range ocTimeseries.LabelValues {
ocStringMap.Insert(mf.labelKeysOrdered[i], labelValue.Value)
}
require.Equal(t, ocStringMap.Sort(), pdataPoint.LabelsMap().Sort())
// 6. Ensure that the quantile values all match up.
ocQuantiles := ocSummary.GetSnapshot().GetPercentileValues()
pdataQuantiles := pdataPoint.QuantileValues()
require.Equal(t, len(ocQuantiles), pdataQuantiles.Len())
for i, ocQuantile := range ocQuantiles {
pdataQuantile := pdataQuantiles.At(i)
require.Equal(t, ocQuantile.Percentile, pdataQuantile.Quantile(), "The quantile percentiles must match")
require.Equal(t, ocQuantile.Value, pdataQuantile.Value(), "The quantile values must match")
}
})
}
} | explode_data.jsonl/19396 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1254
} | [
2830,
3393,
54310,
2808,
1043,
2346,
19237,
2609,
24509,
88790,
1155,
353,
8840,
836,
8,
341,
13158,
57128,
2036,
341,
197,
35447,
257,
526,
21,
19,
198,
197,
16309,
220,
2224,
21,
19,
198,
197,
2109,
16340,
914,
198,
197,
532,
78216,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestPrevMonth(t *testing.T) {
tests := []struct{ Input, Want time.Time }{
{New(2006, 1, 1), New(2005, 12, 1)},
{New(2006, 12, 4), New(2006, 11, 1)},
{New(2006, 3, 4), New(2006, 2, 1)},
{New(2016, 2, 29), New(2016, 1, 1)}, // leap year
{New(2015, 2, 28), New(2015, 1, 1)}, // non leap year
}
for i, tc := range tests {
has := PrevMonth(tc.Input)
if has != tc.Want {
t.Errorf("%d: input=%s want=%s has=%s", i+1, tc.Input.Format("2006-01-02"), tc.Want.Format("2006-01-02"), has.Format("2006-01-02"))
}
}
} | explode_data.jsonl/49083 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
33528,
11318,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
90,
5571,
11,
23252,
882,
16299,
335,
515,
197,
197,
90,
3564,
7,
17,
15,
15,
21,
11,
220,
16,
11,
220,
16,
701,
1532,
7,
17,
15,
15,
20,
11,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPlayer_Money(t *testing.T) {
pl := playerWithProperty("m_iAccount", st.PropertyValue{IntVal: 800})
assert.Equal(t, 800, pl.Money())
} | explode_data.jsonl/12192 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 53
} | [
2830,
3393,
4476,
1245,
2534,
1155,
353,
8840,
836,
8,
341,
72213,
1669,
2781,
2354,
3052,
445,
76,
5318,
7365,
497,
357,
15727,
1130,
90,
1072,
2208,
25,
220,
23,
15,
15,
8824,
6948,
12808,
1155,
11,
220,
23,
15,
15,
11,
625,
132... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSortTags(t *testing.T) {
a := assert.New(t, false)
// type=default
tags := []*Tag{
{
Title: "1",
Posts: []*Post{{}, {}, {}},
},
{
Title: "2",
Posts: []*Post{{}, {}},
},
}
sortTags(tags, loader.TagOrderTypeDefault, loader.OrderAsc)
a.Equal(tags[0].Title, "1").Equal(tags[1].Title, "2")
sortTags(tags, loader.TagOrderTypeDefault, loader.OrderDesc)
a.Equal(tags[0].Title, "2").Equal(tags[1].Title, "1")
// type=size
sortTags(tags, loader.TagOrderTypeSize, loader.OrderAsc)
a.Equal(tags[0].Title, "1").Equal(tags[1].Title, "2")
sortTags(tags, loader.TagOrderTypeSize, loader.OrderDesc)
a.Equal(tags[0].Title, "2").Equal(tags[1].Title, "1")
} | explode_data.jsonl/35906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 301
} | [
2830,
3393,
10231,
15930,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
11,
895,
692,
197,
322,
943,
92628,
198,
3244,
2032,
1669,
29838,
5668,
515,
197,
197,
515,
298,
92233,
25,
330,
16,
756,
298,
197,
19631,
25,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPrivateActivityNoVisibleForUserItself(t *testing.T) {
defer prepareTestEnv(t)()
testPrivateActivityDoSomethingForActionEntries(t)
session := loginUser(t, privateActivityTestUser)
visible := testPrivateActivityHelperHasVisibleActivitiesFromSession(t, session)
assert.True(t, visible, "user should have visible activities")
} | explode_data.jsonl/51646 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
16787,
4052,
2753,
5715,
2461,
1474,
2132,
721,
1155,
353,
8840,
836,
8,
341,
16867,
10549,
2271,
14359,
1155,
8,
741,
18185,
16787,
4052,
5404,
23087,
2461,
2512,
24533,
1155,
692,
25054,
1669,
87169,
1155,
11,
869,
4052,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeadlineExceeded_Unwrap(t *testing.T) {
mnr := &callbacks.DeadlineExceeded{}
unwrappedErr := mnr.Unwrap()
if unwrappedErr != nil {
t.Errorf(
"Unexpected wrapped error. Got %s, Expected: nil",
unwrappedErr,
)
}
} | explode_data.jsonl/56102 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
83593,
840,
94206,
40687,
10097,
1155,
353,
8840,
836,
8,
341,
2109,
19618,
1669,
609,
68311,
909,
3149,
1056,
840,
94206,
31483,
20479,
75704,
7747,
1669,
296,
19618,
10616,
10097,
2822,
743,
15025,
56289,
7747,
961,
2092,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestParse(t *testing.T) {
code := `(+ (* 1 1) (f "xx" "yy"))`
ats, _ := Parse(code)
except := `(+ (* 1 1) (f "xx" "yy"))`
if fmt.Sprintf("%v", ats) != except {
t.Error("Parse Error")
t.Log("ats: ", ats, "except: ", except)
}
} | explode_data.jsonl/14416 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
14463,
1155,
353,
8840,
836,
8,
341,
43343,
1669,
1565,
40938,
4609,
220,
16,
220,
16,
8,
320,
69,
330,
4146,
1,
330,
4807,
2761,
3989,
197,
1862,
11,
716,
1669,
14775,
15842,
340,
34599,
1669,
1565,
40938,
4609,
220,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestUndelay(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
c.CreateConnected(context.TestInitialSequenceNumber, 30000, -1 /* epRcvBuf */)
c.EP.SocketOptions().SetDelayOption(true)
allData := [][]byte{{0}, {1, 2, 3}}
for i, data := range allData {
var r bytes.Reader
r.Reset(data)
if _, err := c.EP.Write(&r, tcpip.WriteOptions{}); err != nil {
t.Fatalf("Write #%d failed: %s", i+1, err)
}
}
seq := c.IRS.Add(1)
iss := seqnum.Value(context.TestInitialSequenceNumber).Add(1)
// Check that data is received.
first := c.GetPacket()
checker.IPv4(t, first,
checker.PayloadLen(len(allData[0])+header.TCPMinimumSize),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(seq)),
checker.TCPAckNum(uint32(iss)),
checker.TCPFlagsMatch(header.TCPFlagAck, ^header.TCPFlagPsh),
),
)
if got, want := first[header.IPv4MinimumSize+header.TCPMinimumSize:], allData[0]; !bytes.Equal(got, want) {
t.Fatalf("got first packet's data = %v, want = %v", got, want)
}
seq = seq.Add(seqnum.Size(len(allData[0])))
// Check that we don't get the second packet yet.
c.CheckNoPacketTimeout("delayed second packet transmitted", 100*time.Millisecond)
c.EP.SocketOptions().SetDelayOption(false)
// Check that data is received.
second := c.GetPacket()
checker.IPv4(t, second,
checker.PayloadLen(len(allData[1])+header.TCPMinimumSize),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(seq)),
checker.TCPAckNum(uint32(iss)),
checker.TCPFlagsMatch(header.TCPFlagAck, ^header.TCPFlagPsh),
),
)
if got, want := second[header.IPv4MinimumSize+header.TCPMinimumSize:], allData[1]; !bytes.Equal(got, want) {
t.Fatalf("got second packet's data = %v, want = %v", got, want)
}
seq = seq.Add(seqnum.Size(len(allData[1])))
// Acknowledge the data.
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagAck,
SeqNum: iss,
AckNum: seq,
RcvWnd: 30000,
})
} | explode_data.jsonl/75965 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 865
} | [
2830,
3393,
19957,
6895,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
1444,
7251,
21146,
5378,
8787,
6341,
14076,
2833,
11,
220,
18,
15,
15,
15,
15,
11,
481,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestParseCfg(t *testing.T) {
dataDir := t.TempDir()
cmd := new(cobra.Command)
o := newOptions()
o.addFlags(cmd)
require.Nil(t, cmd.ParseFlags([]string{
"--addr", "127.5.5.1:8833",
"--advertise-addr", "127.5.5.1:7777",
"--log-file", "/root/cdc.log",
"--log-level", "debug",
"--data-dir", dataDir,
"--gc-ttl", "10",
"--tz", "UTC",
"--owner-flush-interval", "150ms",
"--processor-flush-interval", "150ms",
"--cert", "bb",
"--key", "cc",
"--cert-allowed-cn", "dd,ee",
"--sorter-chunk-size-limit", "50000000",
"--sorter-max-memory-consumption", "60000",
"--sorter-max-memory-percentage", "70",
"--sorter-num-concurrent-worker", "80",
"--sorter-num-workerpool-goroutine", "90",
"--sort-dir", "/tmp/just_a_test",
}))
err := o.complete(cmd)
require.Nil(t, err)
err = o.validate()
require.Nil(t, err)
require.Equal(t, &config.ServerConfig{
Addr: "127.5.5.1:8833",
AdvertiseAddr: "127.5.5.1:7777",
LogFile: "/root/cdc.log",
LogLevel: "debug",
Log: &config.LogConfig{
File: &config.LogFileConfig{
MaxSize: 300,
MaxDays: 0,
MaxBackups: 0,
},
InternalErrOutput: "stderr",
},
DataDir: dataDir,
GcTTL: 10,
TZ: "UTC",
CaptureSessionTTL: 10,
OwnerFlushInterval: config.TomlDuration(150 * time.Millisecond),
ProcessorFlushInterval: config.TomlDuration(150 * time.Millisecond),
Sorter: &config.SorterConfig{
NumConcurrentWorker: 80,
ChunkSizeLimit: 50000000,
MaxMemoryPressure: 70,
MaxMemoryConsumption: 60000,
NumWorkerPoolGoroutine: 90,
SortDir: config.DefaultSortDir,
},
Security: &config.SecurityConfig{
CertPath: "bb",
KeyPath: "cc",
CertAllowedCN: []string{"dd", "ee"},
},
PerTableMemoryQuota: 10 * 1024 * 1024, // 10M
KVClient: &config.KVClientConfig{
WorkerConcurrent: 8,
WorkerPoolSize: 0,
RegionScanLimit: 40,
},
Debug: &config.DebugConfig{
EnableTableActor: false,
EnableDBSorter: false,
DB: &config.DBConfig{
Count: 8,
Concurrency: 128,
MaxOpenFiles: 10000,
BlockSize: 65536,
BlockCacheSize: 4294967296,
WriterBufferSize: 8388608,
Compression: "snappy",
TargetFileSizeBase: 8388608,
WriteL0SlowdownTrigger: math.MaxInt32,
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 160,
CompactionDeletionThreshold: 160000,
IteratorMaxAliveDuration: 10000,
IteratorSlowReadDuration: 256,
CleanupSpeedLimit: 10000,
},
// We expect the default configuration here.
Messages: &config.MessagesConfig{
ClientMaxBatchInterval: config.TomlDuration(time.Millisecond * 200),
ClientMaxBatchSize: 8 * 1024 * 1024,
ClientMaxBatchCount: 128,
ClientRetryRateLimit: 1.0,
ServerMaxPendingMessageCount: 102400,
ServerAckInterval: config.TomlDuration(time.Millisecond * 100),
ServerWorkerPoolSize: 4,
},
},
}, o.serverConfig)
} | explode_data.jsonl/41633 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1611
} | [
2830,
3393,
14463,
42467,
1155,
353,
8840,
836,
8,
341,
8924,
6184,
1669,
259,
65009,
6184,
741,
25920,
1669,
501,
1337,
28856,
12714,
340,
22229,
1669,
501,
3798,
741,
22229,
1364,
9195,
14160,
692,
17957,
59678,
1155,
11,
5439,
8937,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEntity_WriteTo_convert(t *testing.T) {
var h Header
h.Set("Content-Type", "text/plain; charset=utf-8")
h.Set("Content-Transfer-Encoding", "base64")
r := strings.NewReader("Qm9uam91ciDDoCB0b3Vz")
e, _ := New(h, r)
e.Header.Set("Content-Transfer-Encoding", "quoted-printable")
var b bytes.Buffer
if err := e.WriteTo(&b); err != nil {
t.Fatal("Expected no error while writing entity, got", err)
}
expected := "Mime-Version: 1.0\r\n" +
"Content-Transfer-Encoding: quoted-printable\r\n" +
"Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"Bonjour =C3=A0 tous"
if s := b.String(); s != expected {
t.Errorf("Expected written entity to be:\n%s\nbut got:\n%s", expected, s)
}
} | explode_data.jsonl/30553 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 305
} | [
2830,
3393,
3030,
31825,
1249,
34910,
1155,
353,
8840,
836,
8,
341,
2405,
305,
12104,
198,
9598,
4202,
445,
2762,
10804,
497,
330,
1318,
36971,
26,
11617,
22264,
12,
23,
1138,
9598,
4202,
445,
2762,
12,
21970,
67358,
497,
330,
3152,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSamplingPolicyTypicalPath(t *testing.T) {
const maxSize = 100
const decisionWaitSeconds = 5
// For this test explicitly control the timer calls and batcher, and set a mock
// sampling policy evaluator.
msp := new(consumertest.TracesSink)
mpe := &mockPolicyEvaluator{}
mtt := &manualTTicker{}
tsp := &tailSamplingSpanProcessor{
ctx: context.Background(),
nextConsumer: msp,
maxNumTraces: maxSize,
logger: zap.NewNop(),
decisionBatcher: newSyncIDBatcher(decisionWaitSeconds),
policies: []*Policy{{Name: "mock-policy", Evaluator: mpe, ctx: context.TODO()}},
deleteChan: make(chan pdata.TraceID, maxSize),
policyTicker: mtt,
}
_, batches := generateIdsAndBatches(210)
currItem := 0
numSpansPerBatchWindow := 10
// First evaluations shouldn't have anything to evaluate, until decision wait time passed.
for evalNum := 0; evalNum < decisionWaitSeconds; evalNum++ {
for ; currItem < numSpansPerBatchWindow*(evalNum+1); currItem++ {
tsp.ConsumeTraces(context.Background(), batches[currItem])
require.True(t, mtt.Started, "Time ticker was expected to have started")
}
tsp.samplingPolicyOnTick()
require.False(
t,
msp.SpansCount() != 0 || mpe.EvaluationCount != 0,
"policy for initial items was evaluated before decision wait period",
)
}
// Now the first batch that waited the decision period.
mpe.NextDecision = sampling.Sampled
tsp.samplingPolicyOnTick()
require.False(
t,
msp.SpansCount() == 0 || mpe.EvaluationCount == 0,
"policy should have been evaluated totalspans == %d and evaluationcount == %d",
msp.SpansCount(),
mpe.EvaluationCount,
)
require.Equal(t, numSpansPerBatchWindow, msp.SpansCount(), "not all spans of first window were accounted for")
// Late span of a sampled trace should be sent directly down the pipeline exporter
tsp.ConsumeTraces(context.Background(), batches[0])
expectedNumWithLateSpan := numSpansPerBatchWindow + 1
require.Equal(t, expectedNumWithLateSpan, msp.SpansCount(), "late span was not accounted for")
require.Equal(t, 1, mpe.LateArrivingSpansCount, "policy was not notified of the late span")
} | explode_data.jsonl/31673 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 787
} | [
2830,
3393,
98622,
13825,
12834,
938,
1820,
1155,
353,
8840,
836,
8,
341,
4777,
61935,
284,
220,
16,
15,
15,
198,
4777,
5480,
14190,
15343,
284,
220,
20,
198,
197,
322,
1752,
419,
1273,
20975,
2524,
279,
9021,
6738,
323,
7162,
261,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestResolveConstIntWithIdentWithNilObj(t *testing.T) {
expr := ast.Ident{}
_, err := resolveConstInt(&expr)
if err == nil {
t.Error("should have received error because expr.Obj == nil")
}
} | explode_data.jsonl/33716 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
56808,
19167,
1072,
2354,
28301,
2354,
19064,
5261,
1155,
353,
8840,
836,
8,
341,
8122,
649,
1669,
11763,
6444,
306,
16094,
197,
6878,
1848,
1669,
8830,
19167,
1072,
2099,
9413,
340,
743,
1848,
621,
2092,
341,
197,
3244,
614... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestSetReminderTrack(t *testing.T) {
testActorsRuntime := newTestActorsRuntime()
actorType, actorID := getTestActorTypeAndID()
err := testActorsRuntime.updateReminderTrack(actorType, actorID)
assert.Nil(t, err)
} | explode_data.jsonl/12875 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
1649,
95359,
15667,
1155,
353,
8840,
836,
8,
341,
18185,
2414,
1087,
15123,
1669,
501,
2271,
2414,
1087,
15123,
741,
93410,
929,
11,
12089,
915,
1669,
633,
2271,
18870,
929,
3036,
915,
741,
9859,
1669,
1273,
2414,
1087,
1512... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestCheckConstraintBuilder_Build(t *testing.T) {
ctx := context.Background()
semaCtx := tree.MakeSemaContext()
// Trick to get the init() for the builtins package to run.
_ = builtins.AllBuiltinNames
database := tree.Name("foo")
table := tree.Name("bar")
tn := tree.MakeTableName(database, table)
desc := testTableDesc(
string(table),
[]testCol{{"a", types.Bool}, {"b", types.Int}},
[]testCol{{"c", types.String}},
)
builder := schemaexpr.MakeCheckConstraintBuilder(ctx, tn, desc, &semaCtx)
builder.MarkNameInUse("check_a3")
testData := []struct {
name string
expr string
expectedValid bool
expectedExpr string
expectedName string
}{
// Respect custom names.
{"chk_1", "a", true, "a", "chk_1"},
// Use unique default names when there is no custom name.
{"", "a", true, "a", "check_a"},
{"", "a", true, "a", "check_a1"},
{"", "a", true, "a", "check_a2"},
{"", "a AND b = 0", true, "a AND (b = 0:::INT8)", "check_a_b"},
{"", "a AND b = 1", true, "a AND (b = 1:::INT8)", "check_a_b1"},
{"", "a AND b = 1", true, "a AND (b = 1:::INT8)", "check_a_b2"},
// Respect that "check_a3" has been marked, so the next check constraint
// with "a" should be "check_a4".
{"", "a", true, "a", "check_a4"},
{"", "a", true, "a", "check_a5"},
// Allow expressions that result in a bool.
{"ck", "a", true, "a", "ck"},
{"ck", "b = 0", true, "b = 0:::INT8", "ck"},
{"ck", "a AND b = 0", true, "a AND (b = 0:::INT8)", "ck"},
{"ck", "a IS NULL", true, "a IS NULL", "ck"},
{"ck", "b IN (1, 2)", true, "b IN (1:::INT8, 2:::INT8)", "ck"},
// Allow immutable functions.
{"ck", "abs(b) > 0", true, "abs(b) > 0:::INT8", "ck"},
{"ck", "c || c = 'foofoo'", true, "(c || c) = 'foofoo':::STRING", "ck"},
{"ck", "lower(c) = 'bar'", true, "lower(c) = 'bar':::STRING", "ck"},
// Allow mutable functions.
{"ck", "b > random()", true, "b > random()", "ck"},
// Disallow references to columns not in the table.
{"", "d", false, "", ""},
{"", "t.a", false, "", ""},
// Disallow expressions that do not result in a bool.
{"", "b", false, "", ""},
{"", "abs(b)", false, "", ""},
{"", "lower(c)", false, "", ""},
// Disallow subqueries.
{"", "exists(select 1)", false, "", ""},
{"", "b IN (select 1)", false, "", ""},
// Disallow aggregate, window, and set returning functions.
{"", "sum(b) > 10", false, "", ""},
{"", "row_number() OVER () > 1", false, "", ""},
{"", "generate_series(1, 1) > 2", false, "", ""},
// Dequalify column names.
{"ck", "bar.a", true, "a", "ck"},
{"ck", "foo.bar.a", true, "a", "ck"},
{"ck", "bar.b = 0", true, "b = 0:::INT8", "ck"},
{"ck", "foo.bar.b = 0", true, "b = 0:::INT8", "ck"},
{"ck", "bar.a AND foo.bar.b = 0", true, "a AND (b = 0:::INT8)", "ck"},
}
for _, d := range testData {
t.Run(d.expr, func(t *testing.T) {
expr, err := parser.ParseExpr(d.expr)
if err != nil {
t.Fatalf("%s: unexpected error: %s", d.expr, err)
}
ckDef := &tree.CheckConstraintTableDef{Name: tree.Name(d.name), Expr: expr}
ck, err := builder.Build(ckDef)
if !d.expectedValid {
if err == nil {
t.Fatalf("%s: expected invalid expression, but was valid", d.expr)
}
// The input expression is invalid so there is no need to check
// the output ck.
return
}
if err != nil {
t.Fatalf("%s: expected valid expression, but found error: %s", d.expr, err)
}
if ck.Name != d.expectedName || ck.Expr != d.expectedExpr {
t.Errorf(
`%s: expected "%s CHECK %s", got "%s CHECK %s"`,
d.expr,
d.expectedName,
d.expectedExpr,
ck.Name,
ck.Expr,
)
}
})
}
} | explode_data.jsonl/31241 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1606
} | [
2830,
3393,
3973,
17890,
3297,
96686,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
84686,
1728,
23684,
1669,
4916,
50133,
50,
9176,
1972,
2822,
197,
322,
69225,
311,
633,
279,
2930,
368,
369,
279,
5798,
1330,
6328,
311,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestCreateVolumeSpec_Valid_File_VolumeMounts(t *testing.T) {
// create dswp
mode := v1.PersistentVolumeFilesystem
pv := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: "dswp-test-volume-name",
},
Spec: v1.PersistentVolumeSpec{
ClaimRef: &v1.ObjectReference{Namespace: "ns", Name: "file-bound"},
VolumeMode: &mode,
},
}
pvc := &v1.PersistentVolumeClaim{
Spec: v1.PersistentVolumeClaimSpec{
VolumeName: "dswp-test-volume-name",
VolumeMode: &mode,
},
Status: v1.PersistentVolumeClaimStatus{
Phase: v1.ClaimBound,
},
}
dswp, fakePodManager, _, _, _ := createDswpWithVolume(t, pv, pvc)
// create pod
containers := []v1.Container{
{
VolumeMounts: []v1.VolumeMount{
{
Name: "dswp-test-volume-name",
MountPath: "/mnt",
},
},
},
}
pod := createPodWithVolume("dswp-test-pod", "dswp-test-volume-name", "file-bound", containers)
fakePodManager.AddPod(pod)
mountsMap, devicesMap := util.GetPodVolumeNames(pod)
_, volumeSpec, _, err :=
dswp.createVolumeSpec(pod.Spec.Volumes[0], pod, mountsMap, devicesMap)
// Assert
if volumeSpec == nil || err != nil {
t.Fatalf("Failed to create volumeSpec with combination of filesystem mode and volumeMounts. err: %v", err)
}
} | explode_data.jsonl/45754 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 522
} | [
2830,
3393,
4021,
18902,
8327,
97279,
34061,
2334,
4661,
16284,
82,
1155,
353,
8840,
836,
8,
341,
197,
322,
1855,
294,
2280,
79,
198,
60247,
1669,
348,
16,
61655,
18902,
1703,
8948,
198,
3223,
85,
1669,
609,
85,
16,
61655,
18902,
515,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestChangeSetSorted(t *testing.T) {
old := mkSchema(
mkTable("table2"),
mkTable(
"table1",
mkCol("foo", SerialColumn, false, false, mkRef("table2", "bar", false)),
),
mkTable("table3"),
)
new := mkSchema(
mkTable("table3"),
mkTable("table4"),
mkTable(
"table5",
mkCol("foo", SerialColumn, false, false, mkRef("table4", "bar", false)),
),
)
cs := SchemaDiff(old, new)
expected := ChangeSet{
&CreateTable{new.Table("table4")},
&CreateTable{new.Table("table5")},
&DropTable{"table1"},
&DropTable{"table2"},
}
sorted, err := cs.sorted(old.index(), new.index())
require.NoError(t, err)
require.Equal(t, expected, sorted)
} | explode_data.jsonl/19120 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 280
} | [
2830,
3393,
4072,
1649,
51051,
1155,
353,
8840,
836,
8,
341,
61828,
1669,
23789,
8632,
1006,
197,
2109,
74,
2556,
445,
2005,
17,
4461,
197,
2109,
74,
2556,
1006,
298,
197,
1,
2005,
16,
756,
298,
2109,
74,
6127,
445,
7975,
497,
11215... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCombinedIndex(t *testing.T) {
builder1 := InMemoryBuilder(3)
builder2 := InMemoryBuilder(3)
split := 3
for i := 0; i < split; i ++ {
v := vectorTests[i]
builder1.AddWord(v.word, NewVector(v.vec))
}
for i := split; i < len(vectorTests); i ++ {
v := vectorTests[i]
builder2.AddWord(v.word, NewVector(v.vec))
}
memory_index1 := Contextionary(builder1.Build(3))
memory_index2 := Contextionary(builder2.Build(3))
var indices12 []Contextionary = []Contextionary { memory_index1, memory_index2, }
var indices21 []Contextionary = []Contextionary { memory_index2, memory_index1, }
t.Run("indices 1,2", func(t *testing.T) { test_combined(t, indices12) })
t.Run("indices 2,1", func(t *testing.T) { test_combined(t, indices21) })
} | explode_data.jsonl/10279 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 298
} | [
2830,
3393,
94268,
1552,
1155,
353,
8840,
836,
8,
341,
220,
7363,
16,
1669,
758,
10642,
3297,
7,
18,
340,
220,
7363,
17,
1669,
758,
10642,
3297,
7,
18,
692,
220,
6718,
1669,
220,
18,
271,
220,
369,
600,
1669,
220,
15,
26,
600,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestContainsSyncResource(t *testing.T) {
var (
blankUnstructured unstructured.Unstructured
blankResource argoappv1.SyncOperationResource
helloResource = argoappv1.SyncOperationResource{Name: "hello"}
)
tables := []struct {
u *unstructured.Unstructured
rr []argoappv1.SyncOperationResource
expected bool
}{
{&blankUnstructured, []argoappv1.SyncOperationResource{}, false},
{&blankUnstructured, []argoappv1.SyncOperationResource{blankResource}, true},
{&blankUnstructured, []argoappv1.SyncOperationResource{helloResource}, false},
}
for _, table := range tables {
if out := ContainsSyncResource(table.u.GetName(), table.u.GetNamespace(), table.u.GroupVersionKind(), table.rr); out != table.expected {
t.Errorf("Expected %t for slice %+v contains resource %+v; instead got %t", table.expected, table.rr, table.u, out)
}
}
} | explode_data.jsonl/49986 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 313
} | [
2830,
3393,
23805,
12154,
4783,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
197,
10189,
1806,
51143,
650,
51143,
10616,
51143,
198,
197,
197,
10189,
4783,
257,
1392,
78,
676,
85,
16,
92183,
8432,
4783,
198,
197,
9598,
4791,
4783,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestForwardResponseStream(t *testing.T) {
type msg struct {
pb proto.Message
err error
}
tests := []struct {
name string
msgs []msg
statusCode int
responseBody bool
}{{
name: "encoding",
msgs: []msg{
{&pb.SimpleMessage{Id: "One"}, nil},
{&pb.SimpleMessage{Id: "Two"}, nil},
},
statusCode: http.StatusOK,
}, {
name: "empty",
statusCode: http.StatusOK,
}, {
name: "error",
msgs: []msg{{nil, status.Errorf(codes.OutOfRange, "400")}},
statusCode: http.StatusBadRequest,
}, {
name: "stream_error",
msgs: []msg{
{&pb.SimpleMessage{Id: "One"}, nil},
{nil, status.Errorf(codes.OutOfRange, "400")},
},
statusCode: http.StatusOK,
}, {
name: "response body stream case",
msgs: []msg{
{fakeReponseBodyWrapper{&pb.SimpleMessage{Id: "One"}}, nil},
{fakeReponseBodyWrapper{&pb.SimpleMessage{Id: "Two"}}, nil},
},
responseBody: true,
statusCode: http.StatusOK,
}, {
name: "response body stream error case",
msgs: []msg{
{fakeReponseBodyWrapper{&pb.SimpleMessage{Id: "One"}}, nil},
{nil, status.Errorf(codes.OutOfRange, "400")},
},
responseBody: true,
statusCode: http.StatusOK,
}}
newTestRecv := func(t *testing.T, msgs []msg) func() (proto.Message, error) {
var count int
return func() (proto.Message, error) {
if count == len(msgs) {
return nil, io.EOF
} else if count > len(msgs) {
t.Errorf("recv() called %d times for %d messages", count, len(msgs))
}
count++
msg := msgs[count-1]
return msg.pb, msg.err
}
}
ctx := runtime.NewServerMetadataContext(context.Background(), runtime.ServerMetadata{})
marshaler := &runtime.JSONPb{}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
recv := newTestRecv(t, tt.msgs)
req := httptest.NewRequest("GET", "http://example.com/foo", nil)
resp := httptest.NewRecorder()
runtime.ForwardResponseStream(ctx, runtime.NewServeMux(), marshaler, resp, req, recv)
w := resp.Result()
if w.StatusCode != tt.statusCode {
t.Errorf("StatusCode %d want %d", w.StatusCode, tt.statusCode)
}
if h := w.Header.Get("Transfer-Encoding"); h != "chunked" {
t.Errorf("ForwardResponseStream missing header chunked")
}
body, err := ioutil.ReadAll(w.Body)
if err != nil {
t.Errorf("Failed to read response body with %v", err)
}
w.Body.Close()
var want []byte
counter := 0
for i, msg := range tt.msgs {
if msg.err != nil {
if i == 0 {
// Skip non-stream errors
t.Skip("checking error encodings")
}
st := status.Convert(msg.err)
b, err := marshaler.Marshal(map[string]proto.Message{
"error": st.Proto(),
})
if err != nil {
t.Errorf("marshaler.Marshal() failed %v", err)
}
errBytes := body[len(want):]
if string(errBytes) != string(b) {
t.Errorf("ForwardResponseStream() = \"%s\" want \"%s\"", errBytes, b)
}
return
}
var b []byte
if tt.responseBody {
// responseBody interface is in runtime package and test is in runtime_test package. hence can't use responseBody directly
// So type casting to fakeReponseBodyWrapper struct to verify the data.
rb, ok := msg.pb.(fakeReponseBodyWrapper)
if !ok {
t.Errorf("stream responseBody failed %v", err)
}
b, err = marshaler.Marshal(map[string]interface{}{"result": rb.XXX_ResponseBody(), "header_metadata": metadata.MD{}, "count": counter})
} else {
b, err = marshaler.Marshal(map[string]interface{}{"result": msg.pb, "header_metadata": metadata.MD{}, "count": counter})
}
counter++
if err != nil {
t.Errorf("marshaler.Marshal() failed %v", err)
}
want = append(want, b...)
want = append(want, marshaler.Delimiter()...)
}
if string(body) != string(want) {
t.Errorf("ForwardResponseStream() = \"%s\" want \"%s\"", body, want)
}
})
}
} | explode_data.jsonl/13712 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1692
} | [
2830,
3393,
25925,
2582,
3027,
1155,
353,
8840,
836,
8,
341,
13158,
3750,
2036,
341,
197,
3223,
65,
220,
18433,
8472,
198,
197,
9859,
1465,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
21169,
82,
260,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMiddleware(t *testing.T) {
tests := map[string]struct {
handlerID string
config middleware.Config
req func() *http.Request
mock func(m *mmetrics.Recorder)
handler func() http.Handler
expRespCode int
expRespBody string
}{
"A default HTTP middleware should call the recorder to measure.": {
req: func() *http.Request {
return httptest.NewRequest(http.MethodPost, "/test", nil)
},
mock: func(m *mmetrics.Recorder) {
expHTTPReqProps := metrics.HTTPReqProperties{
ID: "/test",
Service: "",
Method: "POST",
Code: "202",
}
m.On("ObserveHTTPRequestDuration", mock.Anything, expHTTPReqProps, mock.Anything).Once()
m.On("ObserveHTTPResponseSize", mock.Anything, expHTTPReqProps, int64(5)).Once()
expHTTPProps := metrics.HTTPProperties{
ID: "/test",
Service: "",
}
m.On("AddInflightRequests", mock.Anything, expHTTPProps, 1).Once()
m.On("AddInflightRequests", mock.Anything, expHTTPProps, -1).Once()
},
handler: func() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(202)
w.Write([]byte("test1")) // nolint: errcheck
})
},
expRespCode: 202,
expRespBody: "test1",
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
// Mocks.
mr := &mmetrics.Recorder{}
test.mock(mr)
// Create our negroni instance with the middleware.
mdlw := middleware.New(middleware.Config{Recorder: mr})
n := negroni.Classic()
n.Use(negronimiddleware.Handler(test.handlerID, mdlw))
n.UseHandler(test.handler())
// Make the request.
resp := httptest.NewRecorder()
n.ServeHTTP(resp, test.req())
// Check.
mr.AssertExpectations(t)
assert.Equal(test.expRespCode, resp.Result().StatusCode)
gotBody, err := ioutil.ReadAll(resp.Result().Body)
require.NoError(err)
assert.Equal(test.expRespBody, string(gotBody))
})
}
} | explode_data.jsonl/72886 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 883
} | [
2830,
3393,
24684,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
53326,
915,
256,
914,
198,
197,
25873,
414,
29679,
10753,
198,
197,
24395,
260,
2915,
368,
353,
1254,
9659,
198,
197,
77333,
286,
2915,
125... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIsValidReturnErrorIfRelativeFiles(t *testing.T) {
yamlWithFiles := `
kernel:
image: linuxkit/kernel:4.9.69
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
files:
- path: /etc/issue
source: "/some/path/in/the/server"
trust:
org:
- linuxkit`
c, parseErr := moby.NewConfig([]byte(yamlWithFiles))
assert.NoError(t, parseErr)
err := IsValid(c)
assert.Error(t, err)
} | explode_data.jsonl/59569 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
55470,
5598,
1454,
2679,
28442,
10809,
1155,
353,
8840,
836,
8,
341,
14522,
9467,
2354,
10809,
1669,
22074,
23248,
510,
220,
2168,
25,
36245,
8226,
58343,
25,
19,
13,
24,
13,
21,
24,
198,
220,
94106,
25,
330,
5354,
24000,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTokenExpired(t *testing.T) {
px, idp, _ := newTestProxyService(nil)
token := newTestToken(idp.getLocation())
cs := []struct {
Expire time.Duration
OK bool
}{
{
Expire: time.Duration(1 * time.Hour),
OK: true,
},
{
Expire: time.Duration(-5 * time.Hour),
},
}
for i, x := range cs {
token.setExpiration(time.Now().Add(x.Expire))
signed, err := idp.signToken(token.claims)
if err != nil {
t.Errorf("case %d unable to sign the token, error: %s", i, err)
continue
}
err = verifyToken(px.client, *signed)
if x.OK && err != nil {
t.Errorf("case %d, expected: %t got error: %s", i, x.OK, err)
}
if !x.OK && err == nil {
t.Errorf("case %d, expected: %t got no error", i, x.OK)
}
}
} | explode_data.jsonl/12649 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
3323,
54349,
1155,
353,
8840,
836,
8,
341,
197,
1767,
11,
877,
79,
11,
716,
1669,
501,
2271,
16219,
1860,
27907,
340,
43947,
1669,
501,
2271,
3323,
3724,
79,
51228,
2398,
71899,
1669,
3056,
1235,
341,
197,
197,
8033,
554,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestWriteTableMeta(t *testing.T) {
t.Parallel()
dir := t.TempDir()
config := defaultConfigForTest(t)
config.OutputDirPath = dir
writer, clean := createTestWriter(config, t)
defer clean()
err := writer.WriteTableMeta("test", "t", "CREATE TABLE t (a INT)")
require.NoError(t, err)
p := path.Join(dir, "test.t-schema.sql")
_, err = os.Stat(p)
require.NoError(t, err)
bytes, err := ioutil.ReadFile(p)
require.NoError(t, err)
require.Equal(t, "/*!40101 SET NAMES binary*/;\n/*T![placement] SET PLACEMENT_CHECKS = 0*/;\nCREATE TABLE t (a INT);\n", string(bytes))
} | explode_data.jsonl/36786 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
7985,
2556,
12175,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
48532,
1669,
259,
65009,
6184,
2822,
25873,
1669,
1638,
2648,
2461,
2271,
1155,
340,
25873,
34246,
6184,
1820,
284,
5419,
271,
38959,
11,
4240,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOrderingKeyFromBlock(t *testing.T) {
v := OrderingKeyFromBlock(0x1122334455667788, false)
assert.EqualValues(t, KinVersion_KIN4, v[0])
assert.Equal(t, uint64(0x1122334455667788), binary.BigEndian.Uint64(v[1:]))
for i := 0; i < 8; i++ {
assert.EqualValues(t, 0, v[9+i])
}
v = OrderingKeyFromBlock(0x1122334455667788, true)
assert.EqualValues(t, KinVersion_KIN4, v[0])
assert.Equal(t, uint64(0x1122334455667788), binary.BigEndian.Uint64(v[1:]))
for i := 0; i < 8; i++ {
assert.EqualValues(t, 0xff, v[9+i])
}
b, err := BlockFromOrderingKey(v)
assert.NoError(t, err)
assert.Equal(t, uint64(0x1122334455667788), b)
b, err = BlockFromOrderingKey(make([]byte, 4))
assert.Error(t, err)
assert.Zero(t, b)
} | explode_data.jsonl/11688 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
4431,
287,
1592,
3830,
4713,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
68621,
1592,
3830,
4713,
7,
15,
87,
16,
16,
17,
17,
18,
18,
19,
19,
20,
20,
21,
21,
22,
22,
23,
23,
11,
895,
340,
6948,
12808,
6227,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPrometheusEtcdRulesFiltered(t *testing.T) {
enabled := false
c := NewDefaultConfig()
c.EtcdConfig.Enabled = &enabled
f := NewFactory("openshift-monitoring", c)
r, err := f.PrometheusK8sRules()
if err != nil {
t.Fatal(err)
}
for _, g := range r.Spec.Groups {
if g.Name == "etcd" {
t.Fatal("etcd rules found, even if etcd is disabled")
}
}
} | explode_data.jsonl/68663 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
35186,
39705,
31860,
4385,
26008,
67310,
1155,
353,
8840,
836,
8,
341,
197,
15868,
1669,
895,
198,
1444,
1669,
1532,
3675,
2648,
741,
1444,
5142,
83,
4385,
2648,
13690,
284,
609,
15868,
198,
1166,
1669,
1532,
4153,
445,
2417... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestBotError(t *testing.T) {
plugin := Plugin{
Repo: Repo{
Name: "go-hello",
Namespace: "appleboy",
},
Commit: Commit{
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
Author: "Bo-Yi Wu",
Branch: "master",
Message: "update travis by drone plugin",
},
Build: Build{
Number: 101,
Status: "success",
Link: "https://github.com/appleboy/go-hello",
},
Config: Config{
Token: "appleboy",
To: []string{os.Getenv("TELEGRAM_TO"), "中文ID", "1234567890"},
Message: []string{"Test Telegram Chat Bot From Travis or Local", " "},
},
}
err := plugin.Exec()
assert.NotNil(t, err)
} | explode_data.jsonl/17931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 307
} | [
2830,
3393,
23502,
1454,
1155,
353,
8840,
836,
8,
341,
197,
9138,
1669,
21245,
515,
197,
197,
25243,
25,
71509,
515,
298,
21297,
25,
414,
330,
3346,
2832,
4791,
756,
298,
90823,
25,
330,
22377,
17184,
756,
197,
197,
1583,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestKustomizeSSHRemoteBase(t *testing.T) {
Given(t).
// not the best test, as we should have two remote repos both with the same SSH private key
SSHInsecureRepoURLAdded(true).
RepoURLType(fixture.RepoURLTypeSSH).
Path("ssh-kustomize-base").
When().
Create().
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(ResourceSyncStatusIs("ConfigMap", "my-map", SyncStatusCodeSynced))
} | explode_data.jsonl/37133 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
42,
1450,
551,
62419,
24703,
3978,
1155,
353,
8840,
836,
8,
341,
9600,
2071,
1155,
4292,
197,
197,
322,
537,
279,
1850,
1273,
11,
438,
582,
1265,
614,
1378,
8699,
45774,
2176,
448,
279,
1852,
40463,
869,
1376,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMaxHeapify(t *testing.T) {
var heap = []int{0, 10, 5, 20, 4, 3, 1, 15}
want := []int{0, 20, 5, 15, 4, 3, 1, 10}
MaxHeapify(&heap, len(heap)-1, 1)
if !reflect.DeepEqual(want, heap) {
t.Errorf("wanted heap %v got %v", want, heap)
}
} | explode_data.jsonl/22503 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
5974,
27909,
1437,
1155,
353,
8840,
836,
8,
341,
2405,
17364,
284,
3056,
396,
90,
15,
11,
220,
16,
15,
11,
220,
20,
11,
220,
17,
15,
11,
220,
19,
11,
220,
18,
11,
220,
16,
11,
220,
16,
20,
630,
50780,
1669,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSetPhotoPrimary(t *testing.T) {
assert.Equal(t, false, entity.FileFixturesExampleXMP.FilePrimary)
err := SetPhotoPrimary("pt9jtdre2lvl0yh7", "ft2es49whhbnlqdn")
if err != nil {
t.Fatal(err)
}
//TODO How to assert
//assert.Equal(t, true, entity.FileFixturesExampleXMP.FilePrimary)
} | explode_data.jsonl/71302 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
1649,
10463,
15972,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
895,
11,
5387,
8576,
25958,
18513,
13314,
55,
5781,
8576,
15972,
692,
9859,
1669,
2573,
10463,
15972,
445,
417,
24,
73,
1296,
265,
17,
58160,
15,
738... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_ReadAll(t *testing.T) {
t.Parallel()
ctx := context.Background()
um, err := NewUnmarshaller(sample{}, csv.NewReader(strings.NewReader(csvContents)))
require.NoError(t, err)
out, err := um.ReadAll(ctx, StopOnError)
require.NoError(t, err)
switch samples := out.(type) {
case []sample:
assert.Len(t, samples, 2)
default:
assert.Fail(t, fmt.Sprintf("Expected []sample, but got %T", out))
}
// With pointers
um, err = NewUnmarshaller(&sample{}, csv.NewReader(strings.NewReader(csvContents)))
require.NoError(t, err)
out, err = um.ReadAll(ctx, StopOnError)
require.NoError(t, err)
switch samples := out.(type) {
case []*sample:
assert.Len(t, samples, 2)
default:
assert.Fail(t, fmt.Sprintf("Expected []sample, but got %T", out))
}
// Handling errors
ignoreErrors := func(_ context.Context, _ error) error {
return nil
}
um, err = NewUnmarshaller(&sample{}, csv.NewReader(strings.NewReader(brokenCSV)))
require.NoError(t, err)
out, err = um.ReadAll(ctx, ignoreErrors)
require.NoError(t, err)
switch samples := out.(type) {
case []*sample:
assert.Len(t, samples, 3)
default:
assert.Fail(t, fmt.Sprintf("Expected []sample, but got %T", out))
}
} | explode_data.jsonl/78439 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 461
} | [
2830,
3393,
38381,
2403,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
1669,
2266,
19047,
2822,
197,
372,
11,
1848,
1669,
1532,
87690,
32968,
22655,
13147,
68587,
51442,
68587,
41583,
14803,
5929,
17957,
35699,
1155,
11,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNewIoBufferString(t *testing.T) {
for i := 0; i < 1024; i++ {
s := randString(i)
b := NewIoBufferString(s)
if b.String() != s {
t.Errorf("Expect %s but got %s", s, b.String())
}
}
} | explode_data.jsonl/24046 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
3564,
42799,
4095,
703,
1155,
353,
8840,
836,
8,
341,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
17,
19,
26,
600,
1027,
341,
197,
1903,
1669,
10382,
703,
1956,
340,
197,
2233,
1669,
1532,
42799,
4095,
703,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSignatureButNoPublicKey(t *testing.T) {
t.Parallel()
fName := "TestSignatureButNoPublicKey"
defer cleanup(fName)
writeOldFile(fName, t)
err := Apply(bytes.NewReader(newFile), Options{
TargetPath: fName,
Signature: signec(ecdsaPrivateKey, newFile, t),
})
if err == nil {
t.Fatalf("Allowed an update with a signautre verification when no public key was specified!")
}
} | explode_data.jsonl/73992 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
25088,
3983,
2753,
61822,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1166,
675,
1669,
330,
2271,
25088,
3983,
2753,
61822,
698,
16867,
21290,
955,
675,
340,
24945,
18284,
1703,
955,
675,
11,
259,
692,
9859,
1669,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestHandleInboundResponse(t *testing.T) {
prov := getProvider(t)
ctx := getContext(t, &prov, kms.ED25519Type, kms.X25519ECDHKWType, transport.MediaTypeRFC0019EncryptedEnvelope)
_, encKey := newSigningAndEncryptionDIDKeys(t, ctx)
_, err := createMockInvitation(encKey, ctx)
require.NoError(t, err)
t.Run("handle inbound responses get connection record error", func(t *testing.T) {
response := &Response{Thread: &decorator.Thread{ID: "test"}}
_, connRec, e := ctx.handleInboundResponse(response)
require.Error(t, e)
require.Contains(t, e.Error(), "get connection record")
require.Nil(t, connRec)
})
t.Run("handle inbound responses get connection record error", func(t *testing.T) {
response := &Response{Thread: &decorator.Thread{ID: ""}}
_, connRec, e := ctx.handleInboundResponse(response)
require.Error(t, e)
require.Contains(t, e.Error(), "empty bytes")
require.Nil(t, connRec)
})
} | explode_data.jsonl/2106 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
6999,
641,
10891,
2582,
1155,
353,
8840,
836,
8,
341,
197,
42947,
1669,
633,
5179,
1155,
340,
20985,
1669,
66175,
1155,
11,
609,
42947,
11,
96677,
13,
1479,
17,
20,
20,
16,
24,
929,
11,
96677,
4338,
17,
20,
20,
16,
24,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateAssetTxSyntacticVerifyInvalidDenomination(t *testing.T) {
tx, c, ctx := validCreateAssetTx(t)
tx.Denomination = byte(33)
if err := tx.SyntacticVerify(ctx, c, assetID, 0, 0, 1); err == nil {
t.Fatal("CreateAssetTx should have failed syntactic verification due to denomination too large")
}
} | explode_data.jsonl/73232 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
4021,
16604,
31584,
34667,
406,
23170,
32627,
7928,
23619,
80380,
1155,
353,
8840,
836,
8,
341,
46237,
11,
272,
11,
5635,
1669,
2697,
4021,
16604,
31584,
1155,
692,
46237,
909,
268,
80380,
284,
4922,
7,
18,
18,
340,
743,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestArtifactLocation_Key(t *testing.T) {
t.Run("Nil", func(t *testing.T) {
var l *ArtifactLocation
assert.False(t, l.HasKey())
_, err := l.GetKey()
assert.Error(t, err, "cannot get nil")
err = l.SetKey("my-file")
assert.Error(t, err, "cannot set nil")
})
t.Run("Empty", func(t *testing.T) {
// unlike nil, empty is actually invalid
l := &ArtifactLocation{}
assert.False(t, l.HasKey())
_, err := l.GetKey()
assert.Error(t, err, "cannot get empty")
err = l.SetKey("my-file")
assert.Error(t, err, "cannot set empty")
})
t.Run("Artifactory", func(t *testing.T) {
l := &ArtifactLocation{Artifactory: &ArtifactoryArtifact{URL: "http://my-host/my-dir?a=1"}}
err := l.AppendToKey("my-file")
assert.NoError(t, err)
assert.Equal(t, "http://my-host/my-dir/my-file?a=1", l.Artifactory.URL, "appends to Artifactory path")
})
t.Run("Git", func(t *testing.T) {
l := &ArtifactLocation{Git: &GitArtifact{}}
assert.False(t, l.HasKey())
_, err := l.GetKey()
assert.Error(t, err)
err = l.SetKey("my-file")
assert.Error(t, err, "cannot set Git key")
})
t.Run("GCS", func(t *testing.T) {
l := &ArtifactLocation{GCS: &GCSArtifact{Key: "my-dir"}}
err := l.AppendToKey("my-file")
assert.NoError(t, err)
assert.Equal(t, "my-dir/my-file", l.GCS.Key, "appends to GCS key")
})
t.Run("HDFS", func(t *testing.T) {
l := &ArtifactLocation{HDFS: &HDFSArtifact{Path: "my-path"}}
err := l.AppendToKey("my-file")
assert.NoError(t, err)
assert.Equal(t, "my-path/my-file", l.HDFS.Path, "appends to HDFS path")
})
t.Run("HTTP", func(t *testing.T) {
l := &ArtifactLocation{HTTP: &HTTPArtifact{URL: "http://my-host/my-dir?a=1"}}
err := l.AppendToKey("my-file")
assert.NoError(t, err)
assert.Equal(t, "http://my-host/my-dir/my-file?a=1", l.HTTP.URL, "appends to HTTP URL path")
})
t.Run("OSS", func(t *testing.T) {
l := &ArtifactLocation{OSS: &OSSArtifact{Key: "my-dir"}}
err := l.AppendToKey("my-file")
assert.NoError(t, err)
assert.Equal(t, "my-dir/my-file", l.OSS.Key, "appends to OSS key")
})
t.Run("Raw", func(t *testing.T) {
l := &ArtifactLocation{Raw: &RawArtifact{}}
assert.False(t, l.HasKey())
_, err := l.GetKey()
assert.Error(t, err, "cannot get raw key")
err = l.SetKey("my-file")
assert.Error(t, err, "cannot set raw key")
})
t.Run("S3", func(t *testing.T) {
l := &ArtifactLocation{S3: &S3Artifact{Key: "my-dir"}}
err := l.AppendToKey("my-file")
assert.NoError(t, err)
assert.Equal(t, "my-dir/my-file", l.S3.Key, "appends to S3 key")
})
} | explode_data.jsonl/26029 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1162
} | [
2830,
3393,
85578,
4707,
35253,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
19064,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2405,
326,
353,
85578,
4707,
198,
197,
6948,
50757,
1155,
11,
326,
88088,
2398,
197,
197,
6878,
1848,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestServeFileFromCWD(t *testing.T) {
defer afterTest(t)
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
ServeFile(w, r, "fs_test.go")
}))
defer ts.Close()
r, err := Get(ts.URL)
if err != nil {
t.Fatal(err)
}
r.Body.Close()
if r.StatusCode != 200 {
t.Fatalf("expected 200 OK, got %s", r.Status)
}
} | explode_data.jsonl/48233 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
60421,
1703,
3830,
34,
17563,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
57441,
1669,
54320,
70334,
7121,
5475,
7,
3050,
9626,
18552,
3622,
5949,
6492,
11,
435,
353,
1900,
8,
341,
197,
7568,
5852,
1703,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPrepFetchForRollback(t *testing.T) {
pp := NewTxPreparedPool(2)
conn := &TxConnection{}
pp.Put(conn, "aa")
got := pp.FetchForRollback("bb")
if got != nil {
t.Errorf("Get(bb): %v, want nil", got)
}
got = pp.FetchForRollback("aa")
if got != conn {
t.Errorf("pp.Get(aa): %p, want %p", got, conn)
}
got = pp.FetchForRollback("aa")
if got != nil {
t.Errorf("Get(aa): %v, want nil", got)
}
} | explode_data.jsonl/36821 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
4703,
79,
20714,
2461,
32355,
1419,
1155,
353,
8840,
836,
8,
341,
65729,
1669,
1532,
31584,
4703,
7212,
10551,
7,
17,
340,
32917,
1669,
609,
31584,
4526,
16094,
65729,
39825,
20571,
11,
330,
5305,
1138,
3174,
354,
1669,
1182... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestExportMetricsOp(t *testing.T) {
doneFn, err := obsreporttest.SetupRecordedMetricsTest()
require.NoError(t, err)
defer doneFn()
set := componenttest.NewNopExporterCreateSettings()
sr := new(oteltest.SpanRecorder)
set.TracerProvider = oteltest.NewTracerProvider(oteltest.WithSpanRecorder(sr))
parentCtx, parentSpan := set.TracerProvider.Tracer("test").Start(context.Background(), t.Name())
defer parentSpan.End()
obsrep := NewExporter(ExporterSettings{
Level: configtelemetry.LevelNormal,
ExporterID: exporter,
ExporterCreateSettings: set,
})
params := []testParams{
{items: 17, err: nil},
{items: 23, err: errFake},
}
for i := range params {
ctx := obsrep.StartMetricsOp(parentCtx)
assert.NotNil(t, ctx)
obsrep.EndMetricsOp(ctx, params[i].items, params[i].err)
}
spans := sr.Completed()
require.Equal(t, len(params), len(spans))
var sentMetricPoints, failedToSendMetricPoints int
for i, span := range spans {
assert.Equal(t, "exporter/"+exporter.String()+"/metrics", span.Name())
switch params[i].err {
case nil:
sentMetricPoints += params[i].items
assert.Equal(t, attribute.Int64Value(int64(params[i].items)), span.Attributes()[obsmetrics.SentMetricPointsKey])
assert.Equal(t, attribute.Int64Value(0), span.Attributes()[obsmetrics.FailedToSendMetricPointsKey])
assert.Equal(t, codes.Unset, span.StatusCode())
case errFake:
failedToSendMetricPoints += params[i].items
assert.Equal(t, attribute.Int64Value(0), span.Attributes()[obsmetrics.SentMetricPointsKey])
assert.Equal(t, attribute.Int64Value(int64(params[i].items)), span.Attributes()[obsmetrics.FailedToSendMetricPointsKey])
assert.Equal(t, codes.Error, span.StatusCode())
assert.Equal(t, params[i].err.Error(), span.StatusMessage())
default:
t.Fatalf("unexpected error: %v", params[i].err)
}
}
obsreporttest.CheckExporterMetrics(t, exporter, int64(sentMetricPoints), int64(failedToSendMetricPoints))
} | explode_data.jsonl/9549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 760
} | [
2830,
3393,
16894,
27328,
7125,
1155,
353,
8840,
836,
8,
341,
40495,
24911,
11,
1848,
1669,
7448,
11736,
1944,
39820,
6471,
291,
27328,
2271,
741,
17957,
35699,
1155,
11,
1848,
340,
16867,
2814,
24911,
2822,
8196,
1669,
3692,
1944,
7121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestSpanPropertiesFilter(t *testing.T) {
cases := []struct {
Desc string
Trace *TraceData
Decision Decision
}{
{
Desc: "fully matching",
Trace: newTraceAttrs("foobar", 1000*time.Microsecond, 100),
Decision: Sampled,
},
{
Desc: "nonmatching operation name",
Trace: newTraceAttrs("non_matching", 1000*time.Microsecond, 100),
Decision: NotSampled,
},
{
Desc: "nonmatching duration",
Trace: newTraceAttrs("foobar", 100*time.Microsecond, 100),
Decision: NotSampled,
},
{
Desc: "nonmatching number of spans",
Trace: newTraceAttrs("foobar", 1000*time.Microsecond, 1),
Decision: NotSampled,
},
}
for _, c := range cases {
t.Run(c.Desc, func(t *testing.T) {
filter, _ := newSpanPropertiesFilter(&operationNamePattern, &minDuration, &minNumberOfSpans)
u, _ := uuid.NewRandom()
decision, err := filter.Evaluate(pdata.NewTraceID(u), c.Trace)
assert.NoError(t, err)
assert.Equal(t, decision, c.Decision)
})
}
} | explode_data.jsonl/79888 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 453
} | [
2830,
3393,
12485,
7903,
5632,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
10957,
3300,
257,
914,
198,
197,
197,
6550,
262,
353,
6550,
1043,
198,
197,
197,
74846,
40425,
198,
197,
59403,
197,
197,
515,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVersionValidation(t *testing.T) {
type subcase struct {
name string
smcp *maistrav1.ServiceMeshControlPlane
configure func(smcp *maistrav1.ServiceMeshControlPlane)
allowed bool
}
cases := []struct {
name string
cases []subcase
}{
{
name: "v1.0",
// all these tests should be allowed, as we only perform 1.0
// validation when downgrading
cases: []subcase{
{
name: "valid",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {},
allowed: true,
},
{
name: "global.proxy.alwaysInjectSelector=false",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "global.proxy.alwaysInjectSelector", false)
},
allowed: true,
},
{
name: "global.proxy.alwaysInjectSelector=true",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "global.proxy.alwaysInjectSelector", true)
},
allowed: true,
},
{
name: "global.proxy.neverInjectSelector=false",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "global.proxy.neverInjectSelector", false)
},
allowed: true,
},
{
name: "global.proxy.neverInjectSelector=true",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "global.proxy.neverInjectSelector", true)
},
allowed: true,
},
{
name: "global.proxy.envoyAccessLogService.enabled=false",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "global.proxy.envoyAccessLogService.enabled", false)
},
allowed: true,
},
{
name: "global.proxy.envoyAccessLogService.enabled=true",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "global.proxy.envoyAccessLogService.enabled", true)
},
allowed: true,
},
{
name: "telemetry.enabled=false, telemetry.v2.enabled=false",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "telemetry.enabled", false)
setNestedField(smcp.Spec.Istio, "telemetry.v2.enabled", false)
},
allowed: true,
},
{
name: "telemetry.enabled=false, telemetry.v2.enabled=true",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "telemetry.enabled", false)
setNestedField(smcp.Spec.Istio, "telemetry.v2.enabled", true)
},
allowed: true,
},
{
name: "telemetry.enabled=true, telemetry.v2.enabled=true",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.0"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {
setNestedField(smcp.Spec.Istio, "telemetry.enabled", true)
setNestedField(smcp.Spec.Istio, "telemetry.v2.enabled", true)
},
allowed: true,
},
},
},
{
name: "v1.1",
cases: []subcase{
{
name: "valid",
smcp: newControlPlaneWithVersion("my-smcp", "istio-system", "v1.1"),
configure: func(smcp *maistrav1.ServiceMeshControlPlane) {},
allowed: true,
},
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
for _, tc := range tc.cases {
t.Run(tc.name, func(t *testing.T) {
validator, _, _ := createControlPlaneValidatorTestFixture()
tc.configure(tc.smcp)
response := validator.Handle(ctx, createCreateRequest(tc.smcp))
if tc.allowed {
defer func() {
if t.Failed() {
t.Logf("Unexpected validation Error: %s", response.Response.Result.Message)
}
}()
assert.True(response.Response.Allowed, "Expected validator to accept ServiceMeshControlPlane", t)
} else {
assert.False(response.Response.Allowed, "Expected validator to reject ServiceMeshControlPlane", t)
t.Logf("Validation Error: %s", response.Response.Result.Message)
}
})
}
})
}
} | explode_data.jsonl/20792 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2151
} | [
2830,
3393,
5637,
13799,
1155,
353,
8840,
836,
8,
341,
13158,
1186,
5638,
2036,
341,
197,
11609,
414,
914,
198,
197,
72023,
4672,
414,
353,
1728,
3758,
402,
16,
13860,
14194,
3273,
34570,
198,
197,
197,
21002,
2915,
55280,
4672,
353,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReplaceHook_CreateHook(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
hooks := []*scm.Hook{}
hookInput := &scm.HookInput{
Target: "https://drone.company.com/hook",
}
remote := mockscm.NewMockRepositoryService(controller)
remote.EXPECT().ListHooks(gomock.Any(), "octocat/hello-world", gomock.Any()).Return(hooks, nil, nil)
remote.EXPECT().CreateHook(gomock.Any(), "octocat/hello-world", hookInput).Return(nil, nil, nil)
client := new(scm.Client)
client.Repositories = remote
err := replaceHook(context.Background(), client, "octocat/hello-world", hookInput)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/40650 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
23107,
31679,
34325,
31679,
1155,
353,
8840,
836,
8,
341,
61615,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
6461,
991,
18176,
2822,
9598,
14685,
1669,
29838,
2388,
76,
3839,
1941,
16094,
9598,
1941,
2505,
1669,
609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMultithreading(t *testing.T) {
// Setup a router that needs to read the routing table essentially on every access to
// stress threading a bit more.
num := 0
table := &db.RoutingTable{Readers: []string{"rd1", "rd2"}, Writers: []string{"wr"}, TimeToLive: 1}
pool := &poolFake{
borrow: func(names []string, cancel context.CancelFunc, _ log.BoltLogger) (db.Connection, error) {
num++
return &testutil.ConnFake{Table: table}, nil
},
}
n := time.Now()
router := New("router", func() []string { return []string{} }, nil, pool, logger, "routerid")
mut := sync.Mutex{}
router.now = func() time.Time {
// Need to lock here to make race detector happy
mut.Lock()
defer mut.Unlock()
n = n.Add(time.Duration(table.TimeToLive) * time.Second * 2)
return n
}
dbName := "dbname"
wg := sync.WaitGroup{}
wg.Add(2)
consumer := func() {
for i := 0; i < 30; i++ {
readers, err := router.Readers(context.Background(), nil, dbName, nil)
if len(readers) != 2 {
t.Error("Wrong number of readers")
}
if err != nil {
t.Error(err)
}
writers, err := router.Writers(context.Background(), nil, dbName, nil)
if len(writers) != 1 {
t.Error("Wrong number of writers")
}
if err != nil {
t.Error(err)
}
}
wg.Done()
}
go consumer()
go consumer()
wg.Wait()
} | explode_data.jsonl/40048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 533
} | [
2830,
3393,
40404,
410,
6154,
1155,
353,
8840,
836,
8,
1476,
197,
322,
18626,
264,
9273,
429,
3880,
311,
1349,
279,
29058,
1965,
15791,
389,
1449,
2615,
311,
198,
197,
322,
8464,
30159,
264,
2699,
803,
624,
22431,
1669,
220,
15,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetMe(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
ruser, _, err := th.Client.GetMe("")
require.NoError(t, err)
require.Equal(t, th.BasicUser.Id, ruser.Id)
th.Client.Logout()
_, resp, err := th.Client.GetMe("")
require.Error(t, err)
CheckUnauthorizedStatus(t, resp)
} | explode_data.jsonl/47485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
1949,
7823,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
7000,
872,
11,
8358,
1848,
1669,
270,
11716,
2234,
7823,
31764,
17957,
35699,
1155,
11,
1848,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_SetNetworkConfig_Deep(t *testing.T) {
t.Skip() // Were causing intermittent errors on travis TODO Find root cause
test := test.NewTest(
rsm.NewProtocol(),
test.WithReplicas(1),
test.WithPartitions(1),
test.WithDebugLogs())
testify.NoError(t, test.Start())
defer test.Stop()
atomixClient, err := test.NewClient("test")
testify.NoError(t, err)
mgrTest, _ := setUpDeepTest(t, atomixClient)
// First verify the value beforehand
originalChange, _ := mgrTest.NetworkChangesStore.Get(networkChange1)
assert.Equal(t, len(originalChange.Changes[0].Values), 1)
assert.Equal(t, originalChange.Changes[0].Values[0].Path, test1Cont1ACont2ALeaf2A)
assert.Equal(t, originalChange.Changes[0].Values[0].Value.Type, devicechange.ValueType_FLOAT)
assert.Equal(t, (*devicechange.TypedFloat)(originalChange.Changes[0].Values[0].Value).Float32(), float32(valueLeaf2B159))
// Making change
updates := make(devicechange.TypedValueMap)
updates[test1Cont1ACont2ALeaf2A] = devicechange.NewTypedValueUint(valueLeaf2A789, 16)
deletes := []string{test1Cont1ACont2ALeaf2C}
updatesForDevice1, deletesForDevice1, deviceInfo := makeDeviceChanges(device1, updates, deletes)
// Verify the change
validationError := mgrTest.ValidateNetworkConfig(device1, deviceVersion1, deviceTypeTd, updates, deletes, 0)
assert.NilError(t, validationError, "ValidateTargetConfig error")
// Set the new change
const testNetworkChange networkchange.ID = "Test_SetNetworkConfig"
_, err = mgrTest.SetNetworkConfig(updatesForDevice1, deletesForDevice1, deviceInfo, string(testNetworkChange))
assert.NilError(t, err, "SetTargetConfig error")
nwChangeUpdates := make(chan stream.Event)
ctx, err := mgrTest.NetworkChangesStore.Watch(nwChangeUpdates, networkstore.WithChangeID(testNetworkChange))
assert.NilError(t, err)
defer ctx.Close()
breakout := false
for { // 3 responses are expected PENDING, RUNNING and COMPLETE
select {
case eventObj := <-nwChangeUpdates: //Blocks until event from NW change
event := eventObj.Object.(*networkchange.NetworkChange)
t.Logf("Event received %v", event)
if event.Status.State == changetypes.State_COMPLETE {
breakout = true
}
case <-time.After(10 * time.Second):
t.FailNow()
}
if breakout {
break
}
}
testUpdate, _ := mgrTest.NetworkChangesStore.Get(testNetworkChange)
assert.Assert(t, testUpdate != nil)
assert.Equal(t, testUpdate.ID, testNetworkChange, "Change Ids should correspond")
assert.Equal(t, changetypes.Phase_CHANGE, testUpdate.Status.Phase)
assert.Equal(t, changetypes.State_COMPLETE, testUpdate.Status.State)
// Check that the created change is correct
updatedVals := testUpdate.Changes[0].Values
assert.Equal(t, len(updatedVals), 2)
for _, updatedVal := range updatedVals {
switch updatedVal.Path {
case test1Cont1ACont2ALeaf2A:
assert.Equal(t, (*devicechange.TypedUint)(updatedVal.GetValue()).Uint(), valueLeaf2A789)
assert.Equal(t, updatedVal.Removed, false)
case test1Cont1ACont2ALeaf2C:
assert.Equal(t, updatedVal.GetValue().ValueToString(), "")
assert.Equal(t, updatedVal.Removed, true)
default:
t.Errorf("Unexpected path: %s", updatedVal.Path)
}
}
} | explode_data.jsonl/41401 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1131
} | [
2830,
3393,
14812,
12320,
2648,
24597,
747,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
368,
442,
38970,
14381,
74468,
5975,
389,
10137,
285,
5343,
7379,
3704,
5240,
271,
18185,
1669,
1273,
7121,
2271,
1006,
197,
7000,
3563,
7121,
20689,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestMarkConversation(t *testing.T) {
once.Do(startServer)
api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/"))
err := api.MarkConversation("CXXXXXXXX", "1401383885.000061")
if err != nil {
t.Errorf("Unexpected error: %s", err)
return
}
} | explode_data.jsonl/78555 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
8949,
60313,
1155,
353,
8840,
836,
8,
341,
197,
13184,
33596,
10639,
5475,
340,
54299,
1669,
1532,
445,
8840,
34841,
497,
6959,
7082,
3144,
445,
1254,
1110,
5572,
4030,
13986,
27569,
5455,
9859,
1669,
6330,
75888,
60313,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDSNParser(t *testing.T) {
var cfg *config
var err error
var res string
for i, tst := range testDSNs {
cfg, err = parseDSN(tst.in)
if err != nil {
t.Error(err.Error())
}
// pointer not static
cfg.tls = nil
res = fmt.Sprintf("%+v", cfg)
if res != fmt.Sprintf(tst.out, tst.loc) {
t.Errorf("%d. parseDSN(%q) => %q, want %q", i, tst.in, res, fmt.Sprintf(tst.out, tst.loc))
}
}
} | explode_data.jsonl/71457 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
5936,
45,
6570,
1155,
353,
8840,
836,
8,
341,
2405,
13286,
353,
1676,
198,
2405,
1848,
1465,
198,
2405,
592,
914,
271,
2023,
600,
11,
71707,
1669,
2088,
1273,
5936,
47360,
341,
197,
50286,
11,
1848,
284,
4715,
5936,
45,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestPrescalingPreventDelete(t *testing.T) {
stackPrescalingTimeout := 5
t.Parallel()
stacksetName := "stackset-prevent-delete"
factory := NewTestStacksetSpecFactory(stacksetName).StackGC(1, 15).Ingress().Replicas(3)
// create stackset with first version
firstVersion := "v1"
fullFirstStack := fmt.Sprintf("%s-%s", stacksetName, firstVersion)
firstCreateTimestamp := time.Now()
err := createStackSet(stacksetName, stackPrescalingTimeout, factory.Create(firstVersion))
require.NoError(t, err)
_, err = waitForDeployment(t, fullFirstStack)
require.NoError(t, err)
_, err = waitForIngress(t, fullFirstStack)
require.NoError(t, err)
// update stackset with second version
secondVersion := "v2"
fullSecondStack := fmt.Sprintf("%s-%s", stacksetName, firstVersion)
secondCreateTimestamp := time.Now()
err = updateStackset(stacksetName, factory.Create(secondVersion))
require.NoError(t, err)
_, err = waitForDeployment(t, fullSecondStack)
require.NoError(t, err)
_, err = waitForIngress(t, fullSecondStack)
require.NoError(t, err)
// switch all traffic to the new stack
desiredTrafficMap := map[string]float64{
fullSecondStack: 100,
}
err = setDesiredTrafficWeightsIngress(stacksetName, desiredTrafficMap)
require.NoError(t, err)
err = trafficWeightsUpdatedIngress(t, stacksetName, weightKindActual, desiredTrafficMap, nil).withTimeout(2 * time.Minute).await()
require.NoError(t, err)
// update stackset with third version
thirdVersion := "v3"
fullThirdStack := fmt.Sprintf("%s-%s", stacksetName, firstVersion)
thirdCreateTimestamp := time.Now()
err = updateStackset(stacksetName, factory.Create(thirdVersion))
require.NoError(t, err)
_, err = waitForDeployment(t, fullThirdStack)
require.NoError(t, err)
_, err = waitForIngress(t, fullThirdStack)
require.NoError(t, err)
desiredTrafficMap = map[string]float64{
fullThirdStack: 100,
}
err = setDesiredTrafficWeightsIngress(stacksetName, desiredTrafficMap)
require.NoError(t, err)
err = trafficWeightsUpdatedIngress(t, stacksetName, weightKindActual, desiredTrafficMap, nil).withTimeout(2 * time.Minute).await()
require.NoError(t, err)
// verify that all stack deployments are still present and their prescaling is active
for time.Now().Before(firstCreateTimestamp.Add(time.Minute * time.Duration(stackPrescalingTimeout))) {
firstDeployment, err := waitForDeployment(t, fullFirstStack)
require.NoError(t, err)
require.EqualValues(t, 3, *firstDeployment.Spec.Replicas)
time.Sleep(15 * time.Second)
}
for time.Now().Before(secondCreateTimestamp.Add(time.Minute * time.Duration(stackPrescalingTimeout))) {
secondDeployment, err := waitForDeployment(t, fullSecondStack)
require.NoError(t, err)
require.EqualValues(t, 3, *secondDeployment.Spec.Replicas)
time.Sleep(15 * time.Second)
}
for time.Now().Before(thirdCreateTimestamp.Add(time.Minute * time.Duration(stackPrescalingTimeout))) {
thirdDeployment, err := waitForDeployment(t, fullThirdStack)
require.NoError(t, err)
require.EqualValues(t, 3, *thirdDeployment.Spec.Replicas)
time.Sleep(15 * time.Second)
}
} | explode_data.jsonl/4348 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1067
} | [
2830,
3393,
14367,
81552,
4703,
684,
6435,
1155,
353,
8840,
836,
8,
341,
48227,
14367,
81552,
7636,
1669,
220,
20,
198,
3244,
41288,
7957,
741,
48227,
40730,
1669,
330,
7693,
746,
21334,
684,
40904,
698,
1166,
2919,
1669,
1532,
2271,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestUpdateClusterIndex(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec(`use test`)
tk.Session().GetSessionVars().EnableClusteredIndex = variable.ClusteredIndexDefModeOn
tk.MustExec(`drop table if exists t`)
tk.MustExec(`create table t(id varchar(200) primary key, v int)`)
tk.MustExec(`insert into t(id, v) values ('abc', 233)`)
tk.MustQuery(`select id, v from t where id = 'abc'`).Check(testkit.Rows("abc 233"))
tk.MustExec(`update t set id = 'dfg' where id = 'abc'`)
tk.MustQuery(`select * from t`).Check(testkit.Rows("dfg 233"))
tk.MustExec(`update t set id = 'aaa', v = 333 where id = 'dfg'`)
tk.MustQuery(`select * from t where id = 'aaa'`).Check(testkit.Rows("aaa 333"))
tk.MustExec(`update t set v = 222 where id = 'aaa'`)
tk.MustQuery(`select * from t where id = 'aaa'`).Check(testkit.Rows("aaa 222"))
tk.MustExec(`insert into t(id, v) values ('bbb', 111)`)
tk.MustGetErrCode(`update t set id = 'bbb' where id = 'aaa'`, errno.ErrDupEntry)
tk.MustExec(`drop table if exists ut3pk`)
tk.MustExec(`create table ut3pk(id1 varchar(200), id2 varchar(200), v int, id3 int, primary key(id1, id2, id3))`)
tk.MustExec(`insert into ut3pk(id1, id2, v, id3) values ('aaa', 'bbb', 233, 111)`)
tk.MustQuery(`select id1, id2, id3, v from ut3pk where id1 = 'aaa' and id2 = 'bbb' and id3 = 111`).Check(testkit.Rows("aaa bbb 111 233"))
tk.MustExec(`update ut3pk set id1 = 'abc', id2 = 'bbb2', id3 = 222, v = 555 where id1 = 'aaa' and id2 = 'bbb' and id3 = 111`)
tk.MustQuery(`select id1, id2, id3, v from ut3pk where id1 = 'abc' and id2 = 'bbb2' and id3 = 222`).Check(testkit.Rows("abc bbb2 222 555"))
tk.MustQuery(`select id1, id2, id3, v from ut3pk`).Check(testkit.Rows("abc bbb2 222 555"))
tk.MustExec(`update ut3pk set v = 666 where id1 = 'abc' and id2 = 'bbb2' and id3 = 222`)
tk.MustQuery(`select id1, id2, id3, v from ut3pk`).Check(testkit.Rows("abc bbb2 222 666"))
tk.MustExec(`insert into ut3pk(id1, id2, id3, v) values ('abc', 'bbb3', 222, 777)`)
tk.MustGetErrCode(`update ut3pk set id2 = 'bbb3' where id1 = 'abc' and id2 = 'bbb2' and id3 = 222`, errno.ErrDupEntry)
tk.MustExec(`drop table if exists ut1pku`)
tk.MustExec(`create table ut1pku(id varchar(200) primary key, uk int, v int, unique key ukk(uk))`)
tk.MustExec(`insert into ut1pku(id, uk, v) values('a', 1, 2), ('b', 2, 3)`)
tk.MustQuery(`select * from ut1pku`).Check(testkit.Rows("a 1 2", "b 2 3"))
tk.MustExec(`update ut1pku set uk = 3 where id = 'a'`)
tk.MustQuery(`select * from ut1pku`).Check(testkit.Rows("a 3 2", "b 2 3"))
tk.MustGetErrCode(`update ut1pku set uk = 2 where id = 'a'`, errno.ErrDupEntry)
tk.MustQuery(`select * from ut1pku`).Check(testkit.Rows("a 3 2", "b 2 3"))
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a char(10) primary key, b char(10));")
tk.MustExec("insert into t values('a', 'b');")
tk.MustExec("update t set a='c' where t.a='a' and b='b';")
tk.MustQuery("select * from t").Check(testkit.Rows("c b"))
tk.MustExec("drop table if exists s")
tk.MustExec("create table s (a int, b int, c int, primary key (a, b))")
tk.MustExec("insert s values (3, 3, 3), (5, 5, 5)")
tk.MustExec("update s set c = 10 where a = 3")
tk.MustQuery("select * from s").Check(testkit.Rows("3 3 10", "5 5 5"))
} | explode_data.jsonl/76265 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1405
} | [
2830,
3393,
4289,
28678,
1552,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50463,
10216,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSolution(t *testing.T) {
t.Parallel()
type in struct {
q, h, s, d, n int
}
tests := []struct {
in in
want int
}{
{in: in{q: 20, h: 30, s: 70, d: 90, n: 3}, want: 150},
{in: in{q: 10000, h: 1000, s: 100, d: 10, n: 1}, want: 100},
{in: in{q: 10, h: 100, s: 1000, d: 10000, n: 1}, want: 40},
}
for i, tt := range tests {
i, tt := i, tt
t.Run(fmt.Sprint(i), func(t *testing.T) {
t.Parallel()
got := solution(tt.in.q, tt.in.h, tt.in.s, tt.in.d, tt.in.n)
if got != tt.want {
t.Fatalf("in: %v got: %v want: %v", tt.in, got, tt.want)
}
})
}
} | explode_data.jsonl/76126 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 320
} | [
2830,
3393,
36842,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
13158,
304,
2036,
341,
197,
18534,
11,
305,
11,
274,
11,
294,
11,
308,
526,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
17430,
256,
304,
198,
197,
50780,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNonExistentCommandLineFile(t *testing.T) {
loadingRules := ClientConfigLoadingRules{
ExplicitPath: "bogus_file",
}
_, err := loadingRules.Load()
if err == nil {
t.Fatalf("Expected error for missing command-line file, got none")
}
if !strings.Contains(err.Error(), "bogus_file") {
t.Fatalf("Expected error about 'bogus_file', got %s", err.Error())
}
} | explode_data.jsonl/67846 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
8121,
840,
18128,
71885,
1703,
1155,
353,
8840,
836,
8,
341,
197,
10628,
26008,
1669,
8423,
2648,
8578,
26008,
515,
197,
197,
98923,
1820,
25,
330,
65,
538,
355,
2458,
756,
197,
630,
197,
6878,
1848,
1669,
8277,
26008,
139... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestText_MinSize(t *testing.T) {
text := NewText("Test", color.RGBA{0, 0, 0, 0xff})
min := text.MinSize()
assert.True(t, min.Width > 0)
assert.True(t, min.Height > 0)
text = NewText("Test2", color.RGBA{0, 0, 0, 0xff})
min2 := text.MinSize()
assert.True(t, min2.Width > min.Width)
} | explode_data.jsonl/5954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
1178,
62122,
1695,
1155,
353,
8840,
836,
8,
341,
15425,
1669,
1532,
1178,
445,
2271,
497,
1894,
80114,
32,
90,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
9020,
3518,
25320,
1669,
1467,
17070,
1695,
2822,
6948,
32443,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestProxy(t *testing.T) {
// Setup
t1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "target 1")
}))
defer t1.Close()
url1, _ := url.Parse(t1.URL)
t2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "target 2")
}))
defer t2.Close()
url2, _ := url.Parse(t2.URL)
targets := []*fwncs.ProxyTarget{
{
Name: "target 1",
URL: url1,
},
{
Name: "target 2",
URL: url2,
},
}
wTargets := []*fwncs.WeightProxyTarget{
{
Weight: 1,
ProxyTarget: &fwncs.ProxyTarget{
Name: "target 1",
URL: url1,
},
},
{
Weight: 1,
ProxyTarget: &fwncs.ProxyTarget{
Name: "target 2",
URL: url2,
},
},
}
tt := tests.TestFrames{
{
Name: "Rondom Balancer",
Fn: func(t *testing.T) {
rb := fwncs.NewRandomBalancer(nil)
for _, target := range targets {
assert.True(t, rb.Add(target))
}
for _, target := range targets {
assert.False(t, rb.Add(target))
}
for _, target := range wTargets {
assert.False(t, rb.Add(target))
}
router := fwncs.New()
router.Use(fwncs.Proxy(rb))
req := httptest.NewRequest(http.MethodGet, "/", nil)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
body := rec.Body.String()
expected := map[string]bool{
"target 1": true,
"target 2": true,
}
assert.Condition(t, func() bool {
return expected[body]
})
for _, target := range targets {
assert.True(t, rb.Remove(target.Name))
}
assert.False(t, rb.Remove("unknown target"))
},
},
{
Name: "Roundrobin Balancer",
Fn: func(t *testing.T) {
rrb := fwncs.NewRoundRobinBalancer(targets)
router := fwncs.New()
router.Use(fwncs.Proxy(rrb))
req := httptest.NewRequest(http.MethodGet, "/", nil)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
body := rec.Body.String()
assert.Equal(t, "target 1", body)
rec = httptest.NewRecorder()
router.ServeHTTP(rec, req)
body = rec.Body.String()
assert.Equal(t, "target 2", body)
// ModifyResponse
router = fwncs.New()
router.Use(fwncs.ProxyWithConfig(fwncs.ProxyConfig{
LoadBalancer: rrb,
ModifyResponse: func(res *http.Response) error {
res.Body = ioutil.NopCloser(bytes.NewBuffer([]byte("modified")))
res.Header.Set("X-Modified", "1")
return nil
},
}))
rec = httptest.NewRecorder()
router.ServeHTTP(rec, req)
assert.Equal(t, "modified", rec.Body.String())
assert.Equal(t, "1", rec.Header().Get("X-Modified"))
},
},
}
tt.Run(t)
} | explode_data.jsonl/41286 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1291
} | [
2830,
3393,
16219,
1155,
353,
8840,
836,
8,
341,
197,
322,
18626,
198,
3244,
16,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
11009,
991,
1350,
3622,
11,
330,
5657,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnmarshal_WithUnmarshalerRec(t *testing.T) {
type testStruct struct {
String testUnmarshalerRecString
Struct testUnmarshalerRecStruct
Arraytable []testStruct
}
var v testStruct
err := Unmarshal(loadTestData("unmarshal-unmarshalerrec.toml"), &v)
if err != nil {
t.Fatal("Unexpected error:", err)
}
expect := testStruct{
String: "Unmarshaled: str1",
Struct: testUnmarshalerRecStruct{a: 1, b: 2},
Arraytable: []testStruct{
{
String: "Unmarshaled: str2",
Struct: testUnmarshalerRecStruct{a: 3, b: 4},
},
},
}
if !reflect.DeepEqual(v, expect) {
t.Errorf(`toml.Unmarshal(data, &v); v => %#v; want %#v`, v, expect)
}
} | explode_data.jsonl/52964 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 296
} | [
2830,
3393,
1806,
27121,
62,
2354,
1806,
27121,
261,
3820,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
9422,
2036,
341,
197,
4980,
257,
1273,
1806,
27121,
261,
3820,
703,
198,
197,
197,
9422,
257,
1273,
1806,
27121,
261,
3820,
9422,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCCInfoFSPeerInstance(t *testing.T) {
ccname := "bar"
ccver := "1.0"
ccpath := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd"
//CC数据尚不在缓存中
_, err := GetChaincodeFromFS(ccname, ccver)
assert.Error(t, err)
//创建要放置的DEP规范
ds, err := getDepSpec(ccname, ccpath, ccver, [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
assert.NoError(t, err)
//放它
err = PutChaincodeIntoFS(ds)
assert.NoError(t, err)
//获取所有已安装的链码,不应返回0个链码
resp, err := GetInstalledChaincodes()
assert.NoError(t, err)
assert.NotNil(t, resp)
assert.NotZero(t, len(resp.Chaincodes), "GetInstalledChaincodes should not have returned 0 chaincodes")
//获取链码数据
_, err = GetChaincodeData(ccname, ccver)
assert.NoError(t, err)
} | explode_data.jsonl/10595 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 386
} | [
2830,
3393,
3706,
1731,
37,
4592,
34756,
2523,
1155,
353,
8840,
836,
8,
341,
63517,
606,
1669,
330,
2257,
698,
63517,
423,
1669,
330,
16,
13,
15,
698,
63517,
2343,
1669,
330,
5204,
905,
7530,
39252,
50704,
6663,
28897,
67020,
14,
8819... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStickyLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
client1 := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0}
client2 := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 2), Port: 0}
client3 := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 3), Port: 0}
loadBalancer := NewLoadBalancerRR()
service := proxy.ServicePortName{NamespacedName: types.NamespacedName{Namespace: "testnamespace", Name: "foo"}, Port: ""}
endpoint, err := loadBalancer.NextEndpoint(service, nil, false)
if err == nil || len(endpoint) != 0 {
t.Errorf("Didn't fail with non-existent service")
}
loadBalancer.NewService(service, api.ServiceAffinityClientIP, 0)
endpoints := make([]api.Endpoints, 1)
endpoints[0] = api.Endpoints{
ObjectMeta: api.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{
{
Addresses: []api.EndpointAddress{{IP: "endpoint"}},
Ports: []api.EndpointPort{{Port: 1}, {Port: 2}, {Port: 3}},
},
},
}
loadBalancer.OnEndpointsUpdate(endpoints)
shuffledEndpoints := loadBalancer.services[service].endpoints
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[0], client1)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[0], client1)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[1], client2)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[1], client2)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[2], client3)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[0], client1)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[1], client2)
// Then update the configuration with one fewer endpoints, make sure
// we start in the beginning again
endpoints[0] = api.Endpoints{
ObjectMeta: api.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Subsets: []api.EndpointSubset{
{
Addresses: []api.EndpointAddress{{IP: "endpoint"}},
Ports: []api.EndpointPort{{Port: 4}, {Port: 5}},
},
},
}
loadBalancer.OnEndpointsUpdate(endpoints)
shuffledEndpoints = loadBalancer.services[service].endpoints
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[0], client1)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[1], client2)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[0], client1)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[0], client1)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[1], client2)
expectEndpoint(t, loadBalancer, service, shuffledEndpoints[1], client2)
// Clear endpoints
endpoints[0] = api.Endpoints{ObjectMeta: api.ObjectMeta{Name: service.Name, Namespace: service.Namespace}, Subsets: nil}
loadBalancer.OnEndpointsUpdate(endpoints)
endpoint, err = loadBalancer.NextEndpoint(service, nil, false)
if err == nil || len(endpoint) != 0 {
t.Errorf("Didn't fail with non-existent service")
}
} | explode_data.jsonl/66182 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1040
} | [
2830,
3393,
623,
18964,
5879,
21190,
6776,
16056,
32089,
80786,
3036,
37091,
1155,
353,
8840,
836,
8,
341,
25291,
16,
1669,
609,
4711,
836,
7123,
13986,
90,
3298,
25,
4179,
46917,
85,
19,
7,
16,
17,
22,
11,
220,
15,
11,
220,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestAddOrRemoveExternalMonitor(t *testing.T) {
var changed bool
var err error
// populate fake monmap
fakeResp := client.MonStatusResponse{Quorum: []int{0}}
fakeResp.MonMap.Mons = []client.MonMapEntry{
{
Name: "a",
},
}
fakeResp.MonMap.Mons[0].PublicAddr = "172.17.0.4:3300"
// populate fake ClusterInfo
c := &Cluster{ClusterInfo: &client.ClusterInfo{}}
c.ClusterInfo = clienttest.CreateTestClusterInfo(1)
//
// TEST 1
//
// both clusterInfo and mon map are identical so nil is expected
changed, err = c.addOrRemoveExternalMonitor(fakeResp)
assert.NoError(t, err)
assert.False(t, changed)
assert.Equal(t, 1, len(c.ClusterInfo.Monitors))
//
// TEST 2
//
// Now let's test the case where mon disappeared from the external cluster
// ClusterInfo still has them but they are gone from the monmap.
// Thus they should be removed from ClusterInfo
c.ClusterInfo = clienttest.CreateTestClusterInfo(3)
changed, err = c.addOrRemoveExternalMonitor(fakeResp)
assert.NoError(t, err)
assert.True(t, changed)
// ClusterInfo should shrink to 1
assert.Equal(t, 1, len(c.ClusterInfo.Monitors))
//
// TEST 3
//
// Now let's add a new mon in the external cluster
// ClusterInfo should be updated with this new monitor
fakeResp.MonMap.Mons = []client.MonMapEntry{
{
Name: "a",
},
{
Name: "b",
},
}
fakeResp.MonMap.Mons[1].PublicAddr = "172.17.0.5:3300"
c.ClusterInfo = clienttest.CreateTestClusterInfo(1)
changed, err = c.addOrRemoveExternalMonitor(fakeResp)
assert.NoError(t, err)
assert.True(t, changed)
// ClusterInfo should now have 2 monitors
assert.Equal(t, 2, len(c.ClusterInfo.Monitors))
} | explode_data.jsonl/36575 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 605
} | [
2830,
3393,
2212,
2195,
13021,
25913,
30098,
1155,
353,
8840,
836,
8,
341,
2405,
5497,
1807,
198,
2405,
1848,
1465,
271,
197,
322,
30446,
12418,
1615,
2186,
198,
1166,
726,
36555,
1669,
2943,
52211,
2522,
2582,
90,
2183,
33006,
25,
3056... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNotSameHash(t *testing.T) {
hasher1, err := DefaultFactory.GetHasher(SHA256)
if err != nil {
t.Fatal("Unable to retrieve SHA256 Hasher")
}
hasher2, err := DefaultFactory.GetHasher(SHA256)
if err != nil {
t.Fatal("Unable to retrieve SHA256 Hasher")
}
h12345 := "dd712114fb283417de4da3512e17486adbda004060d0d1646508c8a2740d29b4"
h1 := fmt.Sprintf("%x", hasher1.Hash(int64(1)).H)
h2 := fmt.Sprintf("%x", hasher2.Hash(int64(1)).H)
if h1 == h2 || h1 == h12345 || h2 == h12345 {
fmt.Println(h12345)
fmt.Println(h1)
fmt.Println(h2)
t.Fatal("Different hashers give same hash for the same value")
}
} | explode_data.jsonl/42624 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 282
} | [
2830,
3393,
2623,
19198,
6370,
1155,
353,
8840,
836,
8,
1476,
50333,
261,
16,
11,
1848,
1669,
7899,
4153,
2234,
6370,
261,
3759,
17020,
17,
20,
21,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
445,
17075,
311,
17179,
21721,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestClusterAdminDeleteRecords(t *testing.T) {
topicName := "my_topic"
seedBroker := NewMockBroker(t, 1)
defer seedBroker.Close()
seedBroker.SetHandlerByMap(map[string]MockResponse{
"MetadataRequest": NewMockMetadataResponse(t).
SetController(seedBroker.BrokerID()).
SetBroker(seedBroker.Addr(), seedBroker.BrokerID()).
SetLeader(topicName, 1, 1).
SetLeader(topicName, 2, 1).
SetLeader(topicName, 3, 1),
"DeleteRecordsRequest": NewMockDeleteRecordsResponse(t),
})
config := NewTestConfig()
config.Version = V1_0_0_0
admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
if err != nil {
t.Fatal(err)
}
partitionOffsetFake := make(map[int32]int64)
partitionOffsetFake[4] = 1000
errFake := admin.DeleteRecords(topicName, partitionOffsetFake)
if errFake == nil {
t.Fatal(err)
}
partitionOffset := make(map[int32]int64)
partitionOffset[1] = 1000
partitionOffset[2] = 1000
partitionOffset[3] = 1000
err = admin.DeleteRecords(topicName, partitionOffset)
if err != nil {
t.Fatal(err)
}
err = admin.Close()
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/40790 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 437
} | [
2830,
3393,
28678,
7210,
6435,
25876,
1155,
353,
8840,
836,
8,
341,
3244,
24810,
675,
1669,
330,
2408,
31414,
698,
197,
22602,
65545,
1669,
1532,
11571,
65545,
1155,
11,
220,
16,
340,
16867,
10320,
65545,
10421,
2822,
197,
22602,
65545,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGetLocalAddress(t *testing.T) {
e := &ConnectedEndpoint{path: "foo"}
want := tcpip.FullAddress{Addr: tcpip.Address("foo")}
if got, err := e.GetLocalAddress(); err != nil || got != want {
t.Errorf("Got %#v.GetLocalAddress() = %#v, %v, want = %#v, %v", e, got, err, want, nil)
}
} | explode_data.jsonl/257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
1949,
7319,
4286,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
609,
21146,
27380,
90,
2343,
25,
330,
7975,
16707,
50780,
1669,
28051,
573,
32038,
4286,
90,
13986,
25,
28051,
573,
26979,
445,
7975,
42132,
743,
2684,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestContextGetStringSlice(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Set("slice", []string{"foo"})
assert.Equal(t, []string{"foo"}, c.GetStringSlice("slice"))
} | explode_data.jsonl/26753 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
1972,
48905,
33236,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
4230,
2271,
1972,
73392,
83,
70334,
7121,
47023,
2398,
1444,
4202,
445,
24963,
497,
3056,
917,
4913,
7975,
23625,
6948,
12808,
1155,
11,
3056,
917,
4913,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestGet_fileDecompressorExt(t *testing.T) {
dst := tempDir(t)
u := testModule("basic-tgz")
if err := Get(dst, u); err != nil {
t.Fatalf("err: %s", err)
}
mainPath := filepath.Join(dst, "main.tf")
if _, err := os.Stat(mainPath); err != nil {
t.Fatalf("err: %s", err)
}
} | explode_data.jsonl/808 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
1949,
2458,
4900,
316,
56220,
6756,
1155,
353,
8840,
836,
8,
341,
52051,
1669,
2730,
6184,
1155,
340,
10676,
1669,
1273,
3332,
445,
22342,
2385,
46589,
5130,
743,
1848,
1669,
2126,
30260,
11,
575,
1215,
1848,
961,
2092,
341,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCacheMountLockedRefs(t *testing.T) {
t.Parallel()
ctx := namespaces.WithNamespace(context.Background(), "buildkit-test")
tmpdir, err := ioutil.TempDir("", "cachemanager")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
snapshotter, err := native.NewSnapshotter(filepath.Join(tmpdir, "snapshots"))
require.NoError(t, err)
co, cleanup, err := newCacheManager(ctx, cmOpt{
snapshotter: snapshotter,
snapshotterName: "native",
})
require.NoError(t, err)
defer cleanup()
g1 := newRefGetter(co.manager, co.md, sharedCacheRefs)
g2 := newRefGetter(co.manager, co.md, sharedCacheRefs)
ref, err := g1.getRefCacheDir(ctx, nil, "foo", pb.CacheSharingOpt_LOCKED)
require.NoError(t, err)
ref2, err := g1.getRefCacheDir(ctx, nil, "bar", pb.CacheSharingOpt_LOCKED)
require.NoError(t, err)
// different ID returns different ref
require.NotEqual(t, ref.ID(), ref2.ID())
// same ID on same mount still shares the reference
ref3, err := g1.getRefCacheDir(ctx, nil, "foo", pb.CacheSharingOpt_LOCKED)
require.NoError(t, err)
require.Equal(t, ref.ID(), ref3.ID())
// same ID on different mount blocks
gotRef4 := make(chan struct{})
go func() {
ref4, err := g2.getRefCacheDir(ctx, nil, "foo", pb.CacheSharingOpt_LOCKED)
require.NoError(t, err)
require.Equal(t, ref.ID(), ref4.ID())
close(gotRef4)
}()
select {
case <-gotRef4:
require.FailNow(t, "mount did not lock")
case <-time.After(500 * time.Millisecond):
}
ref.Release(ctx)
ref3.Release(ctx)
select {
case <-gotRef4:
case <-time.After(500 * time.Millisecond):
require.FailNow(t, "mount did not unlock")
}
} | explode_data.jsonl/50741 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 638
} | [
2830,
3393,
8233,
16284,
49010,
82807,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20985,
1669,
58091,
26124,
22699,
5378,
19047,
1507,
330,
5834,
8226,
16839,
5130,
20082,
3741,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConvergence(t *testing.T) {
// scenario:
// {boot peer: [peer list]}
// {d1: d2, d3, d4}
// {d5: d6, d7, d8}
// {d9: d10, d11, d12}
// connect all boot peers with d13
// take down d13
// ensure still full membership
instances := []*gossipInstance{}
for _, i := range []int{1, 5, 9} {
bootPort := 4610 + i
id := fmt.Sprintf("d%d", i)
leader := createDiscoveryInstance(bootPort, id, []string{})
instances = append(instances, leader)
for minionIndex := 1; minionIndex <= 3; minionIndex++ {
id := fmt.Sprintf("d%d", i+minionIndex)
minion := createDiscoveryInstance(4610+minionIndex+i, id, []string{bootPeer(bootPort)})
instances = append(instances, minion)
}
}
assertMembership(t, instances, 3)
connector := createDiscoveryInstance(4623, "d13", []string{bootPeer(4611), bootPeer(4615), bootPeer(4619)})
instances = append(instances, connector)
assertMembership(t, instances, 12)
connector.Stop()
instances = instances[:len(instances)-1]
assertMembership(t, instances, 11)
stopInstances(t, instances)
} | explode_data.jsonl/62268 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 407
} | [
2830,
3393,
1109,
80748,
1155,
353,
8840,
836,
8,
341,
197,
322,
15048,
510,
197,
322,
314,
4619,
14397,
25,
508,
16537,
1140,
23439,
197,
322,
314,
67,
16,
25,
294,
17,
11,
294,
18,
11,
294,
19,
532,
197,
322,
314,
67,
20,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_swapRuleV3_getSwapInOffset(t *testing.T) {
type args struct {
lenCommitteesAfterSwapOut int
lenSubstitutes int
maxCommitteeSize int
numberOfSlashingValidators int
lenCommitteesBeforeSwapOut int
}
tests := []struct {
name string
s *swapRuleV3
args args
wantSwapInOffSet int
}{
{
name: "C_old < MaxCommitteeSize && SL > C/8 && SI < SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 52,
lenSubstitutes: 4,
maxCommitteeSize: 64,
numberOfSlashingValidators: 10,
lenCommitteesBeforeSwapOut: 62,
},
wantSwapInOffSet: 4,
},
{
name: "C_old < MaxCommitteeSize && SL > C/8 && SI < SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 52,
lenSubstitutes: 20,
maxCommitteeSize: 64,
numberOfSlashingValidators: 10,
lenCommitteesBeforeSwapOut: 62,
},
wantSwapInOffSet: 6,
},
{
name: "C_old < MaxCommitteeSize && SL < C/8 && SI > SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 56,
lenSubstitutes: 3,
maxCommitteeSize: 64,
numberOfSlashingValidators: 4,
lenCommitteesBeforeSwapOut: 60,
},
wantSwapInOffSet: 3,
},
{
name: "C_old < MaxCommitteeSize && SL < C/8 && SI < SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 46,
lenSubstitutes: 20,
maxCommitteeSize: 64,
numberOfSlashingValidators: 4,
lenCommitteesBeforeSwapOut: 50,
},
wantSwapInOffSet: 5,
},
{
name: "C_old = MaxCommitteeSize && SL > 0 && SL >= C/8 && SI < SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 48,
lenSubstitutes: 3,
maxCommitteeSize: 64,
numberOfSlashingValidators: 16,
lenCommitteesBeforeSwapOut: 64,
},
wantSwapInOffSet: 3,
},
{
name: "C_old = MaxCommitteeSize && SL > 0 && SL > C/8 && SI < SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 48,
lenSubstitutes: 20,
maxCommitteeSize: 64,
numberOfSlashingValidators: 16,
lenCommitteesBeforeSwapOut: 64,
},
wantSwapInOffSet: 6,
},
{
name: "C_old = MaxCommitteeSize && SL > 0 && SL < C/8 && SI < SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 60,
lenSubstitutes: 4,
maxCommitteeSize: 64,
numberOfSlashingValidators: 4,
lenCommitteesBeforeSwapOut: 64,
},
wantSwapInOffSet: 4,
},
{
name: "C_old = MaxCommitteeSize && SL > 0 && SL < C/8 && SI < SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 56,
lenSubstitutes: 20,
maxCommitteeSize: 64,
numberOfSlashingValidators: 4,
lenCommitteesBeforeSwapOut: 64,
},
wantSwapInOffSet: 7,
},
{
name: "C_old = MaxCommitteeSize && SL = 0 && SI < SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 60,
lenSubstitutes: 4,
maxCommitteeSize: 64,
numberOfSlashingValidators: 0,
lenCommitteesBeforeSwapOut: 64,
},
wantSwapInOffSet: 4,
},
{
name: "C_old = MaxCommitteeSize && SL = 0 && SI > SUB",
s: &swapRuleV3{},
args: args{
lenCommitteesAfterSwapOut: 56,
lenSubstitutes: 20,
maxCommitteeSize: 64,
numberOfSlashingValidators: 0,
lenCommitteesBeforeSwapOut: 64,
},
wantSwapInOffSet: 8,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &swapRuleV3{}
if got := s.getSwapInOffset(tt.args.lenCommitteesAfterSwapOut, tt.args.lenSubstitutes, tt.args.maxCommitteeSize, tt.args.numberOfSlashingValidators, tt.args.lenCommitteesBeforeSwapOut); got != tt.wantSwapInOffSet {
t.Errorf("swapRuleV3.getSwapInOffset() = %v, want %v", got, tt.wantSwapInOffSet)
}
})
}
} | explode_data.jsonl/62412 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2061
} | [
2830,
3393,
40991,
11337,
53,
18,
3062,
46179,
641,
6446,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
33111,
33441,
29800,
6025,
46179,
2662,
220,
526,
198,
197,
33111,
3136,
3696,
2095,
1797,
526,
198,
197,
22543,
33441,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestExifEditor_SetDirty(t *testing.T) {
je, _ := NewExifEditorEmpty(false)
if je.IsDirty() {
t.Errorf("Expected editor to not be dirty")
}
je.SetDirty()
if !je.IsDirty() {
t.Errorf("Expected editor to be dirty")
}
} | explode_data.jsonl/79882 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
840,
333,
9410,
14812,
36485,
1155,
353,
8840,
836,
8,
341,
197,
3756,
11,
716,
1669,
1532,
840,
333,
9410,
3522,
3576,
340,
743,
4759,
4506,
36485,
368,
341,
197,
3244,
13080,
445,
18896,
6440,
311,
537,
387,
18595,
1138,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestContainsProjectId(t *testing.T) {
endpointContains := []string{"https://as.eu-de.otc.t-systems.com/autoscaling-api/v1/f9842224f84e44f99c2878eddc7f9ef5",
"https://elb.t-systems.com/rds/v1.0/c9842224f84e44f99c2878eddc7f9ef5/",
"https://elb.eu-de.otc.t-systems.com/v1.1/c9842224f84e44f99c2878eddc7f9ef5",
"https://elb.eu-de.otc.t-systems.com/v2/c9842224f84e44f99c2878eddc7f9ef5",
"https://elb.eu-de.otc.t-systems.com/v2.0/c9842224f84e44f99c2878eddc7f9ef5",
"https://elb.eu-de.otc.t-systems.com/V2.0/c9842224f84e44f99c2878eddc7f9ef5/list",
"https://as.eu-de.otc.t-systems.com/autoscaling-api/v1/c9842224f84e44f99c2878eddc7f9ef5/abc",
"https://as.eu-de.otc.t-systems.com/autoscaling-api/V11/c9842224f84e44f99c2878eddc7f9ef5",
"https://as.eu-de.otc.t-systems.com/autoscaling-api/v2/c9842224f84e44f99c2878eddc7f9ef5",
"https://as.eu-de.otc.t-systems.com/autoscaling-api/V2/c9842224f84e44f99c2878eddc7f9ef5",
"http://as.eu-de.otc.t-systems.com/autoscaling-api/V2/c9842224f84e44f99c2878eddc7f9ef5"}
for _, enpoint := range endpointContains {
th.AssertEquals(t, true, openstack.ContainsProjectId(enpoint))
}
} | explode_data.jsonl/82340 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 619
} | [
2830,
3393,
23805,
7849,
764,
1155,
353,
8840,
836,
8,
341,
6246,
2768,
23805,
1669,
3056,
917,
4913,
2428,
1110,
300,
35003,
6810,
79361,
66,
734,
36648,
82,
905,
14,
79301,
81552,
23904,
5457,
16,
6663,
24,
23,
19,
17,
17,
17,
19,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestBuilder_LangFrom(t *testing.T) {
tests := []struct {
Name, Lang string
Expected language.Tag
}{
{
Name: "success creating language",
Lang: "en",
Expected: language.Make("en"),
},
{
Name: "empty language and empty tag",
Lang: "",
Expected: language.Tag{},
},
{
Name: "empty tag of parse err",
Lang: "xxxxxxxxxxx",
Expected: language.Tag{},
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()
b := New().NewID().LangFrom(tc.Lang).MustBuild()
assert.Equal(t, tc.Expected, b.Lang())
})
}
} | explode_data.jsonl/75867 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
3297,
2351,
524,
3830,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
21297,
11,
22463,
914,
198,
197,
197,
18896,
256,
4128,
23676,
198,
197,
59403,
197,
197,
515,
298,
21297,
25,
257,
330,
5630,
6825,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestData(t *testing.T) {
compose.EnsureUp(t, "logstash")
config := logstash.GetConfig("node_stats")
f := mbtest.NewReportingMetricSetV2(t, config)
err := mbtest.WriteEventsReporterV2(f, t, "")
if err != nil {
t.Fatal("write", err)
}
} | explode_data.jsonl/54992 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
93200,
1155,
353,
8840,
836,
8,
341,
32810,
2900,
22834,
19098,
2324,
1155,
11,
330,
839,
49771,
5130,
25873,
1669,
1487,
49771,
2234,
2648,
445,
3509,
15381,
1138,
1166,
1669,
10016,
1944,
7121,
70131,
54310,
1649,
53,
17,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestClientTimeoutKillsConn_BeforeHeaders(t *testing.T) {
setParallel(t)
defer afterTest(t)
inHandler := make(chan net.Conn, 1)
handlerReadReturned := make(chan bool, 1)
cst := newClientServerTest(t, h1Mode, HandlerFunc(func(w ResponseWriter, r *Request) {
conn, _, err := w.(Hijacker).Hijack()
if err != nil {
t.Error(err)
return
}
inHandler <- conn
n, err := conn.Read([]byte{0})
if n != 0 || err != io.EOF {
t.Errorf("unexpected Read result: %v, %v", n, err)
}
handlerReadReturned <- true
}))
defer cst.close()
const timeout = 50 * time.Millisecond
cst.c.Timeout = timeout
_, err := cst.c.Get(cst.ts.URL)
if err == nil {
t.Fatal("unexpected Get succeess")
}
select {
case c := <-inHandler:
select {
case <-handlerReadReturned:
// Success.
return
case <-time.After(5 * time.Second):
t.Error("Handler's conn.Read seems to be stuck in Read")
c.Close() // close it to unblock Handler
}
case <-time.After(timeout * 10):
// If we didn't get into the Handler in 50ms, that probably means
// the builder was just slow and the Get failed in that time
// but never made it to the server. That's fine. We'll usually
// test the part above on faster machines.
t.Skip("skipping test on slow builder")
}
} | explode_data.jsonl/14176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 487
} | [
2830,
3393,
2959,
7636,
42,
3305,
9701,
1668,
4642,
10574,
1155,
353,
8840,
836,
8,
341,
8196,
16547,
1155,
340,
16867,
1283,
2271,
1155,
340,
17430,
3050,
1669,
1281,
35190,
4179,
50422,
11,
220,
16,
340,
53326,
4418,
84804,
1669,
1281... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestInvalidRMIDToString(t *testing.T) {
rmidNotAllocatedProperly := replicationGroupMessageID{}
str := rmidNotAllocatedProperly.String()
if str != "" {
t.Error("got unexpected string: " + str)
}
} | explode_data.jsonl/72230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
7928,
23652,
915,
5870,
1155,
353,
8840,
836,
8,
341,
7000,
16106,
2623,
25154,
657,
1336,
712,
398,
1669,
47791,
2808,
2052,
915,
16094,
11355,
1669,
435,
16106,
2623,
25154,
657,
1336,
712,
398,
6431,
741,
743,
607,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestDPAReconciler_populateAWSRegistrySecret(t *testing.T) {
tests := []struct {
name string
bsl *velerov1.BackupStorageLocation
registrySecret *corev1.Secret
awsSecret *corev1.Secret
dpa *oadpv1alpha1.DataProtectionApplication
wantErr bool
}{
{
name: "Given Velero CR and bsl instance, appropriate registry secret is updated for aws case",
wantErr: false,
bsl: &velerov1.BackupStorageLocation{
ObjectMeta: metav1.ObjectMeta{
Name: "test-bsl",
Namespace: "test-ns",
},
Spec: velerov1.BackupStorageLocationSpec{
StorageType: velerov1.StorageType{
ObjectStorage: &velerov1.ObjectStorageLocation{
Bucket: "aws-bucket",
},
},
Config: map[string]string{
Region: "aws-region",
S3URL: "https://sr-url-aws-domain.com",
InsecureSkipTLSVerify: "false",
Profile: testBslProfile,
},
},
},
dpa: &oadpv1alpha1.DataProtectionApplication{
ObjectMeta: metav1.ObjectMeta{
Name: "Velero-test-CR",
Namespace: "test-ns",
},
},
awsSecret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "cloud-credentials",
Namespace: "test-ns",
},
Data: secretData,
},
registrySecret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "oadp-test-bsl-aws-registry-secret",
Namespace: "test-ns",
Labels: map[string]string{
oadpv1alpha1.OadpOperatorLabel: "True",
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fakeClient, err := getFakeClientFromObjects(tt.awsSecret, tt.dpa)
if err != nil {
t.Errorf("error in creating fake client, likely programmer error")
}
r := &DPAReconciler{
Client: fakeClient,
Scheme: fakeClient.Scheme(),
Log: logr.Discard(),
Context: newContextForTest(tt.name),
NamespacedName: types.NamespacedName{
Namespace: tt.bsl.Namespace,
Name: tt.bsl.Name,
},
EventRecorder: record.NewFakeRecorder(10),
}
wantRegistrySecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "oadp-" + tt.bsl.Name + "-" + tt.bsl.Spec.Provider + "-registry-secret",
Namespace: r.NamespacedName.Namespace,
Labels: map[string]string{
oadpv1alpha1.OadpOperatorLabel: "True",
},
},
Data: awsRegistrySecretData,
}
if err := r.populateAWSRegistrySecret(tt.bsl, tt.registrySecret); (err != nil) != tt.wantErr {
t.Errorf("populateAWSRegistrySecret() error = %v, wantErr %v", err, tt.wantErr)
}
if !reflect.DeepEqual(tt.registrySecret.Data, wantRegistrySecret.Data) {
t.Errorf("expected bsl labels to be %#v, got %#v", tt.registrySecret.Data, wantRegistrySecret.Data)
}
})
}
} | explode_data.jsonl/45549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1377
} | [
2830,
3393,
35,
8041,
693,
40446,
5769,
17061,
6334,
36136,
15603,
19773,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
341,
197,
11609,
1843,
914,
198,
197,
93801,
75,
310,
353,
889,
261,
859,
16,
8864,
454,
5793,
4707,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestRemoveQuad(t *testing.T) {
ctx := context.TODO()
qs, w, _ := makeTestStore(simpleGraph)
err := w.RemoveQuad(quad.Make(
"E",
"follows",
"F",
nil,
))
if err != nil {
t.Error("Couldn't remove quad", err)
}
fixed := iterator.NewFixed()
qsv, err := qs.ValueOf(quad.Raw("E"))
require.NoError(t, err)
fixed.Add(qsv)
fixed2 := iterator.NewFixed()
qsv, err = qs.ValueOf(quad.Raw("follows"))
require.NoError(t, err)
fixed2.Add(qsv)
innerAnd := iterator.NewAnd(
graph.NewLinksTo(qs, fixed, quad.Subject),
graph.NewLinksTo(qs, fixed2, quad.Predicate),
)
hasa := graph.NewHasA(qs, innerAnd, quad.Object)
newIt, _ := hasa.Optimize(ctx)
if newIt.Iterate().Next(ctx) {
t.Error("E should not have any followers.")
}
} | explode_data.jsonl/79103 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 320
} | [
2830,
3393,
13021,
43474,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
90988,
741,
18534,
82,
11,
289,
11,
716,
1669,
1281,
2271,
6093,
1141,
6456,
11212,
692,
9859,
1669,
289,
13270,
43474,
7,
31610,
50133,
1006,
197,
197,
77199,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMacd(t *testing.T) {
data := []float64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}
fast, slow, signal := talib.Macd(data, 12, 26, 9)
expectedFast := []float64{7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}
expectedSlow := []float64{7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}
expectedSignal := []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
if !reflect.DeepEqual(expectedFast, fast) {
t.Errorf("Expected %#v got %#v.", expectedFast, fast)
}
if !reflect.DeepEqual(expectedSlow, slow) {
t.Errorf("Expected %#v got %#v.", expectedSlow, slow)
}
if !reflect.DeepEqual(expectedSignal, signal) {
t.Errorf("Expected %#v got %#v.", expectedSignal, signal)
}
} | explode_data.jsonl/51212 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 490
} | [
2830,
3393,
19552,
67,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3649,
21,
19,
90,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
11,
220,
22,
11,
220,
23,
11,
220,
24,
11,
220,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestCreate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/v2.0/fw/firewalls", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
{
"firewall":{
"name": "fw",
"description": "OpenStack firewall",
"admin_state_up": true,
"firewall_policy_id": "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c",
"tenant_id": "b4eedccc6fb74fa8a7ad6b08382b852b"
}
}
`)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
fmt.Fprintf(w, `
{
"firewall":{
"status": "PENDING_CREATE",
"name": "fw",
"description": "OpenStack firewall",
"admin_state_up": true,
"tenant_id": "b4eedccc6fb74fa8a7ad6b08382b852b",
"firewall_policy_id": "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c"
}
}
`)
})
options := firewalls.CreateOpts{
TenantID: "b4eedccc6fb74fa8a7ad6b08382b852b",
Name: "fw",
Description: "OpenStack firewall",
AdminStateUp: gophercloud.Enabled,
PolicyID: "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c",
}
_, err := firewalls.Create(fake.ServiceClient(), options).Extract()
th.AssertNoErr(t, err)
} | explode_data.jsonl/36153 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 701
} | [
2830,
3393,
4021,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
70479,
1321,
2200,
63623,
4283,
85,
17,
13,
15,
60193,
53010,
86296,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFormatWithdrawPermissions(t *testing.T) {
h.SetDefaults()
expectedResult := exchange.AutoWithdrawCryptoWithSetupText + " & " + exchange.NoFiatWithdrawalsText
withdrawPermissions := h.FormatWithdrawPermissions()
if withdrawPermissions != expectedResult {
t.Errorf("Expected: %s, Received: %s", expectedResult, withdrawPermissions)
}
} | explode_data.jsonl/24344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
4061,
92261,
23851,
1155,
353,
8840,
836,
8,
341,
9598,
4202,
16273,
741,
42400,
2077,
1669,
9289,
6477,
92261,
58288,
2354,
21821,
1178,
488,
330,
609,
330,
488,
9289,
16766,
37,
10358,
92261,
1127,
1178,
271,
46948,
7633,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestQuickQueuePoll(t *testing.T) {
q := NewQuickQueue()
q.Add(5)
q.Add("hello")
val1, ok := q.Poll().(int)
assert.True(t, ok)
assert.Equal(t, 5, val1)
val2, ok := q.Poll().(string)
assert.True(t, ok)
assert.Equal(t, "hello", val2)
val3 := q.Poll()
assert.Nil(t, val3)
} | explode_data.jsonl/42915 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
24318,
7554,
49207,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
1532,
24318,
7554,
2822,
18534,
1904,
7,
20,
340,
18534,
1904,
445,
14990,
1138,
19302,
16,
11,
5394,
1669,
2804,
1069,
965,
1005,
7,
396,
340,
6948,
32443,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseErrPosix(t *testing.T) {
t.Parallel()
p := NewParser(KeepComments(true), Variant(LangPOSIX))
i := 0
for _, c := range shellTests {
want := c.common
if c.posix != nil {
want = c.posix
}
if want == nil {
continue
}
t.Run(fmt.Sprintf("%03d", i), checkError(p, c.in, want.(string)))
i++
}
} | explode_data.jsonl/55122 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
14463,
7747,
4859,
941,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3223,
1669,
1532,
6570,
7,
19434,
17373,
3715,
701,
39292,
4957,
524,
17456,
5396,
1171,
8230,
1669,
220,
15,
198,
2023,
8358,
272,
1669,
2088,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestReconcileInfrastructureCluster(t *testing.T) {
g := NewWithT(t)
clusterInfrastructure1 := builder.InfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster1").
WithSpecFields(map[string]interface{}{"spec.template.spec.fakeSetting": true}).
Build()
clusterInfrastructure2 := builder.InfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster2").
WithSpecFields(map[string]interface{}{"spec.template.spec.fakeSetting": true}).
Build()
clusterInfrastructure3 := builder.InfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster3").
WithSpecFields(map[string]interface{}{"spec.template.spec.fakeSetting": true}).
Build()
clusterInfrastructure3WithInstanceSpecificChanges := clusterInfrastructure3.DeepCopy()
clusterInfrastructure3WithInstanceSpecificChanges.SetLabels(map[string]string{"foo": "bar"})
clusterInfrastructure4 := builder.InfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster4").
WithSpecFields(map[string]interface{}{"spec.template.spec.fakeSetting": true}).
Build()
clusterInfrastructure4WithTemplateOverridingChanges := clusterInfrastructure4.DeepCopy()
err := unstructured.SetNestedField(clusterInfrastructure4WithTemplateOverridingChanges.UnstructuredContent(), false, "spec", "fakeSetting")
g.Expect(err).ToNot(HaveOccurred())
clusterInfrastructure5 := builder.InfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster5").
WithSpecFields(map[string]interface{}{"spec.template.spec.fakeSetting": true}).
Build()
tests := []struct {
name string
current *unstructured.Unstructured
desired *unstructured.Unstructured
want *unstructured.Unstructured
wantErr bool
}{
{
name: "Should create desired InfrastructureCluster if the current does not exists yet",
current: nil,
desired: clusterInfrastructure1,
want: clusterInfrastructure1,
wantErr: false,
},
{
name: "No-op if current InfrastructureCluster is equal to desired",
current: clusterInfrastructure2,
desired: clusterInfrastructure2,
want: clusterInfrastructure2,
wantErr: false,
},
{
name: "Should preserve instance specific changes",
current: clusterInfrastructure3WithInstanceSpecificChanges,
desired: clusterInfrastructure3,
want: clusterInfrastructure3WithInstanceSpecificChanges,
wantErr: false,
},
{
name: "Should restore template values if overridden",
current: clusterInfrastructure4WithTemplateOverridingChanges,
desired: clusterInfrastructure4,
want: clusterInfrastructure4,
wantErr: false,
},
{
name: "Fails for incompatible changes",
current: clusterInfrastructure5,
desired: clusterInfrastructure1,
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
fakeObjs := make([]client.Object, 0)
if tt.current != nil {
fakeObjs = append(fakeObjs, tt.current)
}
fakeClient := fake.NewClientBuilder().
WithScheme(fakeScheme).
WithObjects(fakeObjs...).
Build()
s := scope.New(&clusterv1.Cluster{})
s.Current.InfrastructureCluster = tt.current
s.Desired = &scope.ClusterState{InfrastructureCluster: tt.desired}
r := Reconciler{
Client: fakeClient,
recorder: env.GetEventRecorderFor("test"),
}
err := r.reconcileInfrastructureCluster(ctx, s)
if tt.wantErr {
g.Expect(err).To(HaveOccurred())
return
}
g.Expect(err).ToNot(HaveOccurred())
got := tt.want.DeepCopy() // this is required otherwise Get will modify tt.want
err = fakeClient.Get(ctx, client.ObjectKeyFromObject(tt.want), got)
g.Expect(err).ToNot(HaveOccurred())
// Spec
wantSpec, ok, err := unstructured.NestedMap(tt.want.UnstructuredContent(), "spec")
g.Expect(err).NotTo(HaveOccurred())
g.Expect(ok).To(BeTrue())
gotSpec, ok, err := unstructured.NestedMap(got.UnstructuredContent(), "spec")
g.Expect(err).NotTo(HaveOccurred())
g.Expect(ok).To(BeTrue())
for k, v := range wantSpec {
g.Expect(gotSpec).To(HaveKeyWithValue(k, v))
}
})
}
} | explode_data.jsonl/11658 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1497
} | [
2830,
3393,
693,
40446,
457,
97838,
28678,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
2354,
51,
1155,
692,
197,
18855,
97838,
16,
1669,
7363,
40435,
28678,
1255,
295,
402,
16,
46011,
3675,
11,
330,
13573,
10314,
93208,
16,
38609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestTryDequeueAndAbortCommitQueueVersion(t *testing.T) {
assert.NoError(t, db.ClearCollections(patch.Collection, VersionCollection, task.Collection, build.Collection, commitqueue.Collection))
v := &Version{
Id: "my-version",
Status: evergreen.VersionStarted,
}
p := &patch.Patch{
Version: v.Id,
GithubPatchData: patch.GithubPatch{
PRNumber: 12,
MergeCommitSHA: "abcdef",
},
Alias: evergreen.CommitQueueAlias,
Status: evergreen.PatchStarted,
}
b := build.Build{
Id: "my-build",
Version: v.Id,
}
t1 := &task.Task{
Id: "t1",
Activated: true,
Status: evergreen.TaskFailed,
Version: v.Id,
BuildId: b.Id,
}
t2 := &task.Task{
Id: "t2",
Activated: true,
Status: evergreen.TaskUndispatched,
Version: v.Id,
BuildId: b.Id,
}
t3 := &task.Task{
Id: "t3",
Activated: true,
Status: evergreen.TaskStarted,
Version: v.Id,
BuildId: b.Id,
}
t4 := task.Task{
Id: "t4",
Activated: true,
Status: evergreen.TaskDispatched,
Version: v.Id,
BuildId: b.Id,
}
q := []commitqueue.CommitQueueItem{
commitqueue.CommitQueueItem{Issue: "12"},
commitqueue.CommitQueueItem{Issue: "42"},
}
cq := &commitqueue.CommitQueue{ProjectID: "my-project", Processing: true, Queue: q}
assert.NoError(t, v.Insert())
assert.NoError(t, p.Insert())
assert.NoError(t, b.Insert())
assert.NoError(t, t1.Insert())
assert.NoError(t, t2.Insert())
assert.NoError(t, t3.Insert())
assert.NoError(t, t4.Insert())
assert.NoError(t, commitqueue.InsertQueue(cq))
pRef := &ProjectRef{Identifier: cq.ProjectID}
assert.NoError(t, TryDequeueAndAbortCommitQueueVersion(pRef, v.Id, evergreen.User))
cq, err := commitqueue.FindOneId("my-project")
assert.NoError(t, err)
assert.Equal(t, cq.FindItem("12"), -1)
assert.Len(t, cq.Queue, 1)
assert.False(t, cq.Processing)
// check that all tasks are now in the correct state
tasks, err := task.FindAll(db.Q{})
assert.NoError(t, err)
aborted := 0
finished := 0
for _, thisTask := range tasks {
if thisTask.Aborted {
aborted++
}
if thisTask.Status == evergreen.TaskFailed {
finished++
}
if thisTask.Status == evergreen.TaskUndispatched {
assert.False(t, thisTask.Activated)
}
}
assert.Equal(t, 2, aborted)
assert.Equal(t, 1, finished)
p, err = patch.FindOne(patch.ByVersion("my-version"))
assert.NoError(t, err)
assert.NotNil(t, p)
} | explode_data.jsonl/60434 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1063
} | [
2830,
3393,
21453,
1912,
4584,
3036,
85891,
33441,
7554,
5637,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
2927,
13524,
52730,
91940,
28629,
11,
6079,
6482,
11,
3383,
28629,
11,
1936,
28629,
11,
5266,
4584,
28629,
4390,
5195,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestBasicPutValid(t *testing.T) {
client := newBasicClient()
result, err := client.PutValid(context.Background(), Basic{
ID: to.Int32Ptr(2),
Name: to.StringPtr("abc"),
Color: CMYKColorsMagenta.ToPtr(),
}, nil)
if err != nil {
t.Fatalf("PutValid: %v", err)
}
if s := result.RawResponse.StatusCode; s != http.StatusOK {
t.Fatalf("unexpected status code %d", s)
}
} | explode_data.jsonl/15338 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
15944,
19103,
4088,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
15944,
2959,
741,
9559,
11,
1848,
1669,
2943,
39825,
4088,
5378,
19047,
1507,
14625,
515,
197,
29580,
25,
262,
311,
7371,
18,
17,
5348,
7,
17,
1326,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAssessMetricStatusNoMeasurements(t *testing.T) {
// no measurements yet taken
metric := v1alpha1.Metric{
Name: "success-rate",
}
result := v1alpha1.MetricResult{
Measurements: nil,
}
assert.Equal(t, v1alpha1.AnalysisPhasePending, assessMetricStatus(metric, result, false))
assert.Equal(t, v1alpha1.AnalysisPhaseSuccessful, assessMetricStatus(metric, result, true))
} | explode_data.jsonl/75816 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
5615,
433,
54310,
2522,
2753,
32236,
1368,
1155,
353,
8840,
836,
8,
341,
197,
322,
902,
21595,
3602,
4429,
198,
2109,
16340,
1669,
348,
16,
7141,
16,
1321,
16340,
515,
197,
21297,
25,
330,
5630,
43026,
756,
197,
532,
9559,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNamespaceUpdate(t *testing.T) {
c, _ := newTestClient(t)
namespaceAddAndUpdateTest(t, c, func(obj interface{}) {
// first argument (old namespace) is not used right now
c.handleNamespaceUpdate(&api_v1.Namespace{}, obj)
})
} | explode_data.jsonl/56846 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
22699,
4289,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
501,
2271,
2959,
1155,
340,
56623,
2212,
56365,
2271,
1155,
11,
272,
11,
2915,
6779,
3749,
28875,
341,
197,
197,
322,
1156,
5693,
320,
813,
4473,
8,
374,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestBlkioStatsNoFilesBFQDebug(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
testCases := []blkioStatFailureTestCase{
{
desc: "missing blkio.bfq.io_service_bytes_recursive file",
filename: "blkio.bfq.io_service_bytes_recursive",
},
{
desc: "missing blkio.bfq.io_serviced_recursive file",
filename: "blkio.bfq.io_serviced_recursive",
},
{
desc: "missing blkio.bfq.io_queued_recursive file",
filename: "blkio.bfq.io_queued_recursive",
},
{
desc: "missing blkio.bfq.sectors_recursive file",
filename: "blkio.bfq.sectors_recursive",
},
{
desc: "missing blkio.bfq.io_service_time_recursive file",
filename: "blkio.bfq.io_service_time_recursive",
},
{
desc: "missing blkio.bfq.io_wait_time_recursive file",
filename: "blkio.bfq.io_wait_time_recursive",
},
{
desc: "missing blkio.bfq.io_merged_recursive file",
filename: "blkio.bfq.io_merged_recursive",
},
{
desc: "missing blkio.bfq.time_recursive file",
filename: "blkio.bfq.time_recursive",
},
}
for _, testCase := range testCases {
helper := NewCgroupTestUtil("cpuset", t)
defer helper.cleanup()
tempBlkioTestFiles := map[string]string{}
for i, v := range blkioBFQDebugStatsTestFiles {
tempBlkioTestFiles[i] = v
}
delete(tempBlkioTestFiles, testCase.filename)
helper.writeFileContents(tempBlkioTestFiles)
cpuset := &CpusetGroup{}
actualStats := *cgroups.NewStats()
err := cpuset.GetStats(helper.CgroupPath, &actualStats)
if err != nil {
t.Errorf(fmt.Sprintf("test case '%s' failed unexpectedly: %s", testCase.desc, err))
}
}
} | explode_data.jsonl/45839 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 755
} | [
2830,
3393,
4923,
74,
815,
16635,
2753,
10809,
19883,
88191,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
304,
2805,
3856,
13053,
197,
532,
18185,
37302,
1669,
3056,
34989,
815,
1587... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestInsertAbsent(t *testing.T) {
m := NewSharedMap()
elephant := Animal{"elephant"}
monkey := Animal{"monkey"}
m.LoadOrStore("elephant", elephant)
if ok := m.LoadOrStore("elephant", monkey); ok {
t.Error("map set a new value even the entry is already present")
}
} | explode_data.jsonl/77831 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
13780,
80251,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
16997,
2227,
741,
7727,
273,
26924,
1669,
21292,
4913,
10068,
26924,
16707,
197,
96016,
1669,
21292,
4913,
96016,
63159,
2109,
13969,
2195,
6093,
445,
10068,
26924,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestYouonInvalid(t *testing.T) {
const want = "yōon cannot be the first character in a kana block"
input := []string{
"ゃき", "ゅき", "ょき", "ぁき", "ぃき", "ぅき", "ぇき", "ぉき", "ゎき",
"ャキ", "ュキ", "ョキ", "ァキ", "ィキ", "ゥキ", "ェキ", "ォキ", "ヮキ",
}
for _, v := range input {
got, err := KanaToRomaji(v)
assert.Empty(t, got)
assert.EqualError(t, err, want)
}
} | explode_data.jsonl/11310 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
2610,
263,
7928,
1155,
353,
8840,
836,
8,
341,
4777,
1366,
284,
330,
88,
55661,
263,
4157,
387,
279,
1156,
3668,
304,
264,
595,
3362,
2504,
1837,
22427,
1669,
3056,
917,
515,
197,
197,
1,
124234,
49734,
497,
330,
138218,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGitGetter_tag(t *testing.T) {
if !testHasGit {
t.Log("git not found, skipping")
t.Skip()
}
g := new(GitGetter)
dst := tempDir(t)
repo := testGitRepo(t, "tag")
repo.commitFile("tag.txt", "tag")
repo.git("tag", "v1.0")
q := repo.url.Query()
q.Add("ref", "v1.0")
repo.url.RawQuery = q.Encode()
if err := g.Get(dst, repo.url); err != nil {
t.Fatalf("err: %s", err)
}
// Verify the main file exists
mainPath := filepath.Join(dst, "tag.txt")
if _, err := os.Stat(mainPath); err != nil {
t.Fatalf("err: %s", err)
}
// Get again should work
if err := g.Get(dst, repo.url); err != nil {
t.Fatalf("err: %s", err)
}
// Verify the main file exists
mainPath = filepath.Join(dst, "tag.txt")
if _, err := os.Stat(mainPath); err != nil {
t.Fatalf("err: %s", err)
}
} | explode_data.jsonl/39696 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 363
} | [
2830,
3393,
46562,
31485,
9372,
1155,
353,
8840,
836,
8,
341,
743,
753,
1944,
10281,
46562,
341,
197,
3244,
5247,
445,
12882,
537,
1730,
11,
42659,
1138,
197,
3244,
57776,
741,
197,
630,
3174,
1669,
501,
6699,
275,
31485,
340,
52051,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.