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 TestGoldenFiles(t *testing.T) {
// Add testing users and groups to test with resolve_ids enabled.
aucoalesce.HardcodeUsers(knownUsers...)
aucoalesce.HardcodeGroups(knownGroups...)
sourceFiles, err := filepath.Glob(filepath.Join(testDir, testPattern))
if err != nil {
t.Fatal(err)
}
for _, file := range sourceFiles {
testName := strings.TrimSuffix(filepath.Base(file), testExt)
t.Run(testName, func(t *testing.T) {
lines, err := readLines(file)
if err != nil {
t.Fatalf("error reading log file '%s': %v", file, err)
}
mock := NewMock().
// Get Status response for initClient
returnACK().returnStatus().
// Send expected ACKs for initialization
returnACK().returnACK().returnACK().returnACK().returnACK().
// Send audit messages
returnMessage(lines...).
// Send stream terminator
returnMessage(terminator)
ms := mbtest.NewPushMetricSetV2(t, configForGolden())
auditMetricSet := ms.(*MetricSet)
auditMetricSet.client.Close()
auditMetricSet.client = &libaudit.AuditClient{Netlink: mock}
mbEvents := runTerminableReporter(fileTimeout, ms, isTestEvent)
t.Logf("Received %d events for %d audit records", len(mbEvents), len(lines))
assertNoErrors(t, mbEvents)
events := normalize(t, mbEvents)
goldenPath := file + goldenSuffix
if *update {
data, err := json.MarshalIndent(events, "", " ")
if err != nil {
t.Fatal(err)
}
if err = ioutil.WriteFile(goldenPath, data, 0644); err != nil {
t.Fatalf("failed writing golden file '%s': %v", goldenPath, err)
}
}
golden := readGoldenFile(t, goldenPath)
assert.EqualValues(t, golden, events)
})
}
} | explode_data.jsonl/63812 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 661
} | [
2830,
3393,
59790,
10809,
1155,
353,
8840,
836,
8,
341,
197,
322,
2691,
7497,
3847,
323,
5203,
311,
1273,
448,
8830,
8077,
8970,
624,
197,
2863,
1015,
73250,
3839,
567,
1851,
7137,
7,
5278,
7137,
31218,
197,
2863,
1015,
73250,
3839,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInferredMatcher(t *testing.T) {
// If we are not on CI skip the test.
if os.Getenv("CI") == "" {
t.Skip("Not on CI, skipping comby-dependent test")
}
input := map[string]string{
"main.go": `
/* This foo(ignore string) {} is in a Go comment should not match */
func foo(real string) {}
`,
}
pattern := "foo(:[args])"
want := "foo(real string)"
zipData, err := testutil.CreateZip(input)
if err != nil {
t.Fatal(err)
}
zPath, cleanup, err := testutil.TempZipFileOnDisk(zipData)
if err != nil {
t.Fatal(err)
}
defer cleanup()
zFile, _ := testutil.MockZipFile(zipData)
if err != nil {
t.Fatal(err)
}
p := &protocol.PatternInfo{
Pattern: pattern,
Limit: 30,
}
ctx, cancel, sender := newLimitedStreamCollector(context.Background(), 1000000000)
defer cancel()
err = filteredStructuralSearch(ctx, zPath, zFile, p, "foo", sender)
if err != nil {
t.Fatal(err)
}
got := sender.collected[0].LineMatches[0].Preview
if err != nil {
t.Fatal(err)
}
if got != want {
t.Fatalf("got file matches %v, want %v", got, want)
}
} | explode_data.jsonl/5443 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 425
} | [
2830,
3393,
641,
5554,
37554,
1155,
353,
8840,
836,
8,
341,
197,
322,
1416,
582,
525,
537,
389,
20694,
10706,
279,
1273,
624,
743,
2643,
64883,
445,
11237,
899,
621,
1591,
341,
197,
3244,
57776,
445,
2623,
389,
20694,
11,
42659,
469,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestHybrid(t *testing.T) {
n := bigint.MustBinary("11111111_11111111_000_111_000000_1_0_111111_0_11_0")
f := Hybrid{T: 8, K: 4}
got := f.Decompose(n)
expect := Sum{
{D: big.NewInt(0x3), E: 1},
{D: big.NewInt(0x3f), E: 4},
{D: big.NewInt(0x1), E: 11},
{D: big.NewInt(0x7), E: 18},
{D: big.NewInt(0xff), E: 24},
{D: big.NewInt(0xff), E: 32},
}
if !SumEquals(got, expect) {
t.Fatalf("got %v expect %v", got, expect)
}
} | explode_data.jsonl/75061 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
30816,
16223,
1155,
353,
8840,
836,
8,
341,
9038,
1669,
79663,
50463,
21338,
445,
16,
16,
16,
16,
16,
16,
16,
16,
62,
16,
16,
16,
16,
16,
16,
16,
16,
62,
15,
15,
15,
62,
16,
16,
16,
62,
15,
15,
15,
15,
15,
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... | 2 |
func Test_buildTcpMD5Sigv6(t *testing.T) {
s, _ := buildTcpMD5Sig("fe80::4850:31ff:fe01:fc55", "helloworld")
buf1 := make([]uint8, 216)
p := unsafe.Pointer(&s)
for i := uintptr(0); i < 216; i++ {
buf1[i] = *(*byte)(unsafe.Pointer(uintptr(p) + i))
}
buf2 := []uint8{10, 0, 0, 0, 0, 0, 0, 0, 254, 128, 0, 0, 0, 0, 0, 0, 72, 80, 49, 255, 254, 1, 252, 85, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 104, 101, 108, 108, 111, 119, 111, 114, 108, 100, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
buf2[0] = syscall.AF_INET6
if bytes.Compare(buf1, buf2) == 0 {
t.Log("OK")
} else {
t.Error("Something wrong v6")
}
} | explode_data.jsonl/18689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 630
} | [
2830,
3393,
20801,
77536,
6076,
20,
47246,
85,
21,
1155,
353,
8840,
836,
8,
341,
1903,
11,
716,
1669,
1936,
77536,
6076,
20,
47246,
445,
1859,
23,
15,
486,
19,
23,
20,
15,
25,
18,
16,
542,
25,
1859,
15,
16,
25,
8316,
20,
20,
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... | 3 |
func TestInitializeLogging(t *testing.T) {
origEnvValue := os.Getenv("FABRIC_LOGGING_SPEC")
os.Setenv("FABRIC_LOGGING_SPEC", "foo=debug")
initializeLogging()
assert.Equal(t, "debug", flogging.LoggerLevel("foo"))
os.Setenv("FABRIC_LOGGING_SPEC", origEnvValue)
} | explode_data.jsonl/32647 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
9928,
34575,
1155,
353,
8840,
836,
8,
341,
197,
4670,
14359,
1130,
1669,
2643,
64883,
445,
37,
1867,
35978,
8419,
49437,
36436,
1138,
25078,
4202,
3160,
445,
37,
1867,
35978,
8419,
49437,
36436,
497,
330,
7975,
28,
8349,
113... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEth_EstimateGas_ContractDeployment(t *testing.T) {
bytecode := "0x608060405234801561001057600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a260d08061004d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063eb8ac92114602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506062565b005b8160008190555080827ff3ca124a697ba07e8c5e80bebcfcc48991fc16a63170e8a9206e30508960d00360405160405180910390a3505056fea265627a7a723158201d94d2187aaf3a6790527b615fcc40970febf0385fa6d72a2344848ebd0df3e964736f6c63430005110032"
param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["data"] = bytecode
rpcRes := call(t, "eth_estimateGas", param)
require.NotNil(t, rpcRes)
require.NotEmpty(t, rpcRes.Result)
var gas hexutil.Uint64
err := json.Unmarshal(rpcRes.Result, &gas)
require.NoError(t, err, string(rpcRes.Result))
require.Equal(t, "0x1c2c4", gas.String())
} | explode_data.jsonl/865 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 511
} | [
2830,
3393,
65390,
2089,
267,
3426,
58728,
15100,
2144,
75286,
1155,
353,
8840,
836,
8,
341,
31422,
1851,
1669,
330,
15,
87,
21,
15,
23,
15,
21,
15,
19,
15,
20,
17,
18,
19,
23,
15,
16,
20,
21,
16,
15,
15,
16,
15,
20,
22,
21,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRandomString(t *testing.T) {
for _, test := range []struct {
in []string
should string
}{
{[]string{}, ""},
{nil, ""},
{[]string{"a"}, "a"},
{[]string{"a", "b", "c", "d", "e", "f"}, "f"},
} {
Seed(44)
got := RandomString(test.in)
if got == test.should {
continue
}
t.Errorf("for '%v' should '%s' got '%s'",
test.in, test.should, got)
}
} | explode_data.jsonl/82369 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
13999,
703,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
17430,
257,
3056,
917,
198,
197,
197,
5445,
914,
198,
197,
59403,
197,
197,
90,
1294,
917,
22655,
77496,
197,
197,
90,
8385,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDashboardGetAll(t *testing.T) {
ctx, finish := WithRecorder(WithTestAuth(context.Background()), t)
defer finish()
assert := tests.Assert(ctx, t)
getAllResponse, httpresp, err := Client(ctx).DashboardsApi.ListDashboards(ctx).Execute()
if err != nil {
t.Fatalf("Error getting all dashboards: Response %s: %v", err.(datadog.GenericOpenAPIError).Body(), err)
}
assert.Equal(200, httpresp.StatusCode)
assert.True(len(getAllResponse.GetDashboards()) >= 1)
} | explode_data.jsonl/18057 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
26947,
1949,
2403,
1155,
353,
8840,
836,
8,
341,
20985,
11,
6248,
1669,
3085,
47023,
7,
2354,
2271,
5087,
5378,
19047,
11858,
259,
340,
16867,
6248,
741,
6948,
1669,
7032,
11711,
7502,
11,
259,
692,
10366,
2403,
2582,
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... | 2 |
func TestUnaryRpc(t *testing.T) {
resp, err := stub.InvokeRpc(context.Background(), "", unaryMd, &grpc_testing.SimpleRequest{Payload: payload})
testutil.Ok(t, err, "Failed to invoke unary RPC")
dm := resp.(*dynamic.Message)
fd := dm.GetMessageDescriptor().FindFieldByName("payload")
p := dm.GetField(fd)
testutil.Require(t, dynamic.MessagesEqual(p.(proto.Message), payload), "Incorrect payload returned from RPC: %v != %v", p, payload)
} | explode_data.jsonl/51786 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
94545,
60248,
1155,
353,
8840,
836,
8,
341,
34653,
11,
1848,
1669,
13633,
32784,
60248,
5378,
19047,
1507,
7342,
75678,
72529,
11,
609,
56585,
70962,
24252,
1900,
90,
29683,
25,
7729,
3518,
18185,
1314,
54282,
1155,
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... | 1 |
func TestLoadFile(t *testing.T) {
goodConfig := "testdata/config.json"
badConfig := "testdata/bad_config.json"
expected := New()
expected.Server = &Server{
Addr: "localhost:8080",
KeyPaths: "testdata/server.key",
CertPaths: "testdata/server.pem",
}
_, err := Load("testdata/enoent.json")
if err == nil {
t.Fatal("attempt to load non-existent file should fail")
}
_, err = Load(badConfig)
if err == nil {
t.Fatal("attempt to load malformed JSON should fail")
}
cfg, err := Load(goodConfig)
if err != nil {
t.Fatalf("failed to load config: %s", err)
}
if !cfg.equal(expected) {
t.Fatal("loaded config is invalid")
}
} | explode_data.jsonl/57695 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
5879,
1703,
1155,
353,
8840,
836,
8,
341,
3174,
1386,
2648,
1669,
330,
92425,
14730,
4323,
698,
2233,
329,
2648,
1669,
330,
92425,
3470,
329,
5332,
4323,
698,
42400,
1669,
1532,
741,
42400,
22997,
284,
609,
5475,
515,
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... | 5 |
func TestGrpc_WalletRecoverScript(t *testing.T) {
_, err := g.GetWalletRecoverAddress(getOkCtx(), nil)
assert.Equal(t, types.ErrInvalidParam, err)
_, err = g.SignWalletRecoverTx(getOkCtx(), nil)
assert.Equal(t, types.ErrInvalidParam, err)
} | explode_data.jsonl/344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
6464,
3992,
2763,
7464,
693,
3688,
5910,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
342,
2234,
38259,
693,
3688,
4286,
5433,
11578,
23684,
1507,
2092,
340,
6948,
12808,
1155,
11,
4494,
27862,
7928,
2001,
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... | 1 |
func TestReadCoupon(t *testing.T) {
//api := client.Coupon
//
//authStatus, err := client.AuthStatus.Read()
//assert.NoError(t, err)
//assert.NotEmpty(t, authStatus)
//
//res, err := api.Find()
//assert.NotNil(t, res)
//assert.NoError(t, err)
//t.Logf("Coupon: %#v", res)
} | explode_data.jsonl/65038 | {
"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,
4418,
88052,
1155,
353,
8840,
836,
8,
341,
197,
322,
2068,
1669,
2943,
727,
32987,
198,
197,
2289,
197,
322,
3242,
2522,
11,
1848,
1669,
2943,
25233,
2522,
6503,
741,
197,
322,
2207,
35699,
1155,
11,
1848,
340,
197,
322,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRotate(t *testing.T) {
src := NewMatWithSize(1, 2, MatTypeCV64F)
defer src.Close()
dst := NewMat()
defer dst.Close()
Rotate(src, &dst, Rotate90Clockwise)
if dst.Rows() != 2 {
t.Errorf("expected rows: %d got %d", src.Cols(), dst.Rows())
}
dst2src := NewMat()
defer dst2src.Close()
Rotate(dst, &dst2src, Rotate90CounterClockwise)
if dst2src.Rows() != 1 {
t.Errorf("expected rows: %d got %d", src.Rows(), dst2src.Rows())
}
} | explode_data.jsonl/81746 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
34540,
1155,
353,
8840,
836,
8,
341,
41144,
1669,
1532,
11575,
2354,
1695,
7,
16,
11,
220,
17,
11,
6867,
929,
19589,
21,
19,
37,
340,
16867,
2286,
10421,
741,
52051,
1669,
1532,
11575,
741,
16867,
10648,
10421,
2822,
11143... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTCPSegmentsSentIncrement(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
stats := c.Stack().Stats()
// SYN and ACK
want := stats.TCP.SegmentsSent.Value() + 2
c.CreateConnected(789, 30000, nil)
if got := stats.TCP.SegmentsSent.Value(); got != want {
t.Errorf("got stats.TCP.SegmentsSent.Value() = %v, want = %v", got, want)
}
} | explode_data.jsonl/22275 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
7749,
5012,
791,
1368,
31358,
38311,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
79659,
1669,
272,
58646,
1005,
16635,
741,
197,
322,
61694,
323,
53763,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTfgridReservationContainer1_ToProvisionType(t *testing.T) {
type fields struct {
WorkloadID int64
NodeID string
Flist string
HubURL string
Environment map[string]string
Entrypoint string
Interactive bool
Volumes []workloads.ContainerMount
NetworkConnection []workloads.NetworkConnection
StatsAggregator []workloads.StatsAggregator
Capacity workloads.ContainerCapacity
}
tests := []struct {
name string
fields fields
want Container
wantErr bool
}{
{
name: "empty network and volume",
fields: fields{
WorkloadID: 1,
NodeID: "node1",
Flist: "https://hub.grid.tf/tf-official-apps/ubuntu-bionic-build.flist",
HubURL: "zdb://hub.grid.tf:9900",
Environment: map[string]string{"FOO": "BAR"},
Entrypoint: "/sbin/my_init",
Interactive: false,
Volumes: nil,
NetworkConnection: nil,
StatsAggregator: nil,
Capacity: workloads.ContainerCapacity{
Cpu: 2,
Memory: 1024,
DiskSize: 1024,
DiskType: workloads.DiskTypeSSD,
},
},
want: Container{
FList: "https://hub.grid.tf/tf-official-apps/ubuntu-bionic-build.flist",
FlistStorage: "zdb://hub.grid.tf:9900",
Env: map[string]string{"FOO": "BAR"},
SecretEnv: nil,
Entrypoint: "/sbin/my_init",
Interactive: false,
Mounts: []Mount{},
Network: Network{},
Logs: []logger.Logs{},
StatsAggregator: []stats.Aggregator{},
Capacity: ContainerCapacity{
CPU: 2,
Memory: 1024,
DiskSize: 1024,
DiskType: pkg.SSDDevice,
},
},
wantErr: false,
},
{
name: "with network and volumes",
fields: fields{
WorkloadID: 1,
NodeID: "node1",
Flist: "https://hub.grid.tf/tf-official-apps/ubuntu-bionic-build.flist",
HubURL: "zdb://hub.grid.tf:9900",
Environment: map[string]string{"FOO": "BAR"},
Entrypoint: "/sbin/my_init",
Interactive: false,
Volumes: []workloads.ContainerMount{
{
VolumeId: "-volume1",
Mountpoint: "/mnt",
},
{
VolumeId: "volume2",
Mountpoint: "/data",
},
},
NetworkConnection: []workloads.NetworkConnection{
{
NetworkId: "net1",
Ipaddress: net.ParseIP("10.0.0.1"),
},
},
Capacity: workloads.ContainerCapacity{
Cpu: 2,
Memory: 1024,
DiskSize: 1024,
DiskType: workloads.DiskTypeSSD,
},
},
want: Container{
FList: "https://hub.grid.tf/tf-official-apps/ubuntu-bionic-build.flist",
FlistStorage: "zdb://hub.grid.tf:9900",
Env: map[string]string{"FOO": "BAR"},
SecretEnv: nil,
Entrypoint: "/sbin/my_init",
Interactive: false,
Mounts: []Mount{
{
VolumeID: "reservation-volume1",
Mountpoint: "/mnt",
},
{
VolumeID: "volume2",
Mountpoint: "/data",
},
},
Network: Network{
NetworkID: "net1",
IPs: []net.IP{net.ParseIP("10.0.0.1")},
},
Logs: []logger.Logs{},
StatsAggregator: []stats.Aggregator{},
Capacity: ContainerCapacity{
CPU: 2,
Memory: 1024,
DiskSize: 1024,
DiskType: pkg.SSDDevice,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := workloads.Container{
ReservationInfo: workloads.ReservationInfo{
WorkloadId: tt.fields.WorkloadID,
NodeId: tt.fields.NodeID,
},
Flist: tt.fields.Flist,
HubUrl: tt.fields.HubURL,
Environment: tt.fields.Environment,
Entrypoint: tt.fields.Entrypoint,
Interactive: tt.fields.Interactive,
Volumes: tt.fields.Volumes,
NetworkConnection: tt.fields.NetworkConnection,
StatsAggregator: tt.fields.StatsAggregator,
Capacity: tt.fields.Capacity,
}
got, _, err := ContainerToProvisionType(&c, "reservation")
if !tt.wantErr {
require.NoError(t, err)
assert.DeepEqual(t, tt.want, got)
} else {
require.Error(t, err)
}
})
}
} | explode_data.jsonl/67194 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2216
} | [
2830,
3393,
51,
69,
4203,
54948,
4502,
16,
38346,
1336,
13013,
929,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
6776,
1078,
915,
286,
526,
21,
19,
198,
197,
30217,
915,
310,
914,
198,
197,
12727,
1607,
1797,
914,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseConfigGood(t *testing.T) {
c, err := parseFile("../../../../test/fixture/config/agent_good.conf")
require.NoError(t, err)
assert.Equal(t, c.Agent.DataDir, ".")
assert.Equal(t, c.Agent.LogLevel, "INFO")
assert.Equal(t, c.Agent.ServerAddress, "127.0.0.1")
assert.Equal(t, c.Agent.ServerPort, 8081)
assert.Equal(t, c.Agent.SocketPath, "/tmp/agent.sock")
assert.Equal(t, c.Agent.TrustBundlePath, "conf/agent/dummy_root_ca.crt")
assert.Equal(t, c.Agent.TrustDomain, "example.org")
// Check for plugins configurations
pluginConfigs := *c.Plugins
expectedData := "join_token = \"PLUGIN-AGENT-NOT-A-SECRET\""
var data bytes.Buffer
err = printer.DefaultConfig.Fprint(&data, pluginConfigs["plugin_type_agent"]["plugin_name_agent"].PluginData)
assert.NoError(t, err)
assert.Len(t, pluginConfigs, 1)
assert.Len(t, pluginConfigs["plugin_type_agent"], 3)
pluginConfig := pluginConfigs["plugin_type_agent"]["plugin_name_agent"]
assert.Nil(t, pluginConfig.Enabled)
assert.Equal(t, pluginConfig.IsEnabled(), true)
assert.Equal(t, pluginConfig.PluginChecksum, "pluginAgentChecksum")
assert.Equal(t, pluginConfig.PluginCmd, "./pluginAgentCmd")
assert.Equal(t, expectedData, data.String())
// Disabled plugin
pluginConfig = pluginConfigs["plugin_type_agent"]["plugin_disabled"]
assert.NotNil(t, pluginConfig.Enabled)
assert.Equal(t, pluginConfig.IsEnabled(), false)
assert.Equal(t, pluginConfig.PluginChecksum, "pluginAgentChecksum")
assert.Equal(t, pluginConfig.PluginCmd, "./pluginAgentCmd")
assert.Equal(t, expectedData, data.String())
// Enabled plugin
pluginConfig = pluginConfigs["plugin_type_agent"]["plugin_enabled"]
assert.NotNil(t, pluginConfig.Enabled)
assert.Equal(t, pluginConfig.IsEnabled(), true)
assert.Equal(t, pluginConfig.PluginChecksum, "pluginAgentChecksum")
assert.Equal(t, pluginConfig.PluginCmd, "./pluginAgentCmd")
assert.Equal(t, expectedData, data.String())
} | explode_data.jsonl/69508 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 697
} | [
2830,
3393,
14463,
2648,
15216,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
4715,
1703,
36800,
2748,
1944,
14,
59612,
14730,
14,
8092,
44781,
13937,
1138,
17957,
35699,
1155,
11,
1848,
340,
6948,
12808,
1155,
11,
272,
88869,
333... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccountMetric(t *testing.T) {
knownPubID := "knownPublisher"
performTest := func(m *Metrics, pubID string) {
m.RecordRequest(pbsmetrics.Labels{
RType: pbsmetrics.ReqTypeORTB2Web,
RequestStatus: pbsmetrics.RequestStatusBlacklisted,
PubID: pubID,
})
}
testCases := []struct {
description string
testCase func(m *Metrics)
expectedCount float64
}{
{
description: "Known",
testCase: func(m *Metrics) {
performTest(m, knownPubID)
},
expectedCount: 1,
},
{
description: "Unknown",
testCase: func(m *Metrics) {
performTest(m, pbsmetrics.PublisherUnknown)
},
expectedCount: 0,
},
}
for _, test := range testCases {
m := createMetricsForTesting()
test.testCase(m)
assertCounterVecValue(t, test.description, "accountRequests", m.accountRequests,
test.expectedCount,
prometheus.Labels{
accountLabel: knownPubID,
})
}
} | explode_data.jsonl/13944 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 399
} | [
2830,
3393,
7365,
54310,
1155,
353,
8840,
836,
8,
341,
197,
5278,
29162,
915,
1669,
330,
5278,
34550,
698,
197,
28488,
2271,
1669,
2915,
1255,
353,
27328,
11,
6675,
915,
914,
8,
341,
197,
2109,
49959,
1900,
1295,
1279,
43262,
4679,
82... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProcessorError(t *testing.T) {
ctx := cdcContext.NewBackendContext4Test(true)
p, tester := initProcessor4Test(ctx, t)
var err error
// init tick
_, err = p.Tick(ctx, p.changefeed)
require.Nil(t, err)
tester.MustApplyPatches()
// send a abnormal error
p.sendError(cerror.ErrSinkURIInvalid)
_, err = p.Tick(ctx, p.changefeed)
tester.MustApplyPatches()
require.True(t, cerror.ErrReactorFinished.Equal(errors.Cause(err)))
require.Equal(t, p.changefeed.TaskPositions[p.captureInfo.ID], &model.TaskPosition{
Error: &model.RunningError{
Addr: "127.0.0.1:0000",
Code: "CDC:ErrSinkURIInvalid",
Message: "[CDC:ErrSinkURIInvalid]sink uri invalid",
},
})
p, tester = initProcessor4Test(ctx, t)
// init tick
_, err = p.Tick(ctx, p.changefeed)
require.Nil(t, err)
tester.MustApplyPatches()
// send a normal error
p.sendError(context.Canceled)
_, err = p.Tick(ctx, p.changefeed)
tester.MustApplyPatches()
require.True(t, cerror.ErrReactorFinished.Equal(errors.Cause(err)))
require.Equal(t, p.changefeed.TaskPositions[p.captureInfo.ID], &model.TaskPosition{
Error: nil,
})
} | explode_data.jsonl/81940 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 467
} | [
2830,
3393,
22946,
1454,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
272,
7628,
1972,
7121,
29699,
1972,
19,
2271,
3715,
340,
3223,
11,
37111,
1669,
2930,
22946,
19,
2271,
7502,
11,
259,
340,
2405,
1848,
1465,
198,
197,
322,
2930,
9341... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidate_dataUnexpected(t *testing.T) {
data := []byte(`{
"data": false
}`)
expectedResult(t, data, jsonapivalidator.ErrInvalidDataType, noWarning)
} | explode_data.jsonl/51604 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
17926,
1769,
29430,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
5809,
515,
3677,
330,
691,
788,
895,
198,
197,
5541,
692,
42400,
2077,
1155,
11,
821,
11,
2951,
391,
3936,
307,
850,
27862,
7928,
22653,
11,
902,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsLittleEndian(t *testing.T) {
lscpu := exec.Command("lscpu")
o, err := lscpu.Output()
if err != nil {
t.Skip("no lscpu:", err)
}
for _, line := range bytes.Split(o, []byte("\n")) {
if !bytes.Contains(line, []byte("Byte Order:")) {
continue
}
words := bytes.Fields(line)
lastTwo := bytes.Join(words[len(words)-2:], []byte(" "))
switch string(lastTwo) {
case "Little Endian":
if !IsLittleEndian {
t.Fatal("not little endian")
}
return
case "Big Endian":
if IsLittleEndian {
t.Fatal("not big endian")
}
return
default:
t.Skipf("unknown Byte Order value %q", words)
}
}
t.Skip("unrecognized lscpu output")
} | explode_data.jsonl/9685 | {
"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,
3872,
38103,
43231,
1155,
353,
8840,
836,
8,
341,
8810,
2388,
5584,
1669,
3883,
12714,
445,
75,
2388,
5584,
5130,
22229,
11,
1848,
1669,
326,
2388,
5584,
34246,
741,
743,
1848,
961,
2092,
341,
197,
3244,
57776,
445,
2152,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestPanicHandlerConvertsPanicStringsToHTTPError(t *testing.T) {
r := NewRouter()
r.Use(PanicMiddleware)
done := &sync.WaitGroup{}
done.Add(1)
r.Use(func(next HandlerFunc) HandlerFunc {
return func(c Context) error {
defer done.Done()
err := next(c)
assert.Implements(t, (*HTTPError)(nil), err)
assert.Contains(t, err.Error(), "something broke")
return err
}
})
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/", nil)
r.MethodFunc(http.MethodGet, "/", func(Context) error {
panic("something broke")
})
r.ServeHTTP(rec, req)
done.Wait()
rec.Flush()
} | explode_data.jsonl/18966 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 251
} | [
2830,
3393,
47,
31270,
3050,
12012,
82,
47,
31270,
20859,
1249,
9230,
1454,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
9523,
741,
7000,
9046,
5304,
31270,
24684,
692,
40495,
1669,
609,
12996,
28384,
2808,
16094,
40495,
1904,
7,
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... | 1 |
func TestServerDeleteSession(t *testing.T) {
db := wtmock.NewTowerDB()
localPub := randPubKey(t)
// Initialize two distinct peers with different session ids.
peerPub1 := randPubKey(t)
peerPub2 := randPubKey(t)
id1 := wtdb.NewSessionIDFromPubKey(peerPub1)
id2 := wtdb.NewSessionIDFromPubKey(peerPub2)
// Create closure to simplify assertions on session existence with the
// server's database.
hasSession := func(t *testing.T, id *wtdb.SessionID, shouldHave bool) {
t.Helper()
_, err := db.GetSessionInfo(id)
switch {
case shouldHave && err != nil:
t.Fatalf("expected server to have session %s, got: %v",
id, err)
case !shouldHave && err != wtdb.ErrSessionNotFound:
t.Fatalf("expected ErrSessionNotFound for session %s, "+
"got: %v", id, err)
}
}
initMsg := wtwire.NewInitMessage(
lnwire.NewRawFeatureVector(),
testnetChainHash,
)
createSession := &wtwire.CreateSession{
BlobType: blob.TypeAltruistCommit,
MaxUpdates: 1000,
RewardBase: 0,
RewardRate: 0,
SweepFeeRate: 10000,
}
const timeoutDuration = 100 * time.Millisecond
s := initServer(t, db, timeoutDuration)
defer s.Stop()
// Create a session for peer2 so that the server's db isn't completely
// empty.
peer2 := wtmock.NewMockPeer(localPub, peerPub2, nil, 0)
connect(t, s, peer2, initMsg, timeoutDuration)
sendMsg(t, createSession, peer2, timeoutDuration)
assertConnClosed(t, peer2, 2*timeoutDuration)
// Our initial assertions are that peer2 has a valid session, but peer1
// has not created one.
hasSession(t, &id1, false)
hasSession(t, &id2, true)
peer1Msgs := []struct {
send wtwire.Message
recv wtwire.Message
assert func(t *testing.T)
}{
{
// Deleting unknown session should fail.
send: &wtwire.DeleteSession{},
recv: &wtwire.DeleteSessionReply{
Code: wtwire.DeleteSessionCodeNotFound,
},
assert: func(t *testing.T) {
// Peer2 should still be only session.
hasSession(t, &id1, false)
hasSession(t, &id2, true)
},
},
{
// Create session for peer1.
send: createSession,
recv: &wtwire.CreateSessionReply{
Code: wtwire.CodeOK,
Data: []byte{},
},
assert: func(t *testing.T) {
// Both peers should have sessions.
hasSession(t, &id1, true)
hasSession(t, &id2, true)
},
},
{
// Delete peer1's session.
send: &wtwire.DeleteSession{},
recv: &wtwire.DeleteSessionReply{
Code: wtwire.CodeOK,
},
assert: func(t *testing.T) {
// Peer1's session should have been removed.
hasSession(t, &id1, false)
hasSession(t, &id2, true)
},
},
}
// Now as peer1, process the canned messages defined above. This will:
// 1. Try to delete an unknown session and get a not found error code.
// 2. Create a new session using the same parameters as peer2.
// 3. Delete the newly created session and get an OK.
for _, msg := range peer1Msgs {
peer1 := wtmock.NewMockPeer(localPub, peerPub1, nil, 0)
connect(t, s, peer1, initMsg, timeoutDuration)
sendMsg(t, msg.send, peer1, timeoutDuration)
reply := recvReply(
t, msg.recv.MsgType().String(), peer1, timeoutDuration,
)
if !reflect.DeepEqual(reply, msg.recv) {
t.Fatalf("expected reply: %v, got: %v", msg.recv, reply)
}
assertConnClosed(t, peer1, 2*timeoutDuration)
// Invoke assertions after completing the request/response
// dance.
msg.assert(t)
}
} | explode_data.jsonl/36164 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1337
} | [
2830,
3393,
5475,
6435,
5283,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
289,
13730,
1176,
7121,
95824,
3506,
2822,
8854,
29162,
1669,
10382,
29162,
1592,
1155,
692,
197,
322,
9008,
1378,
12460,
25029,
448,
2155,
3797,
14151,
624,
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... | 5 |
func TestRunAllTheTests(t *testing.T) {
cwd, err := os.Getwd()
if err != nil {
panic(err)
}
s := new(Zuite)
s.cwd = cwd + "/sample_deps"
suite.Run(t, s)
} | explode_data.jsonl/52846 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
6727,
2403,
785,
18200,
1155,
353,
8840,
836,
8,
341,
1444,
6377,
11,
1848,
1669,
2643,
2234,
6377,
741,
743,
1848,
961,
2092,
341,
197,
30764,
3964,
340,
197,
532,
1903,
1669,
501,
27855,
9302,
340,
1903,
64973,
284,
4693... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteExecuteWithExtraStackNotFound(t *testing.T) {
failed := false
handle.LogFatalf = func(s string, a ...interface{}) {
failed = true
}
config.WAITFREQUENCY = 0
client := new(CFClient)
stackname := "ToDeleteStack"
client.Client = &fakeDeleteCFClient{err: nil, stackname: stackname}
opts := &commander.CommandHelper{}
opts.Args = append(opts.Args, "notfound")
d := Delete{
client: client,
}
d.Execute(opts)
if !failed {
t.Error("Expected outcome to fail. Did not fail.")
}
} | explode_data.jsonl/29826 | {
"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,
6435,
17174,
2354,
11612,
4336,
10372,
1155,
353,
8840,
836,
8,
341,
1166,
5687,
1669,
895,
198,
53822,
5247,
68457,
3104,
284,
2915,
1141,
914,
11,
264,
2503,
4970,
28875,
341,
197,
1166,
5687,
284,
830,
198,
197,
532,
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... | 1 |
func TestTransform(t *testing.T) {
timestamp := time.Now()
metadata := Metadata{
Service: Service{Name: "myservice"},
}
resource := "external-service"
const (
trType = "request"
trName = "GET /"
trResult = "HTTP 2xx"
spType = "db"
spSubtype = "sql"
eventOutcome = "success"
)
tests := []struct {
Metricset *Metricset
Output []common.MapStr
Msg string
}{
{
Metricset: nil,
Output: nil,
Msg: "Nil metric",
},
{
Metricset: &Metricset{Timestamp: timestamp, Metadata: metadata},
Output: []common.MapStr{
{
"data_stream.type": "metrics",
"data_stream.dataset": "apm.app",
"processor": common.MapStr{"event": "metric", "name": "metric"},
"service": common.MapStr{
"name": "myservice",
},
},
},
Msg: "Payload with empty metric.",
},
{
Metricset: &Metricset{
Metadata: metadata,
Labels: common.MapStr{"a_b": "a.b.value"},
Timestamp: timestamp,
Samples: []Sample{
{
Name: "a.counter",
Value: 612,
},
{
Name: "some.gauge",
Value: 9.16,
},
},
},
Output: []common.MapStr{
{
"data_stream.type": "metrics",
"data_stream.dataset": "apm.app",
"processor": common.MapStr{"event": "metric", "name": "metric"},
"service": common.MapStr{"name": "myservice"},
"labels": common.MapStr{"a_b": "a.b.value"},
"a": common.MapStr{"counter": float64(612)},
"some": common.MapStr{"gauge": float64(9.16)},
},
},
Msg: "Payload with valid metric.",
},
{
Metricset: &Metricset{
Timestamp: timestamp,
Metadata: metadata,
Span: MetricsetSpan{Type: spType, Subtype: spSubtype},
Transaction: MetricsetTransaction{Type: trType, Name: trName},
Samples: []Sample{{
Name: "span.self_time.count",
Value: 123,
}},
},
Output: []common.MapStr{
{
"data_stream.type": "metrics",
"data_stream.dataset": "apm.internal",
"processor": common.MapStr{"event": "metric", "name": "metric"},
"service": common.MapStr{"name": "myservice"},
"transaction": common.MapStr{"type": trType, "name": trName},
"span": common.MapStr{
"type": spType, "subtype": spSubtype,
"self_time": common.MapStr{
"count": 123.0,
},
},
},
},
Msg: "Payload with breakdown metrics.",
},
{
Metricset: &Metricset{
Timestamp: timestamp,
Metadata: metadata,
Event: MetricsetEventCategorization{Outcome: eventOutcome},
Transaction: MetricsetTransaction{
Type: trType,
Name: trName,
Result: trResult,
Root: true,
},
TimeseriesInstanceID: "foo",
Samples: []Sample{
{
Name: "transaction.duration.histogram",
Value: 666, // Value is ignored when Counts/Values are specified
Counts: []int64{1, 2, 3},
Values: []float64{4.5, 6.0, 9.0},
},
},
},
Output: []common.MapStr{
{
"data_stream.type": "metrics",
"data_stream.dataset": "apm.internal",
"processor": common.MapStr{"event": "metric", "name": "metric"},
"service": common.MapStr{"name": "myservice"},
"event": common.MapStr{"outcome": eventOutcome},
"timeseries": common.MapStr{"instance": "foo"},
"transaction": common.MapStr{
"type": trType,
"name": trName,
"result": trResult,
"root": true,
"duration": common.MapStr{
"histogram": common.MapStr{
"counts": []int64{1, 2, 3},
"values": []float64{4.5, 6.0, 9.0},
},
},
},
"_doc_count": int64(6), // 1+2+3
},
},
Msg: "Payload with transaction duration.",
},
{
Metricset: &Metricset{
Timestamp: timestamp,
Metadata: metadata,
Span: MetricsetSpan{Type: spType, Subtype: spSubtype, DestinationService: DestinationService{
Resource: &resource,
}},
Samples: []Sample{
{
Name: "destination.service.response_time.count",
Value: 40,
},
{
Name: "destination.service.response_time.sum.us",
Value: 500000,
},
},
},
Output: []common.MapStr{
{
"data_stream.type": "metrics",
"data_stream.dataset": "apm.internal",
"processor": common.MapStr{"event": "metric", "name": "metric"},
"service": common.MapStr{"name": "myservice"},
"span": common.MapStr{"type": spType, "subtype": spSubtype,
"destination": common.MapStr{"service": common.MapStr{"resource": resource}}},
"destination": common.MapStr{"service": common.MapStr{"response_time": common.MapStr{
"count": 40.0,
"sum": common.MapStr{"us": 500000.0},
},
},
},
},
},
Msg: "Payload with destination service.",
},
}
for idx, test := range tests {
outputEvents := test.Metricset.Transform(context.Background(), &transform.Config{DataStreams: true})
for j, outputEvent := range outputEvents {
assert.Equal(t, test.Output[j], outputEvent.Fields, fmt.Sprintf("Failed at idx %v; %s", idx, test.Msg))
assert.Equal(t, timestamp, outputEvent.Timestamp, fmt.Sprintf("Bad timestamp at idx %v; %s", idx, test.Msg))
}
}
} | explode_data.jsonl/62973 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2595
} | [
2830,
3393,
8963,
1155,
353,
8840,
836,
8,
341,
3244,
4702,
1669,
882,
13244,
741,
2109,
7603,
1669,
33589,
515,
197,
91619,
25,
5362,
63121,
25,
330,
8209,
1017,
7115,
197,
532,
50346,
1669,
330,
20921,
23461,
1837,
4777,
2399,
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 TestZenkakuASCII2HankakuASCIINumber(t *testing.T) {
opt := NewOption()
tp := newTextProcessor(opt)
actual := tp.zenkaku2Hankaku("0123456789")
expected := "0123456789"
if actual != expected {
t.Errorf("expected %v, but got %v", expected, actual)
}
} | explode_data.jsonl/25037 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
57,
78571,
23557,
56450,
17,
39,
1180,
23557,
1911,
11237,
687,
890,
1155,
353,
8840,
836,
8,
341,
64838,
1669,
1532,
5341,
741,
73423,
1669,
94653,
22946,
24539,
692,
88814,
1669,
18101,
3938,
78571,
23557,
17,
39,
1180,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNodeGetInfo(t *testing.T) {
d := NewFakeDriver()
// Test valid request
req := csi.NodeGetInfoRequest{}
resp, err := d.NodeGetInfo(context.Background(), &req)
assert.NoError(t, err)
assert.Equal(t, resp.GetNodeId(), fakeNodeID)
} | explode_data.jsonl/36849 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
1955,
1949,
1731,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
1532,
52317,
11349,
2822,
197,
322,
3393,
2697,
1681,
198,
24395,
1669,
272,
6321,
21714,
1949,
1731,
1900,
16094,
34653,
11,
1848,
1669,
294,
21714,
1949,
1731,
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... | 1 |
func TestNewReadLogsCommandFileLogStreamProviderCorrect(t *testing.T) {
test.SkipIfGitLabCIOn(t, test.OSWindows)
cmd := newReadLogsCommand()
cmd.WaitFileTimeout = 10 * time.Second
f, cleanup := setupTestFile(t)
time.AfterFunc(time.Second, cleanup)
cmd.Path = f.Name()
err := cmd.execute()
assert.True(t, os.IsNotExist(err), "expected err %T, but got %T", os.ErrNotExist, err)
assert.Equal(t, &fileLogStreamProvider{
waitFileTimeout: cmd.WaitFileTimeout,
path: cmd.Path,
}, cmd.logStreamProvider)
} | explode_data.jsonl/3426 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 203
} | [
2830,
3393,
3564,
4418,
51053,
4062,
1703,
2201,
3027,
5179,
33092,
1155,
353,
8840,
836,
8,
341,
18185,
57776,
2679,
46562,
29046,
11237,
1925,
1155,
11,
1273,
57054,
13164,
692,
25920,
1669,
501,
4418,
51053,
4062,
741,
25920,
28384,
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... | 1 |
func TestReplacingMapMapInterface(t *testing.T) {
// We want to replace map[string]map[string]interface{} with
// map[string]JSON, rather than the right one, since
// controller-gen can't handle it at the moment.
g := NewGomegaWithT(t)
p1 := test.MakeLocalPackageReference("horo.logy", "v20200730")
aName := astmodel.MakeTypeName(p1, "A")
defs := make(astmodel.Types)
defs.Add(astmodel.MakeTypeDefinition(
aName,
astmodel.NewObjectType().WithProperties(
astmodel.NewPropertyDefinition("Field1", "field1", astmodel.BoolType),
astmodel.NewPropertyDefinition("Maps", "maps", astmodel.NewMapType(
astmodel.StringType,
astmodel.NewMapType(
astmodel.StringType,
astmodel.AnyType,
),
)),
),
))
state := NewState().WithTypes(defs)
finalState, err := ReplaceAnyTypeWithJSON().action(context.Background(), state)
g.Expect(err).To(BeNil())
// A should be a map[string]JSON.
expectedType := astmodel.NewMapType(
astmodel.StringType,
astmodel.MakeTypeName(
astmodel.MakeExternalPackageReference("k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"),
"JSON",
),
)
finalTypes := finalState.Types()
aDef := finalTypes[aName]
aProp, found := aDef.Type().(*astmodel.ObjectType).Property("Maps")
g.Expect(found).To(BeTrue())
g.Expect(aProp.PropertyType()).To(Equal(expectedType))
} | explode_data.jsonl/13754 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 507
} | [
2830,
3393,
81160,
2227,
2227,
5051,
1155,
353,
8840,
836,
8,
341,
197,
322,
1205,
1366,
311,
8290,
2415,
14032,
60,
2186,
14032,
31344,
6257,
448,
198,
197,
322,
2415,
14032,
60,
5370,
11,
4751,
1091,
279,
1290,
825,
11,
2474,
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 TestAppSplits(t *testing.T) {
ctx := testApp(t, `
android_app {
name: "foo",
srcs: ["a.java"],
package_splits: ["v4", "v7,hdpi"],
sdk_version: "current"
}`)
foo := ctx.ModuleForTests("foo", "android_common")
expectedOutputs := []string{
"out/soong/.intermediates/foo/android_common/foo.apk",
"out/soong/.intermediates/foo/android_common/foo_v4.apk",
"out/soong/.intermediates/foo/android_common/foo_v7_hdpi.apk",
}
for _, expectedOutput := range expectedOutputs {
foo.Output(expectedOutput)
}
outputFiles, err := foo.Module().(*AndroidApp).OutputFiles("")
if err != nil {
t.Fatal(err)
}
android.AssertPathsRelativeToTopEquals(t, `OutputFiles("")`, expectedOutputs, outputFiles)
} | explode_data.jsonl/58474 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 310
} | [
2830,
3393,
2164,
50,
39033,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1273,
2164,
1155,
11,
22074,
571,
197,
5954,
8191,
341,
464,
11609,
25,
330,
7975,
756,
464,
41144,
82,
25,
4383,
64,
10848,
8097,
464,
197,
1722,
73000,
25,
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... | 3 |
func TestEncode(t *testing.T) {
requireEncodeResult(t, true, 1)
requireEncodeResult(t, false, 0)
requireEncodeResult(t, int8(10), 10)
requireEncodeResult(t, int8(-2), 0xfe)
requireEncodeResult(t, int16(100), 100, 0)
requireEncodeResult(t, int32(-10), 0xf6, 0xff, 0xff, 0xff)
requireEncodeResult(t, int64(12345678), 0x4e, 0x61, 0xbc, 0, 0, 0, 0, 0)
requireEncodeResult(t, uint8(10), 10)
requireEncodeResult(t, int16(4321), 0xe1, 0x10)
requireEncodeResult(t, uint32(645322), 0xca, 0xd8, 0x09, 0)
requireEncodeResult(t, uint64(987654321), 0xb1, 0x68, 0xde, 0x3a, 0, 0, 0, 0)
requireEncodeResult(t, float32(3.14159), 0xd0, 0x0f, 0x49, 0x40)
requireEncodeResult(t, float64(3.14159265359), 0xea, 0x2e, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40)
requireEncodeResult(t, "hello", []byte("\x05hello")...)
requireEncodeResult(t, "", 0)
requireEncodeResult(t, []byte("hello"), []byte("\x05hello")...)
requireEncodeResult(t, []byte{}, 0)
requireEncodeResult(t, StructValue("alice", int16(100), float32(3.14159)), []byte("\x03\x05alice\x64\x00\xd0\x0f\x49\x40")...)
requireEncodeResult(t,
StructValue("bob",
StructValue("alice", int16(100), float32(3.14159)),
),
[]byte("\x02\x03bob\x03\x05alice\x64\x00\xd0\x0f\x49\x40")...)
requireEncodeResult(t, []int32{3,4,5,6}, 4, 3,0,0,0, 4,0,0,0, 5,0,0,0, 6,0,0,0)
requireEncodeResult(t, []string{"nice", "to", "meet", "you"}, []byte("\x04\x04nice\x02to\x04meet\x03you")...)
requireEncodeError(t, map[int]int{1:2, 3:4})
requireEncodeError(t, nil)
requireEncodeError(t, []interface{}{3})
} | explode_data.jsonl/13702 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 726
} | [
2830,
3393,
32535,
1155,
353,
8840,
836,
8,
341,
17957,
32535,
2077,
1155,
11,
830,
11,
220,
16,
340,
17957,
32535,
2077,
1155,
11,
895,
11,
220,
15,
340,
17957,
32535,
2077,
1155,
11,
526,
23,
7,
16,
15,
701,
220,
16,
15,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTracingDiagnostics(t *testing.T) {
tcs := []struct {
defaults *tracingDiagnostics
enabledEnv string
fileEnv string
expected *tracingDiagnostics
}{
{defaults: newTracingDiagnostics(false, "trace.out"), enabledEnv: "", fileEnv: "", expected: newTracingDiagnostics(false, "trace.out")},
{defaults: newTracingDiagnostics(true, "/tmp/trace.out"), enabledEnv: "", fileEnv: "", expected: newTracingDiagnostics(true, "/tmp/trace.out")},
{defaults: newTracingDiagnostics(false, "trace.out"), enabledEnv: "false", fileEnv: "/tmp/trace.out", expected: newTracingDiagnostics(false, "/tmp/trace.out")},
{defaults: newTracingDiagnostics(false, "trace.out"), enabledEnv: "true", fileEnv: "/tmp/trace.out", expected: newTracingDiagnostics(true, "/tmp/trace.out")},
{defaults: newTracingDiagnostics(false, "trace.out"), enabledEnv: "true", fileEnv: "", expected: newTracingDiagnostics(true, "trace.out")},
}
for i, tc := range tcs {
t.Run(fmt.Sprintf("testcase %d", i), func(t *testing.T) {
os.Clearenv()
if tc.enabledEnv != "" {
err := os.Setenv(tracingEnabledEnvName, tc.enabledEnv)
assert.NoError(t, err)
}
if tc.fileEnv != "" {
err := os.Setenv(tracingFileEnvName, tc.fileEnv)
assert.NoError(t, err)
}
err := tc.defaults.overrideWithEnv()
assert.NoError(t, err)
assert.Exactly(t, tc.expected, tc.defaults)
})
}
} | explode_data.jsonl/33538 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 564
} | [
2830,
3393,
1282,
4527,
35,
18938,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
1235,
341,
197,
11940,
82,
256,
353,
376,
4527,
35,
18938,
198,
197,
197,
15868,
14359,
914,
198,
197,
17661,
14359,
262,
914,
198,
197,
42400,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetFullDirectoryPath(t *testing.T) {
tempFile := filepath.Join(os.TempDir(), "testdir"+uuid.New().String()+"_"+t.Name())
err := os.MkdirAll(tempFile, os.ModeDir)
assert.NoError(t, err, "creating temp dir failed")
aPath, err := GetFullDirectoryPath(tempFile)
assert.Equal(t, tempFile, aPath, "Path is different")
assert.NoError(t, err)
os.RemoveAll(tempFile)
} | explode_data.jsonl/54588 | {
"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,
1949,
9432,
9310,
1820,
1155,
353,
8840,
836,
8,
341,
16280,
1703,
1669,
26054,
22363,
9638,
65009,
6184,
1507,
330,
1944,
3741,
5572,
17128,
7121,
1005,
703,
25589,
33415,
83,
2967,
2398,
9859,
1669,
2643,
1321,
12438,
2403,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetValidDiskName(t *testing.T) {
tests := []struct {
volumeName string
expected string
}{
{
volumeName: "az",
expected: "az",
},
{
volumeName: "09",
expected: "09",
},
{
volumeName: "a-z",
expected: "a-z",
},
{
volumeName: "AZ",
expected: "AZ",
},
{
volumeName: "123456789-123456789-123456789-123456789-123456789.123456789-123456789_1234567890",
expected: "123456789-123456789-123456789-123456789-123456789.123456789-123456789_1234567890",
},
}
for _, test := range tests {
result := getValidDiskName(test.volumeName)
if !reflect.DeepEqual(result, test.expected) {
t.Errorf("input: %q, getValidFileShareName result: %q, expected: %q", test.volumeName, result, test.expected)
}
}
} | explode_data.jsonl/62107 | {
"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,
1949,
4088,
47583,
675,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
5195,
4661,
675,
914,
198,
197,
42400,
256,
914,
198,
197,
59403,
197,
197,
515,
298,
5195,
4661,
675,
25,
330,
1370,
756,
298,
424... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccCloudStackNetwork_vpc(t *testing.T) {
var network cloudstack.Network
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudStackNetworkDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCloudStackNetwork_vpc,
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudStackNetworkExists(
"cloudstack_network.foo", &network),
testAccCheckCloudStackNetworkVPCAttributes(&network),
),
},
},
})
} | explode_data.jsonl/79600 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
14603,
16055,
4336,
12320,
2273,
3992,
1155,
353,
8840,
836,
8,
341,
2405,
3922,
9437,
7693,
30149,
271,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
4703,
3973,
25,
257,
2915,
368,
314,
1273,
14603,
4703,
3973,
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... | 1 |
func TestCheckNetNsConfig(t *testing.T) {
assert := assert.New(t)
config := oci.RuntimeConfig{
DisableNewNetNs: true,
NetmonConfig: vc.NetmonConfig{
Enable: true,
},
}
err := checkNetNsConfig(config)
assert.Error(err)
config = oci.RuntimeConfig{
DisableNewNetNs: true,
InterNetworkModel: vc.NetXConnectDefaultModel,
}
err = checkNetNsConfig(config)
assert.Error(err)
} | explode_data.jsonl/11752 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
3973,
6954,
47360,
2648,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
25873,
1669,
93975,
16706,
2648,
515,
197,
197,
25479,
3564,
6954,
47360,
25,
830,
345,
197,
197,
6954,
1645,
2648,
25,
24553,
16993,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcileAddonsConfiguration_UpdateAddonsProcess(t *testing.T) {
// GIVEN
fixAddonsCfg := fixAddonsConfiguration()
fixAddonsCfg.Generation = 2
fixAddonsCfg.Status.ObservedGeneration = 1
ts := getTestSuite(t, fixAddonsCfg)
indexDTO := fixIndexDTO()
tmpDir := os.TempDir()
ts.addonGetter.On("GetIndex").Return(indexDTO, nil)
ts.addonGetter.On("Cleanup").Return(nil)
for _, entry := range indexDTO.Entries {
for _, e := range entry {
completeAddon := fixAddonWithDocsURL(string(e.Name), string(e.Name), "example.com", "example.com")
ts.addonGetter.On("GetCompleteAddon", e).
Return(completeAddon, nil)
ts.docsProvider.On("EnsureAssetGroup", completeAddon.Addon).Return(nil)
}
}
ts.brokerFacade.On("Exist").Return(false, nil).Once()
ts.addonGetterFactory.On("NewGetter", fixAddonsCfg.Spec.Repositories[0].URL, path.Join(tmpDir, "addon-loader-dst")).Return(ts.addonGetter, nil).Once()
defer ts.assertExpectations()
// WHEN
reconciler := NewReconcileAddonsConfiguration(ts.mgr, ts.addonGetterFactory, ts.chartStorage, ts.addonStorage,
ts.brokerFacade, ts.docsProvider, ts.brokerSyncer, ts.templateService, tmpDir, time.Second, spy.NewLogDummy())
// THEN
result, err := reconciler.Reconcile(reconcile.Request{NamespacedName: types.NamespacedName{Namespace: fixAddonsCfg.Namespace, Name: fixAddonsCfg.Name}})
assert.NoError(t, err)
assert.False(t, result.Requeue)
} | explode_data.jsonl/40349 | {
"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,
693,
40446,
457,
2212,
2382,
7688,
47393,
2212,
2382,
7423,
1155,
353,
8840,
836,
8,
341,
197,
322,
89836,
198,
1166,
941,
2212,
2382,
42467,
1669,
5046,
2212,
2382,
7688,
741,
1166,
941,
2212,
2382,
42467,
66516,
284,
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 TestCompiler_releaseRegisterToStack(t *testing.T) {
const val = 10000
tests := []struct {
name string
stackPointer uint64
isFloat bool
}{
{name: "int", stackPointer: 10, isFloat: false},
{name: "float", stackPointer: 10, isFloat: true},
{name: "int-huge-height", stackPointer: math.MaxInt16 + 1, isFloat: false},
{name: "float-huge-height", stackPointer: math.MaxInt16 + 1, isFloat: true},
}
for _, tt := range tests {
tc := tt
t.Run(tc.name, func(t *testing.T) {
env := newCompilerEnvironment()
// Compile code.
compiler := env.requireNewCompiler(t, newCompiler, nil)
err := compiler.compilePreamble()
require.NoError(t, err)
// Setup the location stack so that we push the const on the specified height.
s := &runtimeValueLocationStack{
sp: tc.stackPointer,
stack: make([]*runtimeValueLocation, tc.stackPointer),
usedRegisters: map[asm.Register]struct{}{},
}
// Peek must be non-nil. Otherwise, compileConst* would fail.
s.stack[s.sp-1] = &runtimeValueLocation{}
compiler.setRuntimeValueLocationStack(s)
if tc.isFloat {
err = compiler.compileConstF64(&wazeroir.OperationConstF64{Value: math.Float64frombits(val)})
} else {
err = compiler.compileConstI64(&wazeroir.OperationConstI64{Value: val})
}
require.NoError(t, err)
// Release the register allocated value to the memory stack so that we can see the value after exiting.
compiler.compileReleaseRegisterToStack(s.peek())
compiler.compileExitFromNativeCode(nativeCallStatusCodeReturned)
// Generate the code under test.
code, _, _, err := compiler.compile()
require.NoError(t, err)
// Run native code after growing the value stack.
env.callEngine().builtinFunctionGrowValueStack(tc.stackPointer)
env.exec(code)
// Compiler status must be returned and stack pointer must end up the specified one.
require.Equal(t, nativeCallStatusCodeReturned, env.compilerStatus())
require.Equal(t, tc.stackPointer+1, env.stackPointer())
if tc.isFloat {
require.Equal(t, math.Float64frombits(val), env.stackTopAsFloat64())
} else {
require.Equal(t, uint64(val), env.stackTopAsUint64())
}
})
}
} | explode_data.jsonl/13222 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 851
} | [
2830,
3393,
38406,
24577,
8690,
1249,
4336,
1155,
353,
8840,
836,
8,
341,
4777,
1044,
284,
220,
16,
15,
15,
15,
15,
198,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
48227,
9084,
2622,
21,
19,
198,
197,
19907,
5442,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDefaultBackendDoesNotOverwriteNamedHost(t *testing.T) {
rh, c, done := setup(t)
defer done()
rh.OnAdd(fixture.NewService("kuard").
WithPorts(v1.ServicePort{Name: "http", Port: 80, TargetPort: intstr.FromInt(8080)},
v1.ServicePort{Name: "alt", Port: 8080, TargetPort: intstr.FromInt(8080)}),
)
rh.OnAdd(fixture.NewService("test-gui").
WithPorts(v1.ServicePort{Name: "http", Port: 80, TargetPort: intstr.FromInt(8080)}),
)
rh.OnAdd(&v1beta1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "hello",
Namespace: "default",
},
Spec: v1beta1.IngressSpec{
Backend: &v1beta1.IngressBackend{
ServiceName: "kuard",
ServicePort: intstr.FromInt(80),
},
Rules: []v1beta1.IngressRule{{
Host: "test-gui",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{{
Path: "/",
Backend: v1beta1.IngressBackend{
ServiceName: "test-gui",
ServicePort: intstr.FromInt(80),
},
}},
},
},
}, {
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{{
Path: "/kuard",
Backend: v1beta1.IngressBackend{
ServiceName: "kuard",
ServicePort: intstr.FromInt(8080),
},
}},
},
},
}},
},
})
c.Request(routeType).Equals(&v2.DiscoveryResponse{
VersionInfo: "1",
Resources: routeResources(t,
envoy.RouteConfiguration("ingress_http",
envoy.VirtualHost("*",
&envoy_api_v2_route.Route{
Match: routePrefix("/kuard"),
Action: routecluster("default/kuard/8080/da39a3ee5e"),
},
&envoy_api_v2_route.Route{
Match: routePrefix("/"),
Action: routecluster("default/kuard/80/da39a3ee5e"),
},
),
envoy.VirtualHost("test-gui",
&envoy_api_v2_route.Route{
Match: routePrefix("/"),
Action: routecluster("default/test-gui/80/da39a3ee5e"),
},
),
),
),
TypeUrl: routeType,
Nonce: "1",
})
} | explode_data.jsonl/24110 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1015
} | [
2830,
3393,
3675,
29699,
21468,
2623,
1918,
4934,
15810,
9296,
1155,
353,
8840,
836,
8,
341,
7000,
71,
11,
272,
11,
2814,
1669,
6505,
1155,
340,
16867,
2814,
2822,
7000,
71,
8071,
2212,
94886,
7121,
1860,
445,
74,
11034,
38609,
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... | 1 |
func TestParsersTimestampInJSONMessage(t *testing.T) {
env := newInputTestingEnvironment(t)
testlogName := "test.log"
inp := env.mustCreateInput(map[string]interface{}{
"paths": []string{env.abspath(testlogName)},
"prospector.scanner.check_interval": "1ms",
"parsers": []map[string]interface{}{
map[string]interface{}{
"ndjson": map[string]interface{}{
"target": "",
"overwrite_keys": true,
"add_error_key": true,
},
},
},
})
testline := []byte(`{"@timestamp":"2016-04-05T18:47:18.444Z", "msg":"hallo"}
{"@timestamp":"invalid"}
{"@timestamp":{"hello": "test"}}
`)
env.mustWriteLinesToFile(testlogName, testline)
ctx, cancelInput := context.WithCancel(context.Background())
env.startInput(ctx, inp)
env.waitUntilEventCount(3)
env.requireOffsetInRegistry(testlogName, len(testline))
env.requireEventTimestamp(0, "2016-04-05T18:47:18.444")
env.requireEventContents(1, "error.message", "@timestamp not overwritten (parse error on invalid)")
env.requireEventContents(2, "error.message", "@timestamp not overwritten (not string)")
cancelInput()
env.waitUntilInputStops()
} | explode_data.jsonl/14915 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 471
} | [
2830,
3393,
47,
40488,
20812,
641,
5370,
2052,
1155,
353,
8840,
836,
8,
341,
57538,
1669,
501,
2505,
16451,
12723,
1155,
692,
18185,
839,
675,
1669,
330,
1944,
1665,
698,
17430,
79,
1669,
6105,
69419,
4021,
2505,
9147,
14032,
31344,
670... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdatableApps_TransitiveDepsShouldSetMinSdkVersion(t *testing.T) {
testJavaError(t, `module "bar".*: should support min_sdk_version\(29\)`, cc.GatherRequiredDepsForTest(android.Android)+`
android_app {
name: "foo",
srcs: ["a.java"],
updatable: true,
sdk_version: "current",
min_sdk_version: "29",
static_libs: ["bar"],
}
java_library {
name: "bar",
sdk_version: "current",
}
`)
} | explode_data.jsonl/58478 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
2324,
88831,
53602,
34932,
3404,
35,
7124,
14996,
1649,
6217,
57175,
5637,
1155,
353,
8840,
836,
8,
341,
18185,
15041,
1454,
1155,
11,
1565,
4352,
330,
2257,
3263,
80103,
1265,
1824,
1308,
61783,
9438,
44292,
17,
24,
57758,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_OperationHashes(t *testing.T) {
goldenOperationHashses := getResponse(operationhashes).([][]string)
type want struct {
wantErr bool
containsErr string
wantOperationHashes [][]string
}
cases := []struct {
name string
inputHanler http.Handler
want
}{
{
"failed to unmarshal",
gtGoldenHTTPMock(operationHashesHandlerMock([]byte(`junk`), blankHandler)),
want{
true,
"could not unmarshal operation hashes",
[][]string{},
},
},
{
"is successful",
gtGoldenHTTPMock(operationHashesHandlerMock(readResponse(operationhashes), blankHandler)),
want{
false,
"",
goldenOperationHashses,
},
},
}
for _, tt := range cases {
t.Run(tt.name, func(t *testing.T) {
server := httptest.NewServer(tt.inputHanler)
defer server.Close()
gt, err := New(server.URL)
assert.Nil(t, err)
operationHashes, err := gt.OperationHashes("BLzGD63HA4RP8Fh5xEtvdQSMKa2WzJMZjQPNVUc4Rqy8Lh5BEY1")
checkErr(t, tt.wantErr, tt.containsErr, err)
assert.Equal(t, tt.want.wantOperationHashes, operationHashes)
})
}
} | explode_data.jsonl/48370 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 504
} | [
2830,
3393,
2232,
91774,
6370,
288,
1155,
353,
8840,
836,
8,
341,
3174,
813,
268,
8432,
6370,
9275,
1669,
633,
2582,
52347,
8296,
288,
568,
10556,
1294,
917,
692,
13158,
1366,
2036,
341,
197,
50780,
7747,
1797,
1807,
198,
197,
197,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppendChecksum(t *testing.T) {
//goland:noinspection GoImportUsedAsName
assert := assert.New(t)
for _, tt := range tests {
crcBytes := make([]byte, 2)
binary.LittleEndian.PutUint16(crcBytes, tt.expectedCrc)
expectedData := append(tt.data, crcBytes...)
testedData := tt.data[:]
AppendChecksum(&testedData)
assert.Len(testedData, len(expectedData))
assert.Equal(expectedData, testedData)
}
} | explode_data.jsonl/37605 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
23877,
73190,
1155,
353,
8840,
836,
8,
341,
262,
442,
70,
96440,
66479,
53395,
5994,
11511,
22743,
2121,
675,
198,
262,
2060,
1669,
2060,
7121,
1155,
340,
1066,
262,
369,
8358,
17853,
1669,
2088,
7032,
341,
286,
37180,
7078,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFirestoreDeleteDocument(t *testing.T) {
var expectedResponse *emptypb.Empty = &emptypb.Empty{}
mockFirestore.err = nil
mockFirestore.reqs = nil
mockFirestore.resps = append(mockFirestore.resps[:0], expectedResponse)
var formattedName string = fmt.Sprintf("projects/%s/databases/%s/documents/%s/%s", "[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
var request = &firestorepb.DeleteDocumentRequest{
Name: formattedName,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
err = c.DeleteDocument(context.Background(), request)
if err != nil {
t.Fatal(err)
}
if want, got := request, mockFirestore.reqs[0]; !proto.Equal(want, got) {
t.Errorf("wrong request %q, want %q", got, want)
}
} | explode_data.jsonl/27378 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 290
} | [
2830,
3393,
48513,
6435,
7524,
1155,
353,
8840,
836,
8,
341,
2405,
3601,
2582,
353,
20968,
1082,
65,
11180,
284,
609,
20968,
1082,
65,
11180,
31483,
77333,
48513,
18441,
284,
2092,
198,
77333,
48513,
1327,
26358,
284,
2092,
271,
77333,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateOrSetClientIPAffinityConfig(t *testing.T) {
successCases := map[string]*core.SessionAffinityConfig{
"non-empty config, valid timeout: 1": {
ClientIP: &core.ClientIPConfig{
TimeoutSeconds: utilpointer.Int32Ptr(1),
},
},
"non-empty config, valid timeout: core.MaxClientIPServiceAffinitySeconds-1": {
ClientIP: &core.ClientIPConfig{
TimeoutSeconds: utilpointer.Int32Ptr(core.MaxClientIPServiceAffinitySeconds - 1),
},
},
"non-empty config, valid timeout: core.MaxClientIPServiceAffinitySeconds": {
ClientIP: &core.ClientIPConfig{
TimeoutSeconds: utilpointer.Int32Ptr(core.MaxClientIPServiceAffinitySeconds),
},
},
}
for name, test := range successCases {
if errs := validateClientIPAffinityConfig(test, field.NewPath("field")); len(errs) != 0 {
t.Errorf("case: %s, expected success: %v", name, errs)
}
}
errorCases := map[string]*core.SessionAffinityConfig{
"empty session affinity config": nil,
"empty client IP config": {
ClientIP: nil,
},
"empty timeoutSeconds": {
ClientIP: &core.ClientIPConfig{
TimeoutSeconds: nil,
},
},
"non-empty config, invalid timeout: core.MaxClientIPServiceAffinitySeconds+1": {
ClientIP: &core.ClientIPConfig{
TimeoutSeconds: utilpointer.Int32Ptr(core.MaxClientIPServiceAffinitySeconds + 1),
},
},
"non-empty config, invalid timeout: -1": {
ClientIP: &core.ClientIPConfig{
TimeoutSeconds: utilpointer.Int32Ptr(-1),
},
},
"non-empty config, invalid timeout: 0": {
ClientIP: &core.ClientIPConfig{
TimeoutSeconds: utilpointer.Int32Ptr(0),
},
},
}
for name, test := range errorCases {
if errs := validateClientIPAffinityConfig(test, field.NewPath("field")); len(errs) == 0 {
t.Errorf("case: %v, expected failures: %v", name, errs)
}
}
} | explode_data.jsonl/1068 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 698
} | [
2830,
3393,
17926,
2195,
1649,
2959,
3298,
25841,
13489,
2648,
1155,
353,
8840,
836,
8,
341,
30553,
37302,
1669,
2415,
14032,
8465,
2153,
20674,
25841,
13489,
2648,
515,
197,
197,
1,
6280,
39433,
2193,
11,
2697,
9632,
25,
220,
16,
788,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPClientParallel(t *testing.T) {
wg := sync.WaitGroup{}
wg.Add(5)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
wg.Done()
wg.Wait()
w.WriteHeader(http.StatusCreated)
w.Write([]byte("foobar"))
}))
defer ts.Close()
conf := NewConfig()
conf.HTTP.Config.URL = ts.URL + "/testpost"
conf.HTTP.Parallel = true
h, err := NewHTTP(conf, nil, log.Noop(), metrics.Noop())
if err != nil {
t.Fatal(err)
}
inputMsg := message.New([][]byte{
[]byte("foo"),
[]byte("bar"),
[]byte("baz"),
[]byte("qux"),
[]byte("quz"),
})
inputMsg.Get(0).Metadata().Set("foo", "bar")
msgs, res := h.ProcessMessage(inputMsg)
if res != nil {
t.Error(res.Error())
} else if expC, actC := 5, msgs[0].Len(); actC != expC {
t.Errorf("Wrong result count: %v != %v", actC, expC)
} else if exp, act := "foobar", string(message.GetAllBytes(msgs[0])[0]); act != exp {
t.Errorf("Wrong result: %v != %v", act, exp)
} else if exp, act := "bar", msgs[0].Get(0).Metadata().Get("foo"); exp != act {
t.Errorf("Metadata not preserved: %v != %v", act, exp)
} else if exp, act := "201", msgs[0].Get(0).Metadata().Get("http_status_code"); exp != act {
t.Errorf("Wrong response code metadata: %v != %v", act, exp)
}
} | explode_data.jsonl/20220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 535
} | [
2830,
3393,
9230,
2959,
16547,
1155,
353,
8840,
836,
8,
341,
72079,
1669,
12811,
28384,
2808,
16094,
72079,
1904,
7,
20,
340,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
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... | 1 |
func Test_ErrCheck(t *testing.T) {
c1 := NewLidi(Settings{
InvokeErrCheck: true,
})
if err := c1.Provide(15); err != nil {
t.Fatal(err)
}
v := &ErrCheck{}
if err := c1.Provide(v); err != nil {
if err.Error() != "some error" {
t.Fatal("Not Equal")
}
} else {
t.Fatal(err)
}
} | explode_data.jsonl/40211 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
93623,
3973,
1155,
353,
8840,
836,
8,
341,
1444,
16,
1669,
1532,
43,
12278,
57395,
515,
197,
197,
17604,
7747,
3973,
25,
830,
345,
197,
8824,
743,
1848,
1669,
272,
16,
7763,
19448,
7,
16,
20,
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... | 4 |
func TestData(t *testing.T) {
t.Skip("Skipping `data.json` generation test")
_, config, err := getHostURI()
if err != nil {
t.Fatal("error getting config information", err.Error())
}
f := mbtest.NewReportingMetricSetV2(t, config)
events, errs := mbtest.ReportingFetchV2(f)
if len(errs) > 0 {
t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs)
}
assert.NotEmpty(t, events)
if err = mbtest.WriteEventsReporterV2(f, t, ""); err != nil {
t.Fatal("write", err)
}
} | explode_data.jsonl/16610 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
93200,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
445,
85945,
1565,
691,
4323,
63,
9471,
1273,
5130,
197,
6878,
2193,
11,
1848,
1669,
633,
9296,
10301,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
445,
841,
3709,
2193,
1995... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCloudSecretProvider(t *testing.T) {
kmsKeyAlias := os.Getenv("PULUMI_TEST_KMS_KEY_ALIAS")
if kmsKeyAlias == "" {
t.Skipf("Skipping: PULUMI_TEST_KMS_KEY_ALIAS is not set")
}
testOptions := integration.ProgramTestOptions{
Dir: "cloud_secrets_provider",
Dependencies: []string{"@pulumi/pulumi"},
SecretsProvider: fmt.Sprintf("awskms://alias/%s", kmsKeyAlias),
Secrets: map[string]string{
"mysecret": "THISISASECRET",
},
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
secretsProvider := stackInfo.Deployment.SecretsProviders
assert.NotNil(t, secretsProvider)
assert.Equal(t, secretsProvider.Type, "cloud")
_, err := cloud.NewCloudSecretsManagerFromState(secretsProvider.State)
assert.NoError(t, err)
out, ok := stackInfo.Outputs["out"].(map[string]interface{})
assert.True(t, ok)
_, ok = out["ciphertext"]
assert.True(t, ok)
},
}
localTestOptions := testOptions.With(integration.ProgramTestOptions{
CloudURL: "file://~",
})
// Run with default Pulumi service backend
t.Run("service", func(t *testing.T) { integration.ProgramTest(t, &testOptions) })
// Also run with local backend
t.Run("local", func(t *testing.T) { integration.ProgramTest(t, &localTestOptions) })
} | explode_data.jsonl/76374 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 498
} | [
2830,
3393,
16055,
19773,
5179,
1155,
353,
8840,
836,
8,
341,
16463,
1011,
1592,
22720,
1669,
2643,
64883,
445,
47,
1094,
2794,
40,
11641,
10102,
4826,
6600,
61608,
1138,
743,
96677,
1592,
22720,
621,
1591,
341,
197,
3244,
57776,
69,
44... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestXsrfReset_01(t *testing.T) {
r := &http.Request{}
c := NewContext()
c.Request = r
c.ResponseWriter = &Response{}
c.ResponseWriter.reset(httptest.NewRecorder())
c.Output.Reset(c)
c.Input.Reset(c)
c.XSRFToken("key", 16)
if c._xsrfToken == "" {
t.FailNow()
}
token := c._xsrfToken
c.Reset(&Response{ResponseWriter: httptest.NewRecorder()}, r)
if c._xsrfToken != "" {
t.FailNow()
}
c.XSRFToken("key", 16)
if c._xsrfToken == "" {
t.FailNow()
}
if token == c._xsrfToken {
t.FailNow()
}
} | explode_data.jsonl/39538 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
55,
82,
8052,
14828,
62,
15,
16,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
609,
1254,
9659,
16094,
1444,
1669,
1532,
1972,
741,
1444,
9659,
284,
435,
198,
1444,
37508,
284,
609,
2582,
16094,
1444,
37508,
13857,
73392,
83,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEC2CredentialsBuildStringToSignV2(t *testing.T) {
opts := ec2tokens.AuthOptions{
Verb: "GET",
Host: "localhost",
Path: "/",
Params: map[string]string{
"Action": "foo",
"Value": "bar",
},
}
expected := []byte("GET\nlocalhost\n/\nAction=foo&Value=bar")
testhelper.CheckDeepEquals(t, expected, ec2tokens.EC2CredentialsBuildStringToSignV2(opts))
} | explode_data.jsonl/68585 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
7498,
17,
27025,
11066,
703,
1249,
7264,
53,
17,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
11942,
17,
30566,
25233,
3798,
515,
197,
197,
66946,
25,
330,
3806,
756,
197,
197,
9296,
25,
330,
8301,
756,
197,
69640,
25,
352... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrderingServiceFirstOperationFailure(t *testing.T) {
testOrderingServiceFirstOperationFailure(t, blockDelivererConsumerWithRecv)
testOrderingServiceFirstOperationFailure(t, blockDelivererConsumerWithSend)
assert.Equal(t, 0, connNumber)
} | explode_data.jsonl/38314 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
4431,
287,
1860,
5338,
8432,
17507,
1155,
353,
8840,
836,
8,
341,
18185,
4431,
287,
1860,
5338,
8432,
17507,
1155,
11,
2504,
16532,
1524,
261,
29968,
2354,
63483,
340,
18185,
4431,
287,
1860,
5338,
8432,
17507,
1155,
11,
250... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsWriteable(t *testing.T) {
writeDir := "privilege" + "/write"
err := Mkdir(writeDir, 0755)
if err != nil {
panic(err)
}
t.Cleanup(func() {
_ = RemoveWithRecur("privilege")
})
if !IsWritable(writeDir) {
t.Error("IsWriteable test failed!")
}
} | explode_data.jsonl/34186 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
3872,
7985,
480,
1155,
353,
8840,
836,
8,
1476,
24945,
6184,
1669,
330,
11887,
42769,
1,
488,
3521,
4934,
698,
9859,
1669,
386,
12438,
55828,
6184,
11,
220,
15,
22,
20,
20,
340,
743,
1848,
961,
2092,
341,
197,
30764,
396... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrintEndpoint(t *testing.T) {
tests := []struct {
endpoint api.Endpoints
expected []metav1.TableRow
}{
// Basic endpoint with no IP's
{
endpoint: api.Endpoints{
ObjectMeta: metav1.ObjectMeta{
Name: "endpoint1",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
},
// Columns: Name, Endpoints, Age
expected: []metav1.TableRow{{Cells: []interface{}{"endpoint1", "<none>", "0s"}}},
},
// Endpoint with no ports
{
endpoint: api.Endpoints{
ObjectMeta: metav1.ObjectMeta{
Name: "endpoint3",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-3e11)},
},
Subsets: []api.EndpointSubset{
{
Addresses: []api.EndpointAddress{
{
IP: "1.2.3.4",
},
{
IP: "5.6.7.8",
},
},
},
},
},
// Columns: Name, Endpoints, Age
expected: []metav1.TableRow{{Cells: []interface{}{"endpoint3", "1.2.3.4,5.6.7.8", "5m"}}},
},
// Basic endpoint with two IP's and one port
{
endpoint: api.Endpoints{
ObjectMeta: metav1.ObjectMeta{
Name: "endpoint2",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Subsets: []api.EndpointSubset{
{
Addresses: []api.EndpointAddress{
{
IP: "1.2.3.4",
},
{
IP: "5.6.7.8",
},
},
Ports: []api.EndpointPort{
{
Port: 8001,
Protocol: "tcp",
},
},
},
},
},
// Columns: Name, Endpoints, Age
expected: []metav1.TableRow{{Cells: []interface{}{"endpoint2", "1.2.3.4:8001,5.6.7.8:8001", "0s"}}},
},
// Basic endpoint with greater than three IP's triggering "more" string
{
endpoint: api.Endpoints{
ObjectMeta: metav1.ObjectMeta{
Name: "endpoint2",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Subsets: []api.EndpointSubset{
{
Addresses: []api.EndpointAddress{
{
IP: "1.2.3.4",
},
{
IP: "5.6.7.8",
},
{
IP: "9.8.7.6",
},
{
IP: "6.6.6.6",
},
},
Ports: []api.EndpointPort{
{
Port: 8001,
Protocol: "tcp",
},
},
},
},
},
// Columns: Name, Endpoints, Age
expected: []metav1.TableRow{{Cells: []interface{}{"endpoint2", "1.2.3.4:8001,5.6.7.8:8001,9.8.7.6:8001 + 1 more...", "0s"}}},
},
}
for i, test := range tests {
rows, err := printEndpoints(&test.endpoint, printers.GenerateOptions{})
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows))
}
}
} | explode_data.jsonl/21635 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1557
} | [
2830,
3393,
8994,
27380,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
341,
197,
6246,
2768,
6330,
18569,
7706,
198,
197,
42400,
3056,
4059,
402,
16,
18257,
3102,
198,
197,
59403,
197,
197,
322,
14625,
14887,
448,
902,
6790,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDirectoryResolver_FilesByGlobMultiple(t *testing.T) {
resolver, err := newDirectoryResolver("./test-fixtures")
assert.NoError(t, err)
refs, err := resolver.FilesByGlob("**/image-symlinks/file*")
assert.NoError(t, err)
assert.Len(t, refs, 2)
} | explode_data.jsonl/50114 | {
"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,
9310,
18190,
1400,
3658,
1359,
38,
1684,
32089,
1155,
353,
8840,
836,
8,
341,
10202,
7921,
11,
1848,
1669,
501,
9310,
18190,
13988,
1944,
70913,
18513,
1138,
6948,
35699,
1155,
11,
1848,
340,
197,
16149,
11,
1848,
1669,
3622... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetBrowser360Spider(t *testing.T) {
if browser, ok := GetBrowser("360Spider"); !ok {
t.Error("Browser not found")
} else if browser.Browser != "360Spider" {
t.Errorf("Expected Chrome but got %q", browser.Browser)
} else if browser.IsCrawler() != true {
t.Errorf("Expected true but got %t", browser.IsCrawler())
}
} | explode_data.jsonl/35276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
1949,
17878,
18,
21,
15,
72908,
1155,
353,
8840,
836,
8,
341,
743,
6929,
11,
5394,
1669,
2126,
17878,
445,
18,
21,
15,
72908,
5038,
753,
562,
341,
197,
3244,
6141,
445,
17878,
537,
1730,
1138,
197,
92,
770,
421,
6929,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccPermissionsInstancePool(t *testing.T) {
permissionsTestHelper(t, func(permissionsAPI PermissionsAPI, user, group string,
ef func(string) PermissionsEntity) {
poolsAPI := compute.NewInstancePoolsAPI(context.Background(), permissionsAPI.client)
ctx := context.Background()
ips, err := poolsAPI.Create(compute.InstancePool{
InstancePoolName: group,
NodeTypeID: compute.NewClustersAPI(
ctx, permissionsAPI.client).GetSmallestNodeType(
compute.NodeTypeRequest{
LocalDisk: true,
}),
})
require.NoError(t, err)
defer func() {
assert.NoError(t, poolsAPI.Delete(ips.InstancePoolID))
}()
objectID := fmt.Sprintf("/instance-pools/%s", ips.InstancePoolID)
require.NoError(t, permissionsAPI.Update(objectID, AccessControlChangeList{
AccessControlList: []AccessControlChange{
{
UserName: user,
PermissionLevel: "CAN_MANAGE",
},
{
GroupName: group,
PermissionLevel: "CAN_ATTACH_TO",
},
},
}))
entity := ef(objectID)
assert.Equal(t, "instance-pool", entity.ObjectType)
assert.Len(t, entity.AccessControlList, 2)
require.NoError(t, permissionsAPI.Delete(objectID))
entity = ef(objectID)
assert.Len(t, entity.AccessControlList, 0)
})
} | explode_data.jsonl/50887 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 491
} | [
2830,
3393,
14603,
23851,
2523,
10551,
1155,
353,
8840,
836,
8,
341,
197,
29900,
2271,
5511,
1155,
11,
2915,
7,
29900,
7082,
53357,
7082,
11,
1196,
11,
1874,
914,
345,
197,
197,
823,
2915,
3609,
8,
53357,
3030,
8,
341,
197,
3223,
61... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateJobs_WhenOneOfThreeJobsIsMissing_SkipsMissingJob_OtherChangesSucceed_SameBatch(t *testing.T) {
whenOneOfThreeJobsIsMissing_SkipsMissingJob_OtherChangesSucceed(t, 10)
} | explode_data.jsonl/32073 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
4289,
40667,
62,
4498,
3966,
2124,
19641,
40667,
3872,
25080,
1098,
74,
3077,
25080,
12245,
2232,
696,
11317,
50,
29264,
1098,
373,
21074,
1155,
353,
8840,
836,
8,
341,
60180,
3966,
2124,
19641,
40667,
3872,
25080,
1098,
74,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCopy(t *testing.T) {
vset := randValidatorSet(10)
vsetHash := vset.Hash()
if len(vsetHash) == 0 {
t.Fatalf("ValidatorSet had unexpected zero hash")
}
vsetCopy := vset.Copy()
vsetCopyHash := vsetCopy.Hash()
if !bytes.Equal(vsetHash, vsetCopyHash) {
t.Fatalf("ValidatorSet copy had wrong hash. Orig: %X, Copy: %X", vsetHash, vsetCopyHash)
}
} | explode_data.jsonl/28313 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
12106,
1155,
353,
8840,
836,
8,
341,
5195,
746,
1669,
10382,
14256,
1649,
7,
16,
15,
340,
5195,
746,
6370,
1669,
348,
746,
15103,
741,
743,
2422,
3747,
746,
6370,
8,
621,
220,
15,
341,
197,
3244,
30762,
445,
14256,
1649,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseVolumeShortVolumes(t *testing.T) {
for _, path := range []string{".", "/a"} {
volume, err := parseVolume(path)
expected := types.ServiceVolumeConfig{Type: "volume", Target: path}
assert.NoError(t, err)
assert.Equal(t, expected, volume)
}
} | explode_data.jsonl/70095 | {
"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,
14463,
18902,
12472,
96325,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1815,
1669,
2088,
3056,
917,
90,
3263,
497,
3521,
64,
9207,
341,
197,
5195,
4661,
11,
1848,
1669,
4715,
18902,
5581,
340,
197,
42400,
1669,
4494,
13860,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTypeSystem_ObjectFieldsMustHaveOutputTypes_AcceptAnOutputTypeAsAnObjectFieldType(t *testing.T) {
for _, ttype := range outputTypes {
_, err := schemaWithObjectFieldOfType(ttype)
if err != nil {
t.Fatalf(`unexpected error: %v for type "%v"`, err, ttype)
}
}
} | explode_data.jsonl/79176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
929,
2320,
27839,
8941,
31776,
12116,
5097,
4173,
1566,
66,
1484,
2082,
5097,
929,
2121,
2082,
1190,
63733,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
259,
1313,
1669,
2088,
2550,
4173,
341,
197,
197,
6878,
1848,
1669,
10802,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWantlistClearsOnCancel(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
vnet := getVirtualNetwork()
ig := testinstance.NewTestInstanceGenerator(vnet, nil, nil)
defer ig.Close()
bgen := blocksutil.NewBlockGenerator()
blks := bgen.Blocks(10)
var cids []cid.Cid
for _, blk := range blks {
cids = append(cids, blk.Cid())
}
inst := ig.Instances(1)
a := inst[0]
ctx1, cancel1 := context.WithCancel(ctx)
ses := a.Exchange.NewSession(ctx1)
_, err := ses.GetBlocks(ctx, cids)
if err != nil {
t.Fatal(err)
}
cancel1()
if err := tu.WaitFor(ctx, func() error {
if len(a.Exchange.GetWantlist()) > 0 {
return fmt.Errorf("expected empty wantlist")
}
return nil
}); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/2229 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 322
} | [
2830,
3393,
28823,
1607,
14008,
82,
1925,
9269,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
882,
32435,
9,
20,
340,
16867,
9121,
2822,
5195,
4711,
1669,
633,
33026,
12320,
741,
197,
343,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDiscoverySync(t *testing.T) {
serverResources := []*metav1.APIResourceList{
{
GroupVersion: "v1",
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod", Verbs: metav1.Verbs{"create", "delete", "list", "watch"}},
},
},
}
unsyncableServerResources := []*metav1.APIResourceList{
{
GroupVersion: "v1",
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod", Verbs: metav1.Verbs{"create", "delete", "list", "watch"}},
{Name: "secrets", Namespaced: true, Kind: "Secret", Verbs: metav1.Verbs{"create", "delete", "list", "watch"}},
},
},
}
fakeDiscoveryClient := &fakeServerResources{
PreferredResources: serverResources,
Error: nil,
Lock: sync.Mutex{},
InterfaceUsedCount: 0,
}
testHandler := &fakeActionHandler{
response: map[string]FakeResponse{
"GET" + "/api/v1/pods": {
200,
[]byte("{}"),
},
"GET" + "/api/v1/secrets": {
404,
[]byte("{}"),
},
},
}
srv, clientConfig := testServerAndClientConfig(testHandler.ServeHTTP)
defer srv.Close()
clientConfig.ContentConfig.NegotiatedSerializer = nil
kubeClient, err := kubernetes.NewForConfig(clientConfig)
if err != nil {
t.Fatal(err)
}
pods := schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}
secrets := schema.GroupVersionResource{Group: "", Version: "v1", Resource: "secrets"}
listersForResourceConfig := map[schema.GroupVersionResource]cache.GenericLister{
pods: newGenericLister(pods.GroupResource(), []runtime.Object{}),
secrets: newGenericLister(secrets.GroupResource(), []runtime.Object{}),
}
qc := setupQuotaController(t, kubeClient, mockListerForResourceFunc(listersForResourceConfig), fakeDiscoveryClient.ServerPreferredNamespacedResources)
defer close(qc.stop)
stopSync := make(chan struct{})
defer close(stopSync)
// The pseudo-code of Sync():
// Sync(client, period, stopCh):
// wait.Until() loops with `period` until the `stopCh` is closed :
// GetQuotableResources()
// resyncMonitors()
// controller.WaitForCacheSync() loops with `syncedPollPeriod` (hardcoded to 100ms), until either its stop channel is closed after `period`, or all caches synced.
//
// Setting the period to 200ms allows the WaitForCacheSync() to check
// for cache sync ~2 times in every wait.Until() loop.
//
// The 1s sleep in the test allows GetQuotableResources and
// resyncMonitors to run ~5 times to ensure the changes to the
// fakeDiscoveryClient are picked up.
go qc.Sync(fakeDiscoveryClient.ServerPreferredNamespacedResources, 200*time.Millisecond, stopSync)
// Wait until the sync discovers the initial resources
time.Sleep(1 * time.Second)
err = expectSyncNotBlocked(fakeDiscoveryClient, &qc.workerLock)
if err != nil {
t.Fatalf("Expected quotacontroller.Sync to be running but it is blocked: %v", err)
}
// Simulate the discovery client returning an error
fakeDiscoveryClient.setPreferredResources(nil)
fakeDiscoveryClient.setError(fmt.Errorf("Error calling discoveryClient.ServerPreferredResources()"))
// Wait until sync discovers the change
time.Sleep(1 * time.Second)
// Remove the error from being returned and see if the quota sync is still working
fakeDiscoveryClient.setPreferredResources(serverResources)
fakeDiscoveryClient.setError(nil)
err = expectSyncNotBlocked(fakeDiscoveryClient, &qc.workerLock)
if err != nil {
t.Fatalf("Expected quotacontroller.Sync to still be running but it is blocked: %v", err)
}
// Simulate the discovery client returning a resource the restmapper can resolve, but will not sync caches
fakeDiscoveryClient.setPreferredResources(unsyncableServerResources)
fakeDiscoveryClient.setError(nil)
// Wait until sync discovers the change
time.Sleep(1 * time.Second)
// Put the resources back to normal and ensure quota sync recovers
fakeDiscoveryClient.setPreferredResources(serverResources)
fakeDiscoveryClient.setError(nil)
err = expectSyncNotBlocked(fakeDiscoveryClient, &qc.workerLock)
if err != nil {
t.Fatalf("Expected quotacontroller.Sync to still be running but it is blocked: %v", err)
}
} | explode_data.jsonl/76144 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1438
} | [
2830,
3393,
67400,
12154,
1155,
353,
8840,
836,
8,
341,
41057,
11277,
1669,
29838,
4059,
402,
16,
24922,
4783,
852,
515,
197,
197,
515,
298,
197,
2808,
5637,
25,
330,
85,
16,
756,
298,
197,
7082,
11277,
25,
3056,
4059,
402,
16,
2492... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 Test_chartTarballURL(t *testing.T) {
r := &models.RepoInternal{Name: "test", URL: "http://testrepo.com"}
tests := []struct {
name string
cv models.ChartVersion
wanted string
}{
{"absolute url", models.ChartVersion{URLs: []string{"http://testrepo.com/wordpress-0.1.0.tgz"}}, "http://testrepo.com/wordpress-0.1.0.tgz"},
{"relative url", models.ChartVersion{URLs: []string{"wordpress-0.1.0.tgz"}}, "http://testrepo.com/wordpress-0.1.0.tgz"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, chartTarballURL(r, tt.cv), tt.wanted, "url")
})
}
} | explode_data.jsonl/67804 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 260
} | [
2830,
3393,
40961,
62733,
3959,
3144,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
609,
6507,
2817,
5368,
11569,
63121,
25,
330,
1944,
497,
5548,
25,
330,
1254,
1110,
1944,
23476,
905,
16707,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLabelsValidate(t *testing.T) {
cases := []struct {
name string
tags Labels
valid bool
}{
{
name: "empty tags",
valid: true,
},
{
name: "bad tag",
tags: Labels{"^": "^"},
},
{
name: "good tag",
tags: Labels{"key": "value"},
valid: true,
},
}
for _, c := range cases {
if got := c.tags.Validate(); (got == nil) != c.valid {
t.Errorf("%s failed: got valid=%v but wanted valid=%v: %v", c.name, got == nil, c.valid, got)
}
}
} | explode_data.jsonl/56890 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
23674,
17926,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
3244,
2032,
220,
60996,
198,
197,
56322,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
220,
330,
3194,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_fileserverHandler(t *testing.T) {
router := httprouter.New()
path := "/frontend/*path"
route, err := NewFileServer(path, "testdata", "testdata/index.html").Build()
require.NoError(t, err)
router.HandlerFunc(route.method, route.path, route.handler)
assert.Equal(t, path, route.Path())
assert.Equal(t, http.MethodGet, route.Method())
tests := map[string]struct {
expectedResponse string
path string
}{
"success": {path: "/frontend/existing.html", expectedResponse: "existing"},
"fallback": {path: "/frontend/missing-file", expectedResponse: "fallback"},
}
for name, tt := range tests {
tt := tt
t.Run(name, func(t *testing.T) {
// the only way to test do we get the same handler that we provided initially, is to run it explicitly,
// since all we have in Route itself is a wrapper function
req, err := http.NewRequest(http.MethodGet, tt.path, nil)
require.NoError(t, err)
wr := httptest.NewRecorder()
router.ServeHTTP(wr, req)
br, err := ioutil.ReadAll(wr.Body)
require.NoError(t, err)
assert.Equal(t, tt.expectedResponse, string(br))
})
}
} | explode_data.jsonl/54961 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 422
} | [
2830,
3393,
2458,
4030,
3050,
1155,
353,
8840,
836,
8,
341,
67009,
1669,
54320,
649,
2676,
7121,
741,
26781,
1669,
3521,
28181,
1057,
2343,
698,
7000,
2133,
11,
1848,
1669,
1532,
1703,
5475,
5581,
11,
330,
92425,
497,
330,
92425,
9022,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAutoscalerBasicFunctions(t *testing.T) {
t.Parallel()
stable := framework.AgonesClient.StableV1alpha1()
fleets := stable.Fleets(defaultNs)
flt, err := fleets.Create(defaultFleet())
if assert.Nil(t, err) {
defer fleets.Delete(flt.ObjectMeta.Name, nil) // nolint:errcheck
}
framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas))
fleetautoscalers := framework.AgonesClient.AutoscalingV1().FleetAutoscalers(defaultNs)
fas, err := fleetautoscalers.Create(defaultFleetAutoscaler(flt))
if assert.Nil(t, err) {
defer fleetautoscalers.Delete(fas.ObjectMeta.Name, nil) // nolint:errcheck
} else {
// if we could not create the autoscaler, their is no point going further
logrus.Error("Failed creating autoscaler, aborting TestAutoscalerBasicFunctions")
return
}
// the fleet autoscaler should scale the fleet up now up to BufferSize
bufferSize := int32(fas.Spec.Policy.Buffer.BufferSize.IntValue())
framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(bufferSize))
// patch the autoscaler to increase MinReplicas and watch the fleet scale up
fas, err = patchFleetAutoscaler(fas, intstr.FromInt(int(bufferSize)), bufferSize+2, fas.Spec.Policy.Buffer.MaxReplicas)
assert.Nil(t, err, "could not patch fleetautoscaler")
// min replicas is now higher than buffer size, will scale to that level
framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(fas.Spec.Policy.Buffer.MinReplicas))
// patch the autoscaler to remove MinReplicas and watch the fleet scale down to bufferSize
fas, err = patchFleetAutoscaler(fas, intstr.FromInt(int(bufferSize)), 0, fas.Spec.Policy.Buffer.MaxReplicas)
assert.Nil(t, err, "could not patch fleetautoscaler")
bufferSize = int32(fas.Spec.Policy.Buffer.BufferSize.IntValue())
framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(bufferSize))
// do an allocation and watch the fleet scale up
gsa := framework.CreateAndApplyAllocation(t, flt)
framework.WaitForFleetCondition(t, flt, func(fleet *stablev1alpha1.Fleet) bool {
return fleet.Status.AllocatedReplicas == 1
})
framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(bufferSize))
// patch autoscaler to switch to relative buffer size and check if the fleet adjusts
_, err = patchFleetAutoscaler(fas, intstr.FromString("10%"), 1, fas.Spec.Policy.Buffer.MaxReplicas)
assert.Nil(t, err, "could not patch fleetautoscaler")
//10% with only one allocated GS means only one ready server
framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(1))
// get the Status of the fleetautoscaler
fas, err = framework.AgonesClient.AutoscalingV1().FleetAutoscalers(fas.ObjectMeta.Namespace).Get(fas.Name, metav1.GetOptions{})
assert.Nil(t, err, "could not get fleetautoscaler")
assert.True(t, fas.Status.AbleToScale, "Could not get AbleToScale status")
// check that we are able to scale
framework.WaitForFleetAutoScalerCondition(t, fas, func(fas *autoscalingv1.FleetAutoscaler) bool {
return !fas.Status.ScalingLimited
})
// patch autoscaler to a maxReplicas count equal to current replicas count
_, err = patchFleetAutoscaler(fas, intstr.FromInt(1), 1, 1)
assert.Nil(t, err, "could not patch fleetautoscaler")
// check that we are not able to scale
framework.WaitForFleetAutoScalerCondition(t, fas, func(fas *autoscalingv1.FleetAutoscaler) bool {
return fas.Status.ScalingLimited
})
// delete the allocated GameServer and watch the fleet scale down
gp := int64(1)
err = stable.GameServers(defaultNs).Delete(gsa.Status.GameServerName, &metav1.DeleteOptions{GracePeriodSeconds: &gp})
assert.Nil(t, err)
framework.WaitForFleetCondition(t, flt, func(fleet *stablev1alpha1.Fleet) bool {
return fleet.Status.AllocatedReplicas == 0 &&
fleet.Status.ReadyReplicas == 1 &&
fleet.Status.Replicas == 1
})
} | explode_data.jsonl/62769 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1333
} | [
2830,
3393,
19602,
436,
63084,
15944,
25207,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18388,
480,
1669,
12626,
49850,
3154,
2959,
7758,
480,
53,
16,
7141,
16,
741,
1166,
273,
1415,
1669,
15175,
991,
273,
1415,
18978,
47360... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApixu_APIInternalServerError(t *testing.T) {
a := &apixu{
config: Config{},
httpClient: &httpClientMock{
response: &http.Response{
StatusCode: http.StatusNotImplemented,
Body: &bodyMock{},
},
err: nil,
},
read: func(r io.Reader) ([]byte, error) {
return []byte{}, nil
},
}
res, err := a.Search("query")
assert.Nil(t, res)
assert.Error(t, err)
} | explode_data.jsonl/14951 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
10611,
941,
84,
11415,
55984,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
609,
391,
941,
84,
515,
197,
25873,
25,
5532,
38837,
197,
28080,
2959,
25,
609,
83417,
11571,
515,
298,
21735,
25,
609,
1254,
12574,
515,
571,
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 TestSampleKurtosis(t *testing.T) {
fmt.Println("Testing Kurtosis")
m := 10000000
mu := 0.0
sd := 1.0
d := make([]float64, m)
for i, _ := range d {
d[i] = dst.NormalNext(mu, sd)
}
x := Kurt(d)
y := 3.0
if abs(x-y) > 1e-3 {
fmt.Println("failed: x, y ", x, y)
t.Error()
}
} | explode_data.jsonl/67292 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
17571,
42,
5639,
10704,
1155,
353,
8840,
836,
8,
341,
11009,
12419,
445,
16451,
42923,
10704,
1138,
2109,
1669,
220,
16,
15,
15,
15,
15,
15,
15,
15,
198,
2109,
84,
1669,
220,
15,
13,
15,
198,
99000,
1669,
220,
16,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDoltTransactionCommitAutocommit(t *testing.T) {
if types.IsFormat_DOLT_1(types.Format_Default) {
t.Skip()
}
// In this test, each insertion from both clients cause a commit as autocommit is enabled.
// Not the recommended way to use the feature, but it's permitted.
harness := newDoltHarness(t)
enginetest.TestTransactionScript(t, harness, enginetest.TransactionTest{
Name: "dolt commit with autocommit",
SetUpScript: []string{
"CREATE TABLE x (y BIGINT PRIMARY KEY, z BIGINT);",
"INSERT INTO x VALUES (1,1);",
},
Assertions: []enginetest.ScriptTestAssertion{
// these SET statements currently commit a transaction (since autocommit is on)
{
Query: "/* client a */ SET @@dolt_transaction_commit=1;",
Expected: []sql.Row{{}},
},
{
Query: "/* client b */ SET @@dolt_transaction_commit=1;",
Expected: []sql.Row{{}},
},
{
Query: "/* client a */ INSERT INTO x VALUES (2,2);",
Expected: []sql.Row{{sql.NewOkResult(1)}},
},
{
Query: "/* client b */ INSERT INTO x VALUES (3,3);",
Expected: []sql.Row{{sql.NewOkResult(1)}},
},
{
Query: "/* client a */ SELECT * FROM x ORDER BY y;",
Expected: []sql.Row{{1, 1}, {2, 2}, {3, 3}},
},
{
Query: "/* client b */ SELECT * FROM x ORDER BY y;",
Expected: []sql.Row{{1, 1}, {2, 2}, {3, 3}},
},
{
Query: "/* client c */ SELECT * FROM x ORDER BY y;",
Expected: []sql.Row{{1, 1}, {2, 2}, {3, 3}},
},
},
})
db := harness.databases[0].GetDoltDB()
cs, err := doltdb.NewCommitSpec("HEAD")
require.NoError(t, err)
headRefs, err := db.GetHeadRefs(context.Background())
require.NoError(t, err)
commit3, err := db.Resolve(context.Background(), cs, headRefs[0])
require.NoError(t, err)
cm3, err := commit3.GetCommitMeta(context.Background())
require.NoError(t, err)
require.Contains(t, cm3.Description, "Transaction commit")
as, err := doltdb.NewAncestorSpec("~1")
require.NoError(t, err)
commit2, err := commit3.GetAncestor(context.Background(), as)
require.NoError(t, err)
cm2, err := commit2.GetCommitMeta(context.Background())
require.NoError(t, err)
require.Contains(t, cm2.Description, "Transaction commit")
commit1, err := commit2.GetAncestor(context.Background(), as)
require.NoError(t, err)
cm1, err := commit1.GetCommitMeta(context.Background())
require.NoError(t, err)
require.Equal(t, "Transaction commit", cm1.Description)
commit0, err := commit1.GetAncestor(context.Background(), as)
require.NoError(t, err)
cm0, err := commit0.GetCommitMeta(context.Background())
require.NoError(t, err)
require.Equal(t, "Initialize data repository", cm0.Description)
} | explode_data.jsonl/5289 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1081
} | [
2830,
3393,
35,
6181,
8070,
33441,
19602,
11986,
1763,
1155,
353,
8840,
836,
8,
341,
743,
4494,
4506,
4061,
1557,
35320,
62,
16,
52613,
9978,
60336,
8,
341,
197,
3244,
57776,
741,
197,
630,
197,
322,
758,
419,
1273,
11,
1817,
35927,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConstTypeConvIssue792(t *testing.T) {
gopClTest(t, `
const dots = ". . . " + ". . . . . "
const n = uint(len(dots))
`, `package main
const dots = ". . . " + ". . . . . "
const n = uint(len(dots))
`)
} | explode_data.jsonl/73595 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
19167,
929,
34892,
42006,
22,
24,
17,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
22074,
1024,
30994,
284,
5933,
659,
659,
330,
488,
5933,
659,
659,
659,
659,
6228,
1024,
308,
284,
2622,
6901,
1500,
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 TestRemove(t *testing.T) {
cases := []struct {
input []string
remove []string
expect []string
}{
{
input: []string{"a", "b", "a", "c"},
remove: []string{"a", "b"},
expect: []string{"c"},
},
{
input: []string{"b", "c"},
remove: []string{"a"},
expect: []string{"b", "c"},
},
{
input: []string{"b", "a", "c"},
remove: []string{"a"},
expect: []string{"b", "c"},
},
{
input: []string{},
remove: []string{"a"},
expect: []string{},
},
}
for _, each := range cases {
t.Run(path.Join(each.input...), func(t *testing.T) {
assert.ElementsMatch(t, each.expect, Remove(each.input, each.remove...))
})
}
} | explode_data.jsonl/76722 | {
"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,
13021,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
22427,
220,
3056,
917,
198,
197,
47233,
3056,
917,
198,
197,
24952,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
22427,
25,
220,
3056,
917,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProcesses_Checkout(t *testing.T) {
p := &processes{maxLen: 10}
cfg, repo, _ := testcfg.BuildWithRepo(t)
key0 := mustCreateKey(t, "0", repo)
value0, cancel := mustCreateCacheable(t, cfg, repo)
p.Add(key0, value0, time.Now().Add(time.Hour), cancel)
entry, ok := p.Checkout(key{sessionID: "foo"})
requireProcessesValid(t, p)
require.Nil(t, entry, "expect nil value when key not found")
require.False(t, ok, "ok flag")
entry, ok = p.Checkout(key0)
requireProcessesValid(t, p)
require.Equal(t, value0, entry.value)
require.True(t, ok, "ok flag")
require.False(t, entry.value.isClosed(), "value should not be closed after checkout")
entry, ok = p.Checkout(key0)
require.False(t, ok, "ok flag after second checkout")
require.Nil(t, entry, "value from second checkout")
} | explode_data.jsonl/81951 | {
"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,
92727,
28188,
411,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
609,
4630,
288,
90,
2810,
11271,
25,
220,
16,
15,
630,
50286,
11,
15867,
11,
716,
1669,
1273,
14072,
25212,
2354,
25243,
1155,
692,
23634,
15,
1669,
1969,
4021,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfiguration_Is(t *testing.T) {
a := Configuration{0, 2, 7, 0}
b := Configuration{0, 2, 7, 0}
c := Configuration{2, 4, 1, 2}
d := Configuration{2, 4, 1}
if !a.Is(b) {
t.Errorf("Expected %v to equal %v.", a, b)
}
if a.Is(c) {
t.Errorf("Expected %v not to equal %v.", a, c)
}
if c.Is(d) {
t.Errorf("Expected %v not to equal %v.", c, d)
}
} | explode_data.jsonl/6767 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
7688,
31879,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
12221,
90,
15,
11,
220,
17,
11,
220,
22,
11,
220,
15,
532,
2233,
1669,
12221,
90,
15,
11,
220,
17,
11,
220,
22,
11,
220,
15,
532,
1444,
1669,
12221,
90,
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,
1... | 4 |
func TestValidateRouteDestination(t *testing.T) {
testCases := []struct {
name string
routes []*networking.RouteDestination
valid bool
}{
{name: "simple", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz"},
}}, valid: true},
{name: "no destination", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: nil,
}}, valid: false},
{name: "weighted", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 25,
}, &networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: 75,
}}, valid: true},
{name: "weight < 0", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 5,
}, &networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: -1,
}}, valid: false},
{name: "total weight > 100", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 55,
}, &networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: 50,
}}, valid: false},
{name: "total weight < 100", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 49,
}, &networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: 50,
}}, valid: false},
{name: "total weight = 100", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 100,
}, &networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: 0,
}}, valid: true},
{name: "weight = 0", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 0,
}}, valid: true},
{name: "total weight = 0 with multi RouteDestination", routes: []*networking.RouteDestination{&networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 0,
}, &networking.RouteDestination{
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: 0,
}}, valid: false},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if err := validateRouteDestinations(tc.routes); (err == nil) != tc.valid {
t.Fatalf("got valid=%v but wanted valid=%v: %v", err == nil, tc.valid, err)
}
})
}
} | explode_data.jsonl/56920 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1107
} | [
2830,
3393,
17926,
4899,
33605,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
7000,
5495,
29838,
17511,
287,
58004,
33605,
198,
197,
56322,
220,
1807,
198,
197,
59403,
197,
197,
47006... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntegration(t *testing.T) {
addr := os.Getenv("ETCD_ADDR")
if addr == "" {
t.Skip("ETCD_ADDR not set; skipping integration test")
}
var (
prefix = "/services/foosvc/" // known at compile time
instance = "1.2.3.4:8080" // taken from runtime or platform, somehow
key = prefix + instance
value = "http://" + instance // based on our transport
)
client, err := NewClient(context.Background(), []string{addr}, ClientOptions{
DialTimeout: 2 * time.Second,
DialKeepAlive: 2 * time.Second,
HeaderTimeoutPerRequest: 2 * time.Second,
})
if err != nil {
t.Fatalf("NewClient(%q): %v", addr, err)
}
// Verify test data is initially empty.
entries, err := client.GetEntries(key)
if err == nil {
t.Fatalf("GetEntries(%q): expected error, got none", key)
}
t.Logf("GetEntries(%q): %v (OK)", key, err)
// Instantiate a new Registrar, passing in test data.
registrar := NewRegistrar(client, Service{
Key: key,
Value: value,
}, log.With(log.NewLogfmtLogger(os.Stderr), "component", "registrar"))
// Register our instance.
registrar.Register()
t.Logf("Registered")
// Retrieve entries from etcd manually.
entries, err = client.GetEntries(key)
if err != nil {
t.Fatalf("client.GetEntries(%q): %v", key, err)
}
if want, have := 1, len(entries); want != have {
t.Fatalf("client.GetEntries(%q): want %d, have %d", key, want, have)
}
if want, have := value, entries[0]; want != have {
t.Fatalf("want %q, have %q", want, have)
}
instancer, err := NewInstancer(
client,
prefix,
log.With(log.NewLogfmtLogger(os.Stderr), "component", "instancer"),
)
if err != nil {
t.Fatalf("NewInstancer: %v", err)
}
endpointer := sd.NewEndpointer(
instancer,
func(string) (endpoint.Endpoint, io.Closer, error) { return endpoint.Nop, nil, nil },
log.With(log.NewLogfmtLogger(os.Stderr), "component", "instancer"),
)
t.Logf("Constructed Endpointer OK")
if !within(time.Second, func() bool {
endpoints, err := endpointer.Endpoints()
return err == nil && len(endpoints) == 1
}) {
t.Fatalf("Endpointer didn't see Register in time")
}
t.Logf("Endpointer saw Register OK")
// Deregister first instance of test data.
registrar.Deregister()
t.Logf("Deregistered")
// Check it was deregistered.
if !within(time.Second, func() bool {
endpoints, err := endpointer.Endpoints()
t.Logf("Checking Deregister: len(endpoints) = %d, err = %v", len(endpoints), err)
return err == nil && len(endpoints) == 0
}) {
t.Fatalf("Endpointer didn't see Deregister in time")
}
// Verify test data no longer exists in etcd.
_, err = client.GetEntries(key)
if err == nil {
t.Fatalf("GetEntries(%q): expected error, got none", key)
}
t.Logf("GetEntries(%q): %v (OK)", key, err)
} | explode_data.jsonl/43880 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1082
} | [
2830,
3393,
52464,
1155,
353,
8840,
836,
8,
341,
53183,
1669,
2643,
64883,
445,
1348,
6484,
16058,
1138,
743,
10789,
621,
1591,
341,
197,
3244,
57776,
445,
1348,
6484,
16058,
537,
738,
26,
42659,
17590,
1273,
1138,
197,
630,
2405,
2399,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInfoKeysToLabelKeys(t *testing.T) {
tests := []struct {
name string
infoKeys []interface{}
want []*wire.LabelKey
}{
{
"empty infoKeys",
[]interface{}{},
[]*wire.LabelKey{},
},
{
"empty string infoKey",
[]interface{}{""},
[]*wire.LabelKey{
&wire.LabelKey{
Key: "",
},
},
},
{
"non-empty string infoKey",
[]interface{}{"hello"},
[]*wire.LabelKey{
&wire.LabelKey{
Key: "hello",
},
},
},
{
"multiple element infoKey",
[]interface{}{"hello", "world"},
[]*wire.LabelKey{
&wire.LabelKey{
Key: "hello",
},
&wire.LabelKey{
Key: "world",
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := infoKeysToLabelKeys(tt.infoKeys)
if !reflect.DeepEqual(got, tt.want) {
t.Fatalf("Got:\n%s\nWant:\n%s", marshaled(got), marshaled(tt.want))
}
})
}
} | explode_data.jsonl/80878 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 465
} | [
2830,
3393,
1731,
8850,
1249,
2476,
8850,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
27043,
8850,
3056,
4970,
16094,
197,
50780,
257,
29838,
35531,
4679,
1592,
198,
197,
59403,
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... | 2 |
func TestLoadBalancedWebService_SerializedParameters(t *testing.T) {
var testLBWebServiceManifest = manifest.NewLoadBalancedWebService(&manifest.LoadBalancedWebServiceProps{
WorkloadProps: &manifest.WorkloadProps{
Name: "frontend",
Dockerfile: "frontend/Dockerfile",
},
Path: "frontend",
Port: 80,
})
testCases := map[string]struct {
mockDependencies func(ctrl *gomock.Controller, c *LoadBalancedWebService)
wantedParams string
wantedError error
}{
"unavailable template": {
mockDependencies: func(ctrl *gomock.Controller, c *LoadBalancedWebService) {
m := mocks.NewMockloadBalancedWebSvcReadParser(ctrl)
m.EXPECT().Parse(wkldParamsTemplatePath, gomock.Any(), gomock.Any()).Return(nil, errors.New("some error"))
c.wkld.parser = m
},
wantedParams: "",
wantedError: errors.New("some error"),
},
"render params template": {
mockDependencies: func(ctrl *gomock.Controller, c *LoadBalancedWebService) {
m := mocks.NewMockloadBalancedWebSvcReadParser(ctrl)
m.EXPECT().Parse(wkldParamsTemplatePath, gomock.Any(), gomock.Any()).Return(&template.Content{Buffer: bytes.NewBufferString("params")}, nil)
c.wkld.parser = m
},
wantedParams: "params",
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
// GIVEN
ctrl := gomock.NewController(t)
defer ctrl.Finish()
c := &LoadBalancedWebService{
wkld: &wkld{
name: aws.StringValue(testLBWebServiceManifest.Name),
env: testEnvName,
app: testAppName,
tc: testLBWebServiceManifest.TaskConfig,
rc: RuntimeConfig{
Image: &ECRImage{
RepoURL: testImageRepoURL,
ImageTag: testImageTag,
},
AdditionalTags: map[string]string{
"owner": "boss",
},
},
},
manifest: testLBWebServiceManifest,
}
tc.mockDependencies(ctrl, c)
// WHEN
params, err := c.SerializedParameters()
// THEN
require.Equal(t, tc.wantedError, err)
require.Equal(t, tc.wantedParams, params)
})
}
} | explode_data.jsonl/20404 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 868
} | [
2830,
3393,
5879,
37889,
4874,
94388,
1098,
67577,
9706,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
34068,
94388,
38495,
284,
14455,
7121,
5879,
37889,
4874,
94388,
2099,
42315,
13969,
37889,
4874,
94388,
5992,
515,
197,
197,
6776,
1078,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCustomer_DeleteContact(t *testing.T) {
key := "api key"
server, err := invdmockserver.New(204, nil, "json", true)
if err != nil {
t.Fatal(err)
}
defer server.Close()
conn := mockConnection(key, server)
customer := conn.NewCustomer()
contact := customer.NewContact()
contact.Id = int64(1234)
err = customer.DeleteContact(int64(1234))
if err != nil {
t.Fatal("Error occurred during deletion")
}
} | explode_data.jsonl/15018 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
12792,
57418,
8732,
1155,
353,
8840,
836,
8,
341,
23634,
1669,
330,
2068,
1376,
1837,
41057,
11,
1848,
1669,
1529,
13849,
1176,
4030,
7121,
7,
17,
15,
19,
11,
2092,
11,
330,
2236,
497,
830,
340,
743,
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 TestAccKeycloakOpenidClient_ClientTimeouts_basic(t *testing.T) {
realmName := "terraform-" + acctest.RandString(10)
clientId := "terraform-" + acctest.RandString(10)
offlineSessionIdleTimeout := "1800"
offlineSessionMaxLifespan := "1900"
sessionIdleTimeout := "2000"
sessionMaxLifespan := "2100"
resource.Test(t, resource.TestCase{
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckKeycloakOpenidClientDestroy(),
Steps: []resource.TestStep{
{
Config: testKeycloakOpenidClient_ClientTimeouts(realmName, clientId,
offlineSessionIdleTimeout, offlineSessionMaxLifespan, sessionIdleTimeout, sessionMaxLifespan),
Check: testAccCheckKeycloakOpenidClientExistsWithCorrectClientTimeouts("keycloak_openid_client.client",
offlineSessionIdleTimeout, offlineSessionMaxLifespan, sessionIdleTimeout, sessionMaxLifespan,
),
},
{
ResourceName: "keycloak_openid_client.client",
ImportState: true,
ImportStateVerify: true,
ImportStateIdPrefix: realmName + "/",
ImportStateVerifyIgnore: []string{"exclude_session_state_from_auth_response"},
},
},
})
} | explode_data.jsonl/52133 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 480
} | [
2830,
3393,
14603,
1592,
88751,
5002,
307,
2959,
46102,
7636,
82,
34729,
1155,
353,
8840,
836,
8,
341,
17200,
7673,
675,
1669,
330,
61385,
27651,
488,
1613,
67880,
2013,
437,
703,
7,
16,
15,
340,
25291,
764,
1669,
330,
61385,
27651,
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... | 1 |
func TestPriorityQueue_AddWithReversePriorityLessFunc(t *testing.T) {
objs := []runtime.Object{medPriorityPodInfo.Pod, highPriorityPodInfo.Pod}
q := NewTestQueueWithObjects(context.Background(), newDefaultQueueSort(), objs)
if err := q.Add(medPriorityPodInfo.Pod); err != nil {
t.Errorf("add failed: %v", err)
}
if err := q.Add(highPriorityPodInfo.Pod); err != nil {
t.Errorf("add failed: %v", err)
}
if p, err := q.Pop(); err != nil || p.Pod != highPriorityPodInfo.Pod {
t.Errorf("Expected: %v after Pop, but got: %v", highPriorityPodInfo.Pod.Name, p.Pod.Name)
}
if p, err := q.Pop(); err != nil || p.Pod != medPriorityPodInfo.Pod {
t.Errorf("Expected: %v after Pop, but got: %v", medPriorityPodInfo.Pod.Name, p.Pod.Name)
}
} | explode_data.jsonl/68183 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 291
} | [
2830,
3393,
20555,
7554,
21346,
2354,
45695,
20555,
27451,
9626,
1155,
353,
8840,
836,
8,
341,
22671,
82,
1669,
3056,
22255,
8348,
90,
2061,
20555,
23527,
1731,
88823,
11,
1550,
20555,
23527,
1731,
88823,
532,
18534,
1669,
1532,
2271,
755... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConnectionResetByPeerIsRetried(t *testing.T) {
count := 0
backoff := &testBackoffManager{}
req := &Request{
verb: "GET",
client: clientFunc(func(req *http.Request) (*http.Response, error) {
count++
if count >= 3 {
return &http.Response{
StatusCode: 200,
Body: ioutil.NopCloser(bytes.NewReader([]byte{})),
}, nil
}
return nil, &net.OpError{Err: syscall.ECONNRESET}
}),
backoffMgr: backoff,
}
// We expect two retries of "connection reset by peer" and the success.
_, err := req.Do().Raw()
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
// We have a sleep before each retry (including the initial one) and for
// every "retry-after" call - thus 5 together.
if len(backoff.sleeps) != 5 {
t.Errorf("Expected 5 retries, got: %d", len(backoff.sleeps))
}
} | explode_data.jsonl/13273 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
4526,
14828,
1359,
30888,
3872,
12020,
4487,
1155,
353,
8840,
836,
8,
341,
18032,
1669,
220,
15,
198,
77446,
1847,
1669,
609,
1944,
3707,
1847,
2043,
16094,
24395,
1669,
609,
1900,
515,
197,
197,
22328,
25,
330,
3806,
756,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestError(t *testing.T) {
state := lua.NewState()
defer state.Close()
std.Open(state)
tmpTable := make(map[interface{}]interface{})
tmpTable["key"] = "value"
v := lua.ValueOf(state, tmpTable)
err := Map(v, 1)
if err.Error() != "result must be a pointer" {
t.Error("invalid error message")
}
var person testPerson
err = Map(lua.ValueOf(state, []string{"hello"}), &person)
if err.Error() != "arguments #1 must be a table, but got an array" {
fmt.Println(err.Error())
t.Error("invalid error message")
}
} | explode_data.jsonl/79579 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
1454,
1155,
353,
8840,
836,
8,
341,
24291,
1669,
20357,
7121,
1397,
741,
16867,
1584,
10421,
741,
6736,
12953,
8390,
692,
20082,
2556,
1669,
1281,
9147,
58,
4970,
78134,
4970,
37790,
20082,
2556,
1183,
792,
1341,
284,
330,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDescribe(t *testing.T) {
framework.NewTest(t).Features("usability.observability.describe").
RequiresSingleCluster().
Run(func(t framework.TestContext) {
deployment := file.AsStringOrFail(t, "testdata/a.yaml")
t.Config().ApplyYAMLOrFail(t, apps.Namespace.Name(), deployment)
istioCtl := istioctl.NewOrFail(t, t, istioctl.Config{})
// When this test passed the namespace through --namespace it was flakey
// because istioctl uses a global variable for namespace, and this test may
// run in parallel.
retry.UntilSuccessOrFail(t, func() error {
args := []string{
"--namespace=dummy",
"x", "describe", "svc", fmt.Sprintf("%s.%s", common.PodASvc, apps.Namespace.Name()),
}
output, _, err := istioCtl.Invoke(args)
if err != nil {
return err
}
if !describeSvcAOutput.MatchString(output) {
return fmt.Errorf("output:\n%v\n does not match regex:\n%v", output, describeSvcAOutput)
}
return nil
}, retry.Timeout(time.Second*20))
retry.UntilSuccessOrFail(t, func() error {
podID, err := getPodID(apps.PodA[0])
if err != nil {
return fmt.Errorf("could not get Pod ID: %v", err)
}
args := []string{
"--namespace=dummy",
"x", "describe", "pod", fmt.Sprintf("%s.%s", podID, apps.Namespace.Name()),
}
output, _, err := istioCtl.Invoke(args)
if err != nil {
return err
}
if !describePodAOutput.MatchString(output) {
return fmt.Errorf("output:\n%v\n does not match regex:\n%v", output, describePodAOutput)
}
return nil
}, retry.Timeout(time.Second*20))
})
} | explode_data.jsonl/57532 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 689
} | [
2830,
3393,
74785,
1155,
353,
8840,
836,
8,
341,
1166,
5794,
7121,
2271,
1155,
568,
21336,
445,
355,
2897,
13,
22764,
2897,
41965,
38609,
197,
197,
46961,
10888,
28678,
25829,
197,
85952,
18552,
1155,
12626,
8787,
1972,
8,
341,
298,
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 TestValidateActionProxy(t *testing.T) {
upstreamNames := map[string]sets.Empty{
"upstream1": {},
}
path := "/path"
actionProxy := &v1.ActionProxy{
Upstream: "upstream1",
RewritePath: "/test",
}
allErrs := validateActionProxy(actionProxy, field.NewPath("proxy"), upstreamNames, path, false)
if len(allErrs) != 0 {
t.Errorf("validateActionProxy(%+v, %v, %v) returned errors for valid input: %v", actionProxy, upstreamNames, path, allErrs)
}
} | explode_data.jsonl/65894 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
17926,
2512,
16219,
1155,
353,
8840,
836,
8,
341,
59810,
4027,
7980,
1669,
2415,
14032,
60,
4917,
11180,
515,
197,
197,
1,
454,
4027,
16,
788,
14573,
197,
532,
26781,
1669,
3521,
2343,
698,
38933,
16219,
1669,
609,
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 TestShellquote(t *testing.T) {
tables := []struct {
input string
expect string
}{
{"pipo", "pipo"},
{"i''i", "i'\\'''\\''i"},
{"'pipo'", "'\\''pipo'\\''"},
}
for _, table := range tables {
str := Shellquote(table.input)
if str != table.expect {
t.Errorf("Shellquote error, got: %s, want: %s.", str, table.expect)
}
}
} | explode_data.jsonl/35245 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
25287,
2949,
1155,
353,
8840,
836,
8,
341,
262,
12632,
1669,
3056,
1235,
341,
286,
1946,
914,
198,
286,
1720,
914,
198,
262,
335,
515,
286,
5212,
79,
6943,
497,
330,
79,
6943,
7115,
286,
5212,
72,
4605,
72,
497,
330,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScrollIntoView(t *testing.T) {
t.Parallel()
ctx, cancel := testAllocate(t, "image.html")
defer cancel()
tests := []struct {
sel string
by QueryOption
}{
{`/html/body/img`, BySearch},
{`img`, ByQueryAll},
{`img`, ByQuery},
{`#icon-github`, ByID},
{`document.querySelector('#icon-github')`, ByJSPath},
}
for i, test := range tests {
if err := Run(ctx, ScrollIntoView(test.sel, test.by)); err != nil {
t.Fatalf("test %d got error: %v", i, err)
}
// TODO test scroll event
}
} | explode_data.jsonl/59492 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
8425,
26591,
851,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
11,
9121,
1669,
1273,
75380,
1155,
11,
330,
1805,
2564,
1138,
16867,
9121,
2822,
78216,
1669,
3056,
1235,
341,
197,
1903,
301,
914,
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... | 3 |
func TestZipkinExporter_roundtripJSON(t *testing.T) {
buf := new(bytes.Buffer)
var sizes []int64
cst := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
s, _ := io.Copy(buf, r.Body)
sizes = append(sizes, s)
r.Body.Close()
}))
defer cst.Close()
config := &Config{
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: cst.URL,
},
Format: "json",
}
zexp, err := NewFactory().CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, config)
assert.NoError(t, err)
require.NotNil(t, zexp)
// The test requires the spans from zipkinSpansJSONJavaLibrary to be sent in a single batch, use
// a mock to ensure that this happens as intended.
mzr := newMockZipkinReporter(cst.URL)
// Run the Zipkin receiver to "receive spans upload from a client application"
addr := testutil.GetAvailableLocalAddress(t)
cfg := &zipkinreceiver.Config{
ReceiverSettings: config2.ReceiverSettings{
NameVal: "zipkin_receiver",
},
HTTPServerSettings: confighttp.HTTPServerSettings{
Endpoint: addr,
},
}
zi, err := zipkinreceiver.New(cfg, zexp)
assert.NoError(t, err)
require.NotNil(t, zi)
require.NoError(t, zi.Start(context.Background(), componenttest.NewNopHost()))
defer zi.Shutdown(context.Background())
// Let the receiver receive "uploaded Zipkin spans from a Java client application"
req, _ := http.NewRequest("POST", "https://tld.org/", strings.NewReader(zipkinSpansJSONJavaLibrary))
responseWriter := httptest.NewRecorder()
zi.ServeHTTP(responseWriter, req)
// Use the mock zipkin reporter to ensure all expected spans in a single batch. Since Flush waits for
// server response there is no need for further synchronization.
require.NoError(t, mzr.Flush())
// We expect back the exact JSON that was received
wants := []string{`
[{
"traceId": "4d1e00c0db9010db86154a4ba6e91385","parentId": "86154a4ba6e91385","id": "4d1e00c0db9010db",
"kind": "CLIENT","name": "get",
"timestamp": 1472470996199000,"duration": 207000,
"localEndpoint": {"serviceName": "frontend","ipv6": "7::80:807f"},
"remoteEndpoint": {"serviceName": "backend","ipv4": "192.168.99.101","port": 9000},
"annotations": [
{"timestamp": 1472470996238000,"value": "foo"},
{"timestamp": 1472470996403000,"value": "bar"}
],
"tags": {"http.path": "/api","clnt/finagle.version": "6.45.0"}
},
{
"traceId": "4d1e00c0db9010db86154a4ba6e91385","parentId": "86154a4ba6e91386","id": "4d1e00c0db9010dc",
"kind": "SERVER","name": "put",
"timestamp": 1472470996199000,"duration": 207000,
"localEndpoint": {"serviceName": "frontend","ipv6": "7::80:807f"},
"remoteEndpoint": {"serviceName": "frontend", "ipv4": "192.168.99.101","port": 9000},
"annotations": [
{"timestamp": 1472470996238000,"value": "foo"},
{"timestamp": 1472470996403000,"value": "bar"}
],
"tags": {"http.path": "/api","clnt/finagle.version": "6.45.0"}
},
{
"traceId": "4d1e00c0db9010db86154a4ba6e91385",
"parentId": "86154a4ba6e91386",
"id": "4d1e00c0db9010dd",
"kind": "SERVER",
"name": "put",
"timestamp": 1472470996199000,
"duration": 207000
}]
`}
for i, s := range wants {
want := unmarshalZipkinSpanArrayToMap(t, s)
gotBytes := buf.Next(int(sizes[i]))
got := unmarshalZipkinSpanArrayToMap(t, string(gotBytes))
for id, expected := range want {
actual, ok := got[id]
assert.True(t, ok)
assert.Equal(t, expected.ID, actual.ID)
assert.Equal(t, expected.Name, actual.Name)
assert.Equal(t, expected.TraceID, actual.TraceID)
assert.Equal(t, expected.Timestamp, actual.Timestamp)
assert.Equal(t, expected.Duration, actual.Duration)
assert.Equal(t, expected.Kind, actual.Kind)
}
}
} | explode_data.jsonl/33050 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1517
} | [
2830,
3393,
31047,
7989,
88025,
29896,
32981,
5370,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
501,
23158,
22622,
340,
2405,
12282,
3056,
396,
21,
19,
198,
1444,
267,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrimitiveTypes(t *testing.T) {
type Prims struct {
f float64
t time.Time
}
testJsonFromStruct(t, Prims{}, `{
"swagger.Prims": {
"id": "swagger.Prims",
"required": [
"f",
"t"
],
"properties": {
"f": {
"type": "number",
"description": "",
"format": "double"
},
"t": {
"type": "string",
"description": "",
"format": "date-time"
}
}
}
}`)
} | explode_data.jsonl/39919 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
33313,
4173,
1155,
353,
8840,
836,
8,
341,
13158,
2340,
5742,
2036,
341,
197,
1166,
2224,
21,
19,
198,
197,
3244,
882,
16299,
198,
197,
532,
18185,
5014,
3830,
9422,
1155,
11,
2340,
5742,
22655,
1565,
515,
220,
330,
74755,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUntar(t *testing.T) {
testdir, err := ioutil.TempDir("", "test-untar")
require.NoError(t, err)
defer os.RemoveAll(testdir)
t.Logf("Test base: %s", testdir)
basedir := filepath.Join(testdir, "base")
files := []testFile{{
// Absolute file within dest
path: filepath.Join(basedir, "abs"),
expected: filepath.Join(basedir, basedir, "abs"),
}, { // Absolute file outside dest
path: filepath.Join(testdir, "abs-out"),
expected: filepath.Join(basedir, testdir, "abs-out"),
}, { // Absolute nested file within dest
path: filepath.Join(basedir, "nested/nest-abs"),
expected: filepath.Join(basedir, basedir, "nested/nest-abs"),
}, { // Absolute nested file outside dest
path: filepath.Join(basedir, "nested/../../nest-abs-out"),
expected: filepath.Join(basedir, testdir, "nest-abs-out"),
}, { // Relative file inside dest
path: "relative",
expected: filepath.Join(basedir, "relative"),
}, { // Relative file outside dest
path: "../unrelative",
expected: "",
}, { // Nested relative file inside dest
path: "nested/nest-rel",
expected: filepath.Join(basedir, "nested/nest-rel"),
}, { // Nested relative file outside dest
path: "nested/../../nest-unrelative",
expected: "",
}}
mkExpectation := func(expected, suffix string) string {
if expected == "" {
return ""
}
return expected + suffix
}
links := []testFile{}
for _, f := range files {
links = append(links, testFile{
path: f.path + "-innerlink",
linkTarget: "link-target",
expected: mkExpectation(f.expected, "-innerlink"),
}, testFile{
path: f.path + "-innerlink-abs",
linkTarget: filepath.Join(basedir, "link-target"),
expected: mkExpectation(f.expected, "-innerlink-abs"),
}, testFile{
path: f.path + "-backlink",
linkTarget: filepath.Join("..", "link-target"),
expected: mkExpectation(f.expected, "-backlink"),
}, testFile{
path: f.path + "-outerlink-abs",
linkTarget: filepath.Join(testdir, "link-target"),
expected: mkExpectation(f.expected, "-outerlink-abs"),
})
if f.expected != "" {
// outerlink is the number of backticks to escape to testdir
outerlink, _ := filepath.Rel(f.expected, testdir)
links = append(links, testFile{
path: f.path + "-outerlink",
linkTarget: filepath.Join(outerlink, "link-target"),
expected: mkExpectation(f.expected, "-outerlink"),
})
}
}
files = append(files, links...)
// Test back-tick escaping through a symlink.
files = append(files,
testFile{
path: "nested/again/back-link",
linkTarget: "../../nested",
expected: filepath.Join(basedir, "nested/again/back-link"),
},
testFile{
path: "nested/again/back-link/../../../back-link-file",
expected: filepath.Join(basedir, "back-link-file"),
})
// Test chaining back-tick symlinks.
files = append(files,
testFile{
path: "nested/back-link-first",
linkTarget: "../",
expected: filepath.Join(basedir, "nested/back-link-first"),
},
testFile{
path: "nested/back-link-second",
linkTarget: "back-link-first/..",
expected: filepath.Join(basedir, "nested/back-link-second"),
})
files = append(files,
testFile{ // Relative directory path with terminating /
path: "direct/dir/",
expected: "",
})
buf := makeTestTar(t, files)
// Capture warnings to stderr for debugging.
output := (*testWriter)(t)
opts := NewCopyOptions(genericclioptions.IOStreams{In: &bytes.Buffer{}, Out: output, ErrOut: output})
require.NoError(t, opts.untarAll(buf, filepath.Join(basedir), ""))
expectations := map[string]bool{}
for _, f := range files {
if f.expected != "" {
expectations[f.expected] = false
}
}
filepath.Walk(testdir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil // Ignore directories.
}
if _, ok := expectations[path]; !ok {
t.Errorf("Unexpected file at %s", path)
} else {
expectations[path] = true
}
return nil
})
for path, found := range expectations {
if !found {
t.Errorf("Missing expected file %s", path)
}
}
} | explode_data.jsonl/58295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1660
} | [
2830,
3393,
20250,
277,
1155,
353,
8840,
836,
8,
341,
18185,
3741,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
1944,
12,
3850,
277,
1138,
17957,
35699,
1155,
11,
1848,
340,
16867,
2643,
84427,
8623,
3741,
340,
3244,
98954,
445,
2271... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStoryServiceGetMostViewsStories(t *testing.T) {
testCases := map[string]struct {
input func() (int, int, store.StoriesStore)
expectedResult func() []model.Story
expectedError error
}{
"test get most viewed story success": {
input: func() (int, int, store.StoriesStore) {
str, err := model.NewStoryBuilder().
SetTitle(100, "title").
SetBody(100, "test body").
Build()
require.NoError(t, err)
str.ID = "2eaa0697-2572-47f9-bcff-0bdf0c7c6432"
mst := &store.MockStoriesStore{}
mst.On("GetMostViewsStories", 0, 1).Return([]model.Story{*str}, nil)
return 0, 1, mst
},
expectedResult: func() []model.Story {
str, err := model.NewStoryBuilder().
SetTitle(100, "title").
SetBody(100, "test body").
Build()
require.NoError(t, err)
str.ID = "2eaa0697-2572-47f9-bcff-0bdf0c7c6432"
return []model.Story{*str}
},
},
"test get most viewed story failure": {
input: func() (int, int, store.StoriesStore) {
mst := &store.MockStoriesStore{}
mst.On("GetMostViewsStories", 0, 1).Return([]model.Story{}, liberr.WithArgs(liberr.SeverityError, errors.New("failed to get most viewed story")))
return 0, 1, mst
},
expectedResult: func() []model.Story {
return nil
},
expectedError: errors.New("failed to get most viewed story"),
},
}
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
o, l, st := testCase.input()
svc := service.NewStoriesService(st)
res, err := svc.GetMostViewsStories(o, l)
if testCase.expectedError != nil {
assert.Equal(t, testCase.expectedError.Error(), err.Error())
} else {
assert.Nil(t, err)
}
assert.Equal(t, testCase.expectedResult(), res)
})
}
} | explode_data.jsonl/44024 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 766
} | [
2830,
3393,
17938,
1860,
1949,
13319,
23217,
92431,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
22427,
688,
2915,
368,
320,
396,
11,
526,
11,
3553,
7758,
2433,
6093,
340,
197,
42400,
2077,
2915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResourceDuration(t *testing.T) {
assert.Equal(t, ResourceDuration(1), NewResourceDuration(1*time.Second))
assert.Equal(t, "1s", NewResourceDuration(1*time.Second).String())
} | explode_data.jsonl/26042 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
4783,
12945,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
11765,
12945,
7,
16,
701,
1532,
4783,
12945,
7,
16,
77053,
32435,
1171,
6948,
12808,
1155,
11,
330,
16,
82,
497,
1532,
4783,
12945,
7,
16,
77053,
32435,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClient_WithdrawFromSpecifiedContractAddress(t *testing.T) {
t.Parallel()
app, cleanup := setupWithdrawalsApplication(t)
defer cleanup()
require.NoError(t, app.StartAndConnect())
client, _ := app.NewClientAndRenderer()
cliParserRouter := cmd.NewApp(client)
app.EthMock.Context("manager.CreateTx#1", func(ethMock *cltest.EthMock) {
ethMock.Register("eth_call", "0xDE0B6B3A7640000")
ethMock.Register("eth_sendRawTransaction", cltest.NewHash())
})
assert.Nil(t, cliParserRouter.Run([]string{
"chainlink", "admin", "withdraw",
"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF", "1234",
"--from=" +
"0x3141592653589793238462643383279502884197"}))
} | explode_data.jsonl/78854 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 277
} | [
2830,
3393,
2959,
62,
92261,
3830,
8327,
1870,
14067,
4286,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
28236,
11,
21290,
1669,
6505,
92261,
1127,
4988,
1155,
340,
16867,
21290,
741,
17957,
35699,
1155,
11,
906,
12101,
3036,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadFormatV1(t *testing.T) {
c := NewMemChunk(EncGZIP, testBlockSize, testTargetSize)
fillChunk(c)
// overrides default v2 format
c.format = chunkFormatV1
b, err := c.Bytes()
if err != nil {
t.Fatal(err)
}
r, err := NewByteChunk(b, testBlockSize, testTargetSize)
if err != nil {
t.Fatal(err)
}
it, err := r.Iterator(context.Background(), time.Unix(0, 0), time.Unix(0, math.MaxInt64), logproto.FORWARD, nil, logql.NoopPipeline)
if err != nil {
t.Fatal(err)
}
i := int64(0)
for it.Next() {
require.Equal(t, i, it.Entry().Timestamp.UnixNano())
require.Equal(t, testdata.LogString(i), it.Entry().Line)
i++
}
} | explode_data.jsonl/15697 | {
"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,
4418,
4061,
53,
16,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
18816,
28304,
7,
7408,
38,
61585,
11,
1273,
89932,
11,
1273,
6397,
1695,
340,
65848,
28304,
1337,
340,
197,
322,
35455,
1638,
348,
17,
3561,
198,
1444,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBucketHandler_CheckBuckets(t *testing.T) {
t.Run("Buckets exist", func(t *testing.T) {
// Given
g := gomega.NewGomegaWithT(t)
publicBucket := "public-bucket"
buckets := bucket.SystemBucketNames{
Private: "private-bucket",
Public: publicBucket,
}
cfg := bucket.Config{
Region: "region",
}
minioCli := &automock.BucketClient{}
handler := bucket.NewHandler(minioCli, cfg)
minioCli.On("BucketExists", buckets.Private).Return(true, nil).Once()
minioCli.On("BucketExists", buckets.Public).Return(true, nil).Once()
minioCli.On("SetBucketPolicy", publicBucket, mock.MatchedBy(func(policy string) bool { return true })).Return(nil).Once()
defer minioCli.AssertExpectations(t)
// When
err := handler.CheckBuckets(buckets)
// Then
g.Expect(err).NotTo(gomega.HaveOccurred())
})
t.Run("Create buckets", func(t *testing.T) {
// Given
g := gomega.NewGomegaWithT(t)
publicBucket := "public-bucket"
buckets := bucket.SystemBucketNames{
Private: "private-bucket",
Public: publicBucket,
}
region := "region"
cfg := bucket.Config{
Region: region,
}
minioCli := &automock.BucketClient{}
handler := bucket.NewHandler(minioCli, cfg)
minioCli.On("BucketExists", buckets.Private).Return(false, nil).Once()
minioCli.On("MakeBucket", buckets.Private, region).Return(nil).Once()
minioCli.On("BucketExists", buckets.Public).Return(false, nil).Once()
minioCli.On("MakeBucket", buckets.Public, region).Return(nil).Once()
minioCli.On("SetBucketPolicy", publicBucket, mock.MatchedBy(func(policy string) bool { return true })).Return(nil).Once()
defer minioCli.AssertExpectations(t)
// When
err := handler.CheckBuckets(buckets)
// Then
g.Expect(err).NotTo(gomega.HaveOccurred())
})
t.Run("Checking private bucket error", func(t *testing.T) {
// Given
g := gomega.NewGomegaWithT(t)
buckets := bucket.SystemBucketNames{
Private: "private-bucket",
Public: "public-bucket",
}
cfg := bucket.Config{
Region: "region",
}
minioCli := &automock.BucketClient{}
handler := bucket.NewHandler(minioCli, cfg)
minioCli.On("BucketExists", buckets.Private).Return(false, errors.New("test error")).Once()
defer minioCli.AssertExpectations(t)
// When
err := handler.CheckBuckets(buckets)
// Then
g.Expect(err).To(gomega.HaveOccurred())
})
t.Run("Checking public bucket error", func(t *testing.T) {
// Given
g := gomega.NewGomegaWithT(t)
buckets := bucket.SystemBucketNames{
Private: "public-bucket",
Public: "private-bucket",
}
cfg := bucket.Config{
Region: "region",
}
minioCli := &automock.BucketClient{}
handler := bucket.NewHandler(minioCli, cfg)
minioCli.On("BucketExists", buckets.Private).Return(true, nil).Once()
minioCli.On("BucketExists", buckets.Public).Return(false, errors.New("test error")).Once()
defer minioCli.AssertExpectations(t)
// When
err := handler.CheckBuckets(buckets)
// Then
g.Expect(err).To(gomega.HaveOccurred())
})
} | explode_data.jsonl/67220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1227
} | [
2830,
3393,
36018,
3050,
28188,
33,
38551,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
33,
38551,
3000,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
197,
322,
16246,
198,
197,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAPIReposGitCommitListPage2Empty(t *testing.T) {
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
// Login as User2.
session := loginUser(t, user.Name)
token := getTokenForLoggedInUser(t, session)
// Test getting commits (Page=2)
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/commits?token="+token+"&page=2", user.Name)
resp := session.MakeRequest(t, req, http.StatusOK)
var apiData []api.Commit
DecodeJSON(t, resp, &apiData)
assert.Equal(t, 0, len(apiData))
} | explode_data.jsonl/2219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 221
} | [
2830,
3393,
7082,
693,
966,
46562,
33441,
852,
2665,
17,
3522,
1155,
353,
8840,
836,
8,
341,
16867,
10549,
2271,
14359,
1155,
8,
741,
19060,
1669,
4119,
11711,
15575,
3036,
5879,
10437,
1155,
11,
609,
6507,
7344,
90,
915,
25,
220,
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... | 1 |
func TestChunkFunction(t *testing.T) {
// Ensure start and end are correct, remembering end is for slicing, so it is the last index + 1
start, end := getVulnProcessingChunks(10, 0, 10)
if start != 0 || end != 10 {
t.Fatal("Incorrect index: ", start, end)
}
start, end = getVulnProcessingChunks(100, 1, 10)
if start != 10 || end != 20 {
t.Fatal("Incorrect index: ", start, end)
}
} | explode_data.jsonl/71411 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
28304,
5152,
1155,
353,
8840,
836,
8,
341,
197,
322,
29279,
1191,
323,
835,
525,
4396,
11,
47284,
835,
374,
369,
84915,
11,
773,
432,
374,
279,
1537,
1922,
488,
220,
16,
198,
21375,
11,
835,
1669,
633,
53,
360,
77,
288... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEvalTakesStructPC(t *testing.T) {
var values = strings.Split("a.PC.PD", ".")
var strNode = ArgNode{
value: "a.PC",
values: values,
valuesLen: len(values),
}
var pds = "pds"
var c = C{
D: "D",
PD: &pds,
}
var m = A{B: "B", C: C{D: "D"}, PC: &c}
var r, e = EvalTakes(strNode, m)
if e != nil {
t.Fatal(e)
}
fmt.Println(r)
} | explode_data.jsonl/52558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
54469,
51,
2050,
9422,
4872,
1155,
353,
8840,
836,
8,
341,
2405,
2750,
284,
9069,
19823,
445,
64,
1069,
34,
1069,
35,
497,
5933,
1138,
2405,
607,
1955,
284,
7638,
1955,
515,
197,
16309,
25,
257,
330,
64,
1069,
34,
756,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetServiceLoadBalancerStatus(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
az := GetTestCloud(ctrl)
service := getTestService("service1", v1.ProtocolTCP, nil, false, 80)
internalService := getInternalTestService("service1", 80)
setMockPublicIPs(az, ctrl, 1)
lb1 := getTestLoadBalancer(to.StringPtr("lb1"), to.StringPtr("rg"), to.StringPtr("testCluster"),
to.StringPtr("aservice1"), internalService, "Basic")
lb1.FrontendIPConfigurations = nil
lb2 := getTestLoadBalancer(to.StringPtr("lb2"), to.StringPtr("rg"), to.StringPtr("testCluster"),
to.StringPtr("aservice1"), internalService, "Basic")
lb2.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{
{
Name: to.StringPtr("aservice1"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.PublicIPAddress{ID: to.StringPtr("testCluster-aservice1")},
PrivateIPAddress: to.StringPtr("private"),
},
},
}
lb3 := getTestLoadBalancer(to.StringPtr("lb3"), to.StringPtr("rg"), to.StringPtr("testCluster"),
to.StringPtr("test1"), internalService, "Basic")
lb3.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{
{
Name: to.StringPtr("bservice1"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.PublicIPAddress{ID: to.StringPtr("testCluster-bservice1")},
PrivateIPAddress: to.StringPtr("private"),
},
},
}
lb4 := getTestLoadBalancer(to.StringPtr("lb4"), to.StringPtr("rg"), to.StringPtr("testCluster"),
to.StringPtr("aservice1"), service, "Basic")
lb4.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{
{
Name: to.StringPtr("aservice1"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.PublicIPAddress{ID: nil},
PrivateIPAddress: to.StringPtr("private"),
},
},
}
lb5 := getTestLoadBalancer(to.StringPtr("lb5"), to.StringPtr("rg"), to.StringPtr("testCluster"),
to.StringPtr("aservice1"), service, "Basic")
lb5.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{
{
Name: to.StringPtr("aservice1"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: nil,
PrivateIPAddress: to.StringPtr("private"),
},
},
}
lb6 := getTestLoadBalancer(to.StringPtr("lb6"), to.StringPtr("rg"), to.StringPtr("testCluster"),
to.StringPtr("aservice1"), service, "Basic")
lb6.FrontendIPConfigurations = &[]network.FrontendIPConfiguration{
{
Name: to.StringPtr("aservice1"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.PublicIPAddress{ID: to.StringPtr("illegal/id/")},
PrivateIPAddress: to.StringPtr("private"),
},
},
}
testCases := []struct {
desc string
service *v1.Service
lb *network.LoadBalancer
expectedStatus *v1.LoadBalancerStatus
expectedError bool
}{
{
desc: "getServiceLoadBalancer shall return nil if no lb is given",
service: &service,
lb: nil,
},
{
desc: "getServiceLoadBalancerStatus shall return nil if given lb has no front ip config",
service: &service,
lb: &lb1,
},
{
desc: "getServiceLoadBalancerStatus shall return private ip if service is internal",
service: &internalService,
lb: &lb2,
expectedStatus: &v1.LoadBalancerStatus{Ingress: []v1.LoadBalancerIngress{{IP: "private"}}},
},
{
desc: "getServiceLoadBalancerStatus shall return nil if lb.FrontendIPConfigurations.name != " +
"az.getFrontendIPConfigName(service)",
service: &internalService,
lb: &lb3,
},
{
desc: "getServiceLoadBalancerStatus shall report error if the id of lb's " +
"public ip address cannot be read",
service: &service,
lb: &lb4,
expectedError: true,
},
{
desc: "getServiceLoadBalancerStatus shall report error if lb's public ip address cannot be read",
service: &service,
lb: &lb5,
expectedError: true,
},
{
desc: "getServiceLoadBalancerStatus shall report error if id of lb's public ip address is illegal",
service: &service,
lb: &lb6,
expectedError: true,
},
{
desc: "getServiceLoadBalancerStatus shall return the corresponding " +
"lb status if everything is good",
service: &service,
lb: &lb2,
expectedStatus: &v1.LoadBalancerStatus{Ingress: []v1.LoadBalancerIngress{{IP: "1.2.3.4"}}},
},
}
for i, test := range testCases {
status, err := az.getServiceLoadBalancerStatus(test.service, test.lb)
assert.Equal(t, test.expectedStatus, status, "TestCase[%d]: %s", i, test.desc)
assert.Equal(t, test.expectedError, err != nil, "TestCase[%d]: %s", i, test.desc)
}
} | explode_data.jsonl/34004 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1913
} | [
2830,
3393,
1949,
1860,
5879,
93825,
2522,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
1370,
1669,
2126,
2271,
16055,
62100,
340,
52934,
1669,
633,
2271,
1860,
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... | 2 |
func TestHappyPath(t *testing.T) {
actual := []string{"c", "b", "a", "d"}
expected := []string{"a", "b", "c", "d"}
Sort(actual, func(i interface{}) string { return i.(string) })
assert.Equal(t, expected, actual)
} | explode_data.jsonl/70048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
32847,
1820,
1155,
353,
8840,
836,
8,
341,
88814,
1669,
3056,
917,
4913,
66,
497,
330,
65,
497,
330,
64,
497,
330,
67,
16707,
42400,
1669,
3056,
917,
4913,
64,
497,
330,
65,
497,
330,
66,
497,
330,
67,
16707,
7568,
371... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.