Skip to content

Commit e85b20d

Browse files
committed
test: Cover direct stream processor start
1 parent 45629a6 commit e85b20d

3 files changed

Lines changed: 46 additions & 10 deletions

File tree

.changelog/4683.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

internal/service/streamprocessor/resource.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ func (r *streamProcessorRS) Create(ctx context.Context, req resource.CreateReque
111111
if plan.Tier.ValueString() != "" {
112112
startWithOptions.SetTier(plan.Tier.ValueString())
113113
}
114-
// Autoscaling is persisted through the preceding Create request. Do not repeat
115-
// it in :startWith: that endpoint treats it as a new autoscaling modification.
116114
_, err := connV2.StreamsAPI.StartStreamProcessorWith(ctx, projectID, workspaceOrInstanceName, processorName, startWithOptions).Execute()
117115
if err != nil {
118116
resp.Diagnostics.AddError(errorCreateStart, err.Error())
@@ -241,8 +239,6 @@ func (r *streamProcessorRS) Update(ctx context.Context, req resource.UpdateReque
241239
if plan.Tier.ValueString() != "" {
242240
startWithOptions.SetTier(plan.Tier.ValueString())
243241
}
244-
// Autoscaling is persisted through the preceding PATCH request. Do not repeat
245-
// it in :startWith: that endpoint treats it as a new autoscaling modification.
246242
_, err := r.Client.AtlasV2.StreamsAPI.StartStreamProcessorWith(ctx, projectID, workspaceOrInstanceName, processorName, startWithOptions).Execute()
247243
if err != nil {
248244
resp.Diagnostics.AddError("Error starting stream processor", err.Error())

internal/service/streamprocessor/resource_test.go

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,27 @@ func TestAccStreamProcessor_withOptionsDLQAutoscaling(t *testing.T) {
138138
CheckDestroy: checkDestroyStreamProcessor,
139139
Steps: []resource.TestStep{
140140
{
141-
// Autoscaling is persisted by Create before the provider starts the
142-
// processor. The subsequent :startWith request does not repeat it.
143141
Config: configWithOptionsDLQAutoscaling(t, projectID, workspaceName, clusterName, processorName, streamProcessorOptionsConfig{
144142
includeDLQ: true,
145143
autoscalingMinTier: "SP10",
146144
autoscalingMaxTier: "SP50",
147-
state: streamprocessor.StartedState,
145+
state: streamprocessor.CreatedState,
148146
}),
149147
Check: resource.ComposeAggregateTestCheckFunc(
150148
resource.TestCheckResourceAttrSet(resourceName, "id"),
149+
resource.TestCheckResourceAttr(resourceName, "options.autoscaling.min_tier", "SP10"),
150+
resource.TestCheckResourceAttr(resourceName, "options.autoscaling.max_tier", "SP50"),
151+
resource.TestCheckResourceAttrSet(resourceName, "effective_tier"),
152+
),
153+
},
154+
{
155+
Config: configWithOptionsDLQAutoscaling(t, projectID, workspaceName, clusterName, processorName, streamProcessorOptionsConfig{
156+
includeDLQ: true,
157+
autoscalingMinTier: "SP10",
158+
autoscalingMaxTier: "SP50",
159+
state: streamprocessor.StartedState,
160+
}),
161+
Check: resource.ComposeAggregateTestCheckFunc(
151162
resource.TestCheckResourceAttr(resourceName, "state", streamprocessor.StartedState),
152163
resource.TestCheckResourceAttr(resourceName, "options.autoscaling.min_tier", "SP10"),
153164
resource.TestCheckResourceAttr(resourceName, "options.autoscaling.max_tier", "SP50"),
@@ -185,6 +196,38 @@ func TestAccStreamProcessor_withOptionsDLQAutoscaling(t *testing.T) {
185196
}})
186197
}
187198

199+
func TestAccStreamProcessor_withOptionsDLQAutoscalingCreateStarted(t *testing.T) {
200+
var (
201+
projectID, workspaceName = acc.ProjectIDExecutionWithStreamInstance(t)
202+
_, clusterName = acc.ClusterNameExecution(t, false)
203+
randomSuffix = acctest.RandString(5)
204+
processorName = "new-processor-autoscaling-started-" + randomSuffix
205+
)
206+
207+
resource.Test(t, resource.TestCase{
208+
PreCheck: func() { acc.PreCheckBasic(t) },
209+
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
210+
CheckDestroy: checkDestroyStreamProcessor,
211+
Steps: []resource.TestStep{
212+
{
213+
Config: configWithOptionsDLQAutoscaling(t, projectID, workspaceName, clusterName, processorName, streamProcessorOptionsConfig{
214+
includeDLQ: true,
215+
autoscalingMinTier: "SP10",
216+
autoscalingMaxTier: "SP50",
217+
state: streamprocessor.StartedState,
218+
}),
219+
Check: resource.ComposeAggregateTestCheckFunc(
220+
resource.TestCheckResourceAttrSet(resourceName, "id"),
221+
resource.TestCheckResourceAttr(resourceName, "state", streamprocessor.StartedState),
222+
resource.TestCheckResourceAttr(resourceName, "options.autoscaling.min_tier", "SP10"),
223+
resource.TestCheckResourceAttr(resourceName, "options.autoscaling.max_tier", "SP50"),
224+
resource.TestCheckResourceAttrSet(resourceName, "effective_tier"),
225+
),
226+
},
227+
importStep(),
228+
}})
229+
}
230+
188231
func basicTestCase(t *testing.T) *resource.TestCase {
189232
t.Helper()
190233
var (

0 commit comments

Comments
 (0)