Skip to content

feat: add all safe experiments to the deployment page #10276

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

Merged
merged 15 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added go test for new param
  • Loading branch information
Kira-Pilot committed Oct 16, 2023
commit 776356ef83153e996b39f296b26c8faf343d5846
22 changes: 22 additions & 0 deletions coderd/experiments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,26 @@ func Test_Experiments(t *testing.T) {
require.Error(t, err)
require.ErrorContains(t, err, httpmw.SignedOutErrorMessage)
})

t.Run("include_all query param", func(t *testing.T) {
t.Parallel()
cfg := coderdtest.DeploymentValues(t)
cfg.Experiments = []string{"foo", "BAR"}
codersdk.ExperimentsAll = []codersdk.Experiment{"bat", "fizz", "foo", "BAR"}
client := coderdtest.New(t, &coderdtest.Options{
DeploymentValues: cfg,
})
_ = coderdtest.CreateFirstUser(t, client)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

experiments, err := client.Experiments(ctx, codersdk.ExperimentOptions{IncludeAll: true})
require.NoError(t, err)
require.NotNil(t, experiments)
require.ElementsMatch(t, []codersdk.Experiment{"bat", "fizz", "foo", "BAR"}, experiments)

require.True(t, codersdk.Experiments{"foo", "BAR"}.Enabled("foo"))
require.True(t, codersdk.Experiments{"foo", "BAR"}.Enabled("BAR"))
})
}
3 changes: 2 additions & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2013,12 +2013,13 @@ var ExperimentsAll = Experiments{
ExperimentSingleTailnet,
}

// Experiments is a list of experiments that are enabled for the deployment.
// Experiments is a list of experiments.
// Multiple experiments may be enabled at the same time.
// Experiments are not safe for production use, and are not guaranteed to
// be backwards compatible. They may be removed or renamed at any time.
type Experiments []Experiment

// Returns a list of experiments that are enabled for the deployment.
func (e Experiments) Enabled(ex Experiment) bool {
for _, v := range e {
if v == ex {
Expand Down