dumpling: return error if init log file failed (#60801)
close pingcap/tidb#60689
This commit is contained in:
12
DEPS.bzl
12
DEPS.bzl
@ -5893,13 +5893,13 @@ def go_deps():
|
||||
name = "com_github_pingcap_log",
|
||||
build_file_proto_mode = "disable_global",
|
||||
importpath = "github.com/pingcap/log",
|
||||
sha256 = "ecdf624669a639a91f49a368f7090df11e9bff366f404fc8a379035fb4d9fe7f",
|
||||
strip_prefix = "github.com/pingcap/log@v1.1.1-0.20241212030209-7e3ff8601a2a",
|
||||
sha256 = "8c5ac751f87626274ace3b615ff7b88552eede51c58eddb6c1f0a7ba5b191c6e",
|
||||
strip_prefix = "github.com/pingcap/log@v1.1.1-0.20250424032633-85a82d016f84",
|
||||
urls = [
|
||||
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
|
||||
"http://ats.apps.svc/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
|
||||
"https://cache.hawkingrei.com/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
|
||||
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip",
|
||||
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
|
||||
"http://ats.apps.svc/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
|
||||
"https://cache.hawkingrei.com/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
|
||||
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip",
|
||||
],
|
||||
)
|
||||
go_repository(
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "log",
|
||||
@ -11,3 +11,12 @@ go_library(
|
||||
"@org_uber_go_zap//:zap",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "log_test",
|
||||
timeout = "short",
|
||||
srcs = ["log_test.go"],
|
||||
embed = [":log"],
|
||||
flaky = True,
|
||||
deps = ["@com_github_stretchr_testify//require"],
|
||||
)
|
||||
|
||||
41
dumpling/log/log_test.go
Normal file
41
dumpling/log/log_test.go
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2025 PingCAP, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package log
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestInitLogNoPermission(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
conf := &Config{
|
||||
Level: "debug",
|
||||
File: tmpDir + "/test.log",
|
||||
Format: "text",
|
||||
}
|
||||
|
||||
logger, _, err := InitAppLogger(conf)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, logger)
|
||||
|
||||
err = os.Chmod(tmpDir, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, _, err = InitAppLogger(conf)
|
||||
require.ErrorContains(t, err, "permission denied")
|
||||
}
|
||||
3
go.mod
3
go.mod
@ -89,7 +89,7 @@ require (
|
||||
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
|
||||
github.com/pingcap/fn v1.0.0
|
||||
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d
|
||||
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a
|
||||
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84
|
||||
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
|
||||
github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e
|
||||
github.com/pingcap/tipb v0.0.0-20250401143359-775c2379cbc7
|
||||
@ -336,4 +336,3 @@ replace (
|
||||
sourcegraph.com/sourcegraph/appdash => github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
|
||||
sourcegraph.com/sourcegraph/appdash-data => github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67
|
||||
)
|
||||
|
||||
|
||||
4
go.sum
4
go.sum
@ -685,8 +685,8 @@ github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d h1:52qhTQG8G8V/pHo
|
||||
github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
|
||||
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
|
||||
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a h1:WIhmJBlNGmnCWH6TLMdZfNEDaiU8cFpZe3iaqDbQ0M8=
|
||||
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA=
|
||||
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84 h1:ljnSbUq7LOkUtLtDXjTS5GanSWSAQ8pgVn7ucXMeMK8=
|
||||
github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA=
|
||||
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5 h1:T4pXRhBflzDeAhmOQHNPRRogMYxP13V7BkYw3ZsoSfE=
|
||||
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5/go.mod h1:rlimy0GcTvjiJqvD5mXTRr8O2eNZPBrcUgiWVYp9530=
|
||||
github.com/pingcap/tipb v0.0.0-20250401143359-775c2379cbc7 h1:iRRoPMrpj4jkIzhMT+yabc98bhGeUzAFSjh5HUOn5Yg=
|
||||
|
||||
Reference in New Issue
Block a user