Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit b0f20e8

Browse files
Added test for bad config for task logs (#298)
1 parent 85c512e commit b0f20e8

2 files changed

Lines changed: 35 additions & 7 deletions

File tree

go/tasks/config_load_test.go

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ import (
44
"context"
55
"testing"
66

7-
"k8s.io/apimachinery/pkg/api/resource"
8-
9-
sagemakerConfig "github.com/flyteorg/flyteplugins/go/tasks/plugins/k8s/sagemaker/config"
10-
11-
"github.com/flyteorg/flytestdlib/config"
12-
"github.com/flyteorg/flytestdlib/config/viper"
137
"github.com/stretchr/testify/assert"
148
v1 "k8s.io/api/core/v1"
9+
"k8s.io/apimachinery/pkg/api/resource"
1510

1611
"github.com/flyteorg/flyteplugins/go/tasks/logs"
1712
flyteK8sConfig "github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/flytek8s/config"
13+
sagemakerConfig "github.com/flyteorg/flyteplugins/go/tasks/plugins/k8s/sagemaker/config"
1814
"github.com/flyteorg/flyteplugins/go/tasks/plugins/k8s/spark"
15+
"github.com/flyteorg/flytestdlib/config"
16+
"github.com/flyteorg/flytestdlib/config/viper"
1917
)
2018

2119
func TestLoadConfig(t *testing.T) {
@@ -26,7 +24,6 @@ func TestLoadConfig(t *testing.T) {
2624

2725
err := configAccessor.UpdateConfig(context.TODO())
2826
assert.NoError(t, err)
29-
3027
t.Run("k8s-config-test", func(t *testing.T) {
3128

3229
k8sConfig := flyteK8sConfig.GetK8sPluginConfig()
@@ -127,3 +124,27 @@ func TestLoadConfig(t *testing.T) {
127124
assert.NotNil(t, sagemakerConfig.GetSagemakerConfig())
128125
})
129126
}
127+
128+
func TestLoadIncorrectConfig(t *testing.T) {
129+
t.Run("logs-config-test-accept-bad-config", func(t *testing.T) {
130+
configAccessor := viper.NewAccessor(config.Options{
131+
StrictMode: false,
132+
SearchPaths: []string{"testdata/incorrect-config.yaml"},
133+
})
134+
135+
err := configAccessor.UpdateConfig(context.TODO())
136+
assert.NoError(t, err)
137+
assert.NotNil(t, logs.GetLogConfig())
138+
assert.True(t, logs.GetLogConfig().IsKubernetesEnabled)
139+
})
140+
141+
t.Run("logs-config-test-failfast", func(t *testing.T) {
142+
configAccessor := viper.NewAccessor(config.Options{
143+
StrictMode: true,
144+
SearchPaths: []string{"testdata/incorrect-config.yaml"},
145+
})
146+
147+
err := configAccessor.UpdateConfig(context.TODO())
148+
assert.Error(t, err)
149+
})
150+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Sample plugins config
2+
plugins:
3+
# Logging configuration
4+
logs:
5+
config:
6+
kubernetes-enabled: true
7+
kubernetes-url: "http://localhost:30082"

0 commit comments

Comments
 (0)