-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add reporting config with reload (#16970)
Co-authored-by: Poonam Jadhav <[email protected]>
- Loading branch information
1 parent
de173e1
commit 177839e
Showing
14 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
//go:build !consulent | ||
// +build !consulent | ||
|
||
package agent | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAgent_consulConfig_Reporting(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("too slow for testing.Short") | ||
} | ||
|
||
t.Parallel() | ||
hcl := ` | ||
reporting { | ||
license { | ||
enabled = true | ||
} | ||
} | ||
` | ||
a := NewTestAgent(t, hcl) | ||
defer a.Shutdown() | ||
require.Equal(t, false, a.consulConfig().Reporting.License.Enabled) | ||
} | ||
|
||
func TestAgent_consulConfig_Reporting_Default(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("too slow for testing.Short") | ||
} | ||
|
||
t.Parallel() | ||
hcl := ` | ||
reporting { | ||
} | ||
` | ||
a := NewTestAgent(t, hcl) | ||
defer a.Shutdown() | ||
require.Equal(t, false, a.consulConfig().Reporting.License.Enabled) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//go:build !consulent | ||
// +build !consulent | ||
|
||
package consul | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/hashicorp/consul/testrpc" | ||
) | ||
|
||
func TestAgent_ReloadConfig_Reporting(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("too slow for testing.Short") | ||
} | ||
t.Parallel() | ||
|
||
dir1, s := testServerWithConfig(t, func(c *Config) { | ||
c.Reporting.License.Enabled = false | ||
}) | ||
defer os.RemoveAll(dir1) | ||
defer s.Shutdown() | ||
|
||
testrpc.WaitForTestAgent(t, s.RPC, "dc1") | ||
|
||
require.Equal(t, false, s.config.Reporting.License.Enabled) | ||
|
||
rc := ReloadableConfig{ | ||
Reporting: Reporting{ | ||
License: License{ | ||
Enabled: true, | ||
}, | ||
}, | ||
} | ||
|
||
require.NoError(t, s.ReloadConfig(rc)) | ||
|
||
// Check config reload is no-op | ||
require.Equal(t, false, s.config.Reporting.License.Enabled) | ||
} |