Skip to content

Commit 7839383

Browse files
GMHDBJDti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#60801
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 0e494be commit 7839383

File tree

5 files changed

+64
-9
lines changed

5 files changed

+64
-9
lines changed

DEPS.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5802,13 +5802,13 @@ def go_deps():
58025802
name = "com_github_pingcap_log",
58035803
build_file_proto_mode = "disable_global",
58045804
importpath = "github.com/pingcap/log",
5805-
sha256 = "ecdf624669a639a91f49a368f7090df11e9bff366f404fc8a379035fb4d9fe7f",
5806-
strip_prefix = "github.com/pingcap/[email protected].20241212030209-7e3ff8601a2a",
5805+
sha256 = "8c5ac751f87626274ace3b615ff7b88552eede51c58eddb6c1f0a7ba5b191c6e",
5806+
strip_prefix = "github.com/pingcap/[email protected].20250424032633-85a82d016f84",
58075807
urls = [
5808-
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
5809-
"http://ats.apps.svc/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
5810-
"https://cache.hawkingrei.com/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
5811-
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
5808+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
5809+
"http://ats.apps.svc/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
5810+
"https://cache.hawkingrei.com/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
5811+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
58125812
],
58135813
)
58145814
go_repository(

dumpling/log/BUILD.bazel

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library")
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
44
name = "log",
@@ -11,3 +11,12 @@ go_library(
1111
"@org_uber_go_zap//:zap",
1212
],
1313
)
14+
15+
go_test(
16+
name = "log_test",
17+
timeout = "short",
18+
srcs = ["log_test.go"],
19+
embed = [":log"],
20+
flaky = True,
21+
deps = ["@com_github_stretchr_testify//require"],
22+
)

dumpling/log/log_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2025 PingCAP, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package log
16+
17+
import (
18+
"os"
19+
"testing"
20+
21+
"github.com/stretchr/testify/require"
22+
)
23+
24+
func TestInitLogNoPermission(t *testing.T) {
25+
tmpDir := t.TempDir()
26+
conf := &Config{
27+
Level: "debug",
28+
File: tmpDir + "/test.log",
29+
Format: "text",
30+
}
31+
32+
logger, _, err := InitAppLogger(conf)
33+
require.NoError(t, err)
34+
require.NotNil(t, logger)
35+
36+
err = os.Chmod(tmpDir, 0)
37+
require.NoError(t, err)
38+
39+
_, _, err = InitAppLogger(conf)
40+
require.ErrorContains(t, err, "permission denied")
41+
}

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,13 @@ require (
8686
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122
8787
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
8888
github.com/pingcap/fn v1.0.0
89+
<<<<<<< HEAD
8990
github.com/pingcap/kvproto v0.0.0-20240924080114-4a3e17f5e62d
9091
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a
92+
=======
93+
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d
94+
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84
95+
>>>>>>> 47e8662e0c4 (dumpling: return error if init log file failed (#60801))
9196
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
9297
github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e
9398
github.com/pingcap/tipb v0.0.0-20241022082558-0607513e7fa4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,8 @@ github.com/pingcap/kvproto v0.0.0-20240924080114-4a3e17f5e62d h1:vSdKTrF6kpcd56G
676676
github.com/pingcap/kvproto v0.0.0-20240924080114-4a3e17f5e62d/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
677677
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
678678
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
679-
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a h1:WIhmJBlNGmnCWH6TLMdZfNEDaiU8cFpZe3iaqDbQ0M8=
680-
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA=
679+
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84 h1:ljnSbUq7LOkUtLtDXjTS5GanSWSAQ8pgVn7ucXMeMK8=
680+
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA=
681681
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5 h1:T4pXRhBflzDeAhmOQHNPRRogMYxP13V7BkYw3ZsoSfE=
682682
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5/go.mod h1:rlimy0GcTvjiJqvD5mXTRr8O2eNZPBrcUgiWVYp9530=
683683
github.com/pingcap/tipb v0.0.0-20241022082558-0607513e7fa4 h1:wvaUybJT0fUReCDcFtV3CEvMuI9iu+G7IW72tbSlil4=

0 commit comments

Comments
 (0)