Skip to content

Commit 259f162

Browse files
committed
STAC-24149: ensure snapshot api compatibility
1 parent 1d04132 commit 259f162

File tree

133 files changed

+17795
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+17795
-439
lines changed

cmd/topology/topology_inspect.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ func RunInspectCommand(
8686
true,
8787
)
8888

89-
request := stackstate_api.NewSnapshotRequest(
89+
request := stackstate_api.NewViewSnapshotRequest(
9090
"SnapshotRequest",
9191
query,
9292
"0.0.1",
9393
*metadata,
9494
)
9595

9696
result, resp, err := api.SnapshotApi.QuerySnapshot(cli.Context).
97-
SnapshotRequest(*request).
97+
ViewSnapshotRequest(*request).
9898
Execute()
9999
if err != nil {
100100
return common.NewResponseError(err, resp)
@@ -104,7 +104,7 @@ func RunInspectCommand(
104104
components, parseErr := parseSnapshotResponse(result, cli.CurrentContext.URL)
105105
if parseErr != nil {
106106
// Check if the error is a typed error from the response by examining the _type discriminator
107-
if typedErr := handleSnapshotError(result.SnapshotResponse, resp); typedErr != nil {
107+
if typedErr := handleSnapshotError(result.ViewSnapshotResponse, resp); typedErr != nil {
108108
return typedErr
109109
}
110110
return common.NewExecutionError(parseErr)
@@ -219,7 +219,7 @@ func parseSnapshotResponse(
219219
baseURL string,
220220
) ([]Component, error) {
221221
// SnapshotResponse is already typed as map[string]interface{} from the generated API
222-
respMap := result.SnapshotResponse
222+
respMap := result.ViewSnapshotResponse
223223
if respMap == nil {
224224
return nil, fmt.Errorf("response data is nil")
225225
}

cmd/topology/topology_inspect_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func setInspectCmd(t *testing.T) (*di.MockDeps, *cobra.Command) {
2121
func mockSnapshotResponse() sts.QuerySnapshotResult {
2222
return sts.QuerySnapshotResult{
2323
Type: "QuerySnapshotResult",
24-
SnapshotResponse: map[string]interface{}{
24+
ViewSnapshotResponse: map[string]interface{}{
2525
"_type": "ViewSnapshot",
2626
"components": []interface{}{
2727
map[string]interface{}{
@@ -121,7 +121,7 @@ func TestTopologyInspectWithTags(t *testing.T) {
121121

122122
// Verify query contains both tags ANDed
123123
call := calls[0]
124-
request := call.PsnapshotRequest
124+
request := call.PviewSnapshotRequest
125125
expectedQuery := `type = "test type" AND label = "service.namespace:test" AND label = "service.name:myservice"`
126126
assert.Equal(t, expectedQuery, request.Query)
127127
}
@@ -141,7 +141,7 @@ func TestTopologyInspectWithIdentifiers(t *testing.T) {
141141

142142
// Verify query contains identifiers in IN clause
143143
call := calls[0]
144-
request := call.PsnapshotRequest
144+
request := call.PviewSnapshotRequest
145145
expectedQuery := `type = "test type" AND identifier IN ("urn:test:1", "urn:test:2")`
146146
assert.Equal(t, expectedQuery, request.Query)
147147
}
@@ -150,7 +150,7 @@ func TestTopologyInspectNoResults(t *testing.T) {
150150
cli, cmd := setInspectCmd(t)
151151
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
152152
Type: "QuerySnapshotResult",
153-
SnapshotResponse: map[string]interface{}{
153+
ViewSnapshotResponse: map[string]interface{}{
154154
"_type": "ViewSnapshot",
155155
"components": []interface{}{},
156156
"metadata": map[string]interface{}{
@@ -178,7 +178,7 @@ func TestTopologyInspectMultipleIdentifiers(t *testing.T) {
178178
cli, cmd := setInspectCmd(t)
179179
responseData := mockSnapshotResponse()
180180
// Modify to include multiple identifiers
181-
components := responseData.SnapshotResponse["components"].([]interface{})
181+
components := responseData.ViewSnapshotResponse["components"].([]interface{})
182182
comp := components[0].(map[string]interface{})
183183
comp["identifiers"] = []interface{}{"urn:test:1", "urn:test:2", "urn:test:3"}
184184
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = responseData
@@ -199,7 +199,7 @@ func TestTopologyInspectURLEncoding(t *testing.T) {
199199
cli, cmd := setInspectCmd(t)
200200
responseData := mockSnapshotResponse()
201201
// Set identifier with special characters
202-
components := responseData.SnapshotResponse["components"].([]interface{})
202+
components := responseData.ViewSnapshotResponse["components"].([]interface{})
203203
comp := components[0].(map[string]interface{})
204204
comp["identifiers"] = []interface{}{"urn:opentelemetry:namespace/service:component/name"}
205205
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = responseData
@@ -219,11 +219,11 @@ func TestTopologyInspectWithEnvironment(t *testing.T) {
219219
cli, cmd := setInspectCmd(t)
220220
responseData := mockSnapshotResponse()
221221
// Add environment to component
222-
components := responseData.SnapshotResponse["components"].([]interface{})
222+
components := responseData.ViewSnapshotResponse["components"].([]interface{})
223223
comp := components[0].(map[string]interface{})
224224
comp["environment"] = float64(123)
225225
// Add environment to metadata
226-
metadata := responseData.SnapshotResponse["metadata"].(map[string]interface{})
226+
metadata := responseData.ViewSnapshotResponse["metadata"].(map[string]interface{})
227227
metadata["environments"] = []interface{}{
228228
map[string]interface{}{
229229
"id": float64(123),
@@ -292,7 +292,7 @@ func TestTopologyInspectFetchTimeout(t *testing.T) {
292292
cli, cmd := setInspectCmd(t)
293293
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
294294
Type: "QuerySnapshotResult",
295-
SnapshotResponse: map[string]interface{}{
295+
ViewSnapshotResponse: map[string]interface{}{
296296
"_type": "ViewSnapshotFetchTimeout",
297297
"usedTimeoutSeconds": float64(30),
298298
},
@@ -310,7 +310,7 @@ func TestTopologyInspectTooManyActiveQueries(t *testing.T) {
310310
cli, cmd := setInspectCmd(t)
311311
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
312312
Type: "QuerySnapshotResult",
313-
SnapshotResponse: map[string]interface{}{
313+
ViewSnapshotResponse: map[string]interface{}{
314314
"_type": "ViewSnapshotTooManyActiveQueries",
315315
},
316316
}
@@ -327,7 +327,7 @@ func TestTopologyInspectTopologySizeOverflow(t *testing.T) {
327327
cli, cmd := setInspectCmd(t)
328328
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
329329
Type: "QuerySnapshotResult",
330-
SnapshotResponse: map[string]interface{}{
330+
ViewSnapshotResponse: map[string]interface{}{
331331
"_type": "ViewSnapshotTopologySizeOverflow",
332332
"maxSize": float64(10000),
333333
},
@@ -345,7 +345,7 @@ func TestTopologyInspectDataUnavailable(t *testing.T) {
345345
cli, cmd := setInspectCmd(t)
346346
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
347347
Type: "QuerySnapshotResult",
348-
SnapshotResponse: map[string]interface{}{
348+
ViewSnapshotResponse: map[string]interface{}{
349349
"_type": "ViewSnapshotDataUnavailable",
350350
"unavailableAtEpochMs": float64(1000000),
351351
"availableSinceEpochMs": float64(1609459200000),

0 commit comments

Comments
 (0)