Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to skip tests using Cloud Logging API #69

Merged
merged 7 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions internal/testflags/testflags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2025 Google LLC
//
// 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 testflags

import "flag"

// SkipCloudLogging is a flag of program arguments on testing. Unit tests using Cloud Logging APIs are skipped with this flag.
var SkipCloudLogging = flag.Bool("skip-cloud-logging", false, "skip tests that require cloud logging")
2 changes: 2 additions & 0 deletions pkg/common/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"

"github.com/GoogleCloudPlatform/khi/pkg/common"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

type testOnMemoryCacheItemStorageProvider struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/cache/gzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package cache
import (
"crypto/rand"
"testing"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestGZipCacheItemStorageProvider(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/cache/lru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"fmt"
"sync"
"testing"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestTouchKeyAndGetRemoved(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"sort" // Import the sort package

"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestDedupStringArray(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/concurrent_counter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"fmt"
"sync"
"testing"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestConcurrentCounter(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/errorreport/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"testing"

"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestCloudErrorReportWriterKeepWorkingWhenReporterFailsToWrite(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/flag/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"testing"

"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func setCommandlineArguments(t *testing.T, arguments []string) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/grouper/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"testing"

"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestBasicGrouper(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/httpclient/basic_http_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"net/http/httptest"
"testing"
"time"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

type mockHeaderProvider struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/httpclient/json_response_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"

"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

type mockHttpClient struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/httpclient/retry_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"time"

"github.com/GoogleCloudPlatform/khi/pkg/common/token"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

type mockFailClient struct {
Expand Down
6 changes: 5 additions & 1 deletion pkg/common/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package common

import "testing"
import (
"testing"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestNewUUID(t *testing.T) {
uuid1 := NewUUID()
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/parserutil/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"testing"

"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestStripSpecialSequences(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/sharding_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"sync"
"testing"
"time"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

const keyLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"fmt"
"testing"
"time"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestParseTime(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/token/multi_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package token
import (
"context"
"testing"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestMultiTokenResolver_Resolve(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/token/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"sync"
"testing"
"time"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestBasicTokenStore_GetType(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/token/token_refresher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"context"
"testing"
"time"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestNewMultiTokenStoreRefresher(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/token/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package token
import (
"testing"
"time"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestNew(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/common/task_registrer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/GoogleCloudPlatform/khi/pkg/inspection"
inspection_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/inspection"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestInspectionTasksAreResolvable(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/form/textform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
common_task "github.com/GoogleCloudPlatform/khi/pkg/task"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func generateFakeVariableSet(taskId string, value string) *common_task.VariableSet {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/inspectiondata/result_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/GoogleCloudPlatform/khi/pkg/testutil"
"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestFileSystemResultRepository(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/ioconfig/ioconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"testing"

task_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/task"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestTestIOConfigCanFindTheRoot(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (

"github.com/GoogleCloudPlatform/khi/pkg/task/taskid"
"github.com/GoogleCloudPlatform/khi/pkg/testutil"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestGlobalLoggerHandlerWithChildLogger(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/error/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"testing"

metadata_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/metadata"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestProgressConformance(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/form/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/GoogleCloudPlatform/khi/pkg/inspection/metadata"
metadata_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/metadata"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func newFormFieldsForConformanceTest() metadata.Metadata {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/form/form_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func fieldWithIdAndPriorityForTest(id string, priority int) FormField {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/header/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"testing"

metadata_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/metadata"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestConformance(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/GoogleCloudPlatform/khi/pkg/inspection/logger"
"github.com/GoogleCloudPlatform/khi/pkg/task/taskid"
metadata_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/metadata"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestConformance(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/logger/throttle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package logger

import (
"testing"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestConstantLogThrottle(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (

"github.com/GoogleCloudPlatform/khi/pkg/task"
"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

// Metadata test utility used from tests in another package
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/plan/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"testing"

metadata_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/metadata"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestConformance(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/progress/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/GoogleCloudPlatform/khi/pkg/inspection/metadata"
metadata_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/metadata"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func newProgressforConformanceTest() metadata.Metadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestIndeterminateUpdator(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/progress/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestGetTaskProgress(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/inspection/metadata/query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

metadata_test "github.com/GoogleCloudPlatform/khi/pkg/testutil/metadata"
"github.com/google/go-cmp/cmp"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestQueryConformance(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/log/cached_log_field_extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"time"

"github.com/GoogleCloudPlatform/khi/pkg/model/enum"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

type commonLogFieldExtractorStub struct {
Expand Down
4 changes: 4 additions & 0 deletions pkg/log/log_entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
// limitations under the License.

package log

import (
_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)
2 changes: 2 additions & 0 deletions pkg/log/structure/adapter/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"testing"

"github.com/GoogleCloudPlatform/khi/pkg/log/structure/structuredatastore"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestAnyAdapter(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/log/structure/adapter/direct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/GoogleCloudPlatform/khi/pkg/log/structure/structuredata"
"github.com/GoogleCloudPlatform/khi/pkg/log/structure/structuredatastore"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestDirectAdapter(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/log/structure/adapter/merge_yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/GoogleCloudPlatform/khi/pkg/log/structure/merger"
"github.com/GoogleCloudPlatform/khi/pkg/log/structure/structuredatastore"

_ "github.com/GoogleCloudPlatform/khi/internal/testflags"
)

func TestYamlMergeAdapterTest(t *testing.T) {
Expand Down
Loading
Loading