-
Notifications
You must be signed in to change notification settings - Fork 1
Readonly Tests for OpenAPI #595
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
Open
celaus
wants to merge
18
commits into
master
Choose a base branch
from
CX-27502
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2eba8af
Add OpenAPI list/read tests
celaus 432bb5d
dockerfile
celaus e4e55d6
go.sum
celaus e3c91b0
rm ssh
celaus 4edb243
fixes
celaus d9fa885
code check
celaus 03f9322
tests
celaus f100ccc
tests
celaus d1392cf
urls
celaus 6a02da6
enable tests
celaus d00fd0b
rm protobuf lint
celaus 9456b0d
run tests openapi ro
celaus be62000
openapi ro test
celaus e730edc
fixed tests
celaus aaa39eb
lints
celaus 042e8aa
container build
celaus 9fb2b24
test fix
celaus fea77b6
test fix
celaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,31 @@ | ||
| name: "[Tools] Go Readonly Tests Image" | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [ master ] | ||
| paths: | ||
| - 'go/**' | ||
| - 'proto/**' | ||
| jobs: | ||
| build-example-image: | ||
| name: "[Tools] Build Go Readonly Tests Image" | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: docker/setup-buildx-action@v3 | ||
| - uses: aws-actions/configure-aws-credentials@v2 | ||
| with: | ||
| role-to-assume: ${{ vars.ECR_ROLE }} | ||
| aws-region: ${{ vars.DEFAULT_ECR_REGISTRY_REGION }} | ||
| - uses: aws-actions/amazon-ecr-login@v2 | ||
| - uses: docker/build-push-action@v6 | ||
| with: | ||
| platforms: linux/amd64,linux/arm64 | ||
| context: . | ||
| file: go/openapi/Dockerfile | ||
celaus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| push: true | ||
| tags: ${{ vars.DEFAULT_ECR_REGISTRY }}/go-readonly-tests:latest | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,42 @@ | ||
| # Copyright 2026 Coralogix Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ARG TARGETARCH | ||
| FROM golang:1.25-alpine AS interim | ||
| FROM interim AS interim-amd64 | ||
| ENV ARCH=x86_64 | ||
| FROM interim AS interim-arm64 | ||
| ENV ARCH=aarch_64 | ||
|
|
||
| FROM interim-${TARGETARCH} | ||
|
|
||
|
|
||
| RUN apk add --no-cache make && \ | ||
| go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \ | ||
| go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | ||
|
|
||
| # Set working directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy Makefile and required files | ||
| COPY ../ . | ||
| # Set environment variables | ||
| ENV CORALOGIX_REGION=us | ||
| ENV CORALOGIX_API_KEY=test_key | ||
|
|
||
| # Run tests using Makefile target | ||
| CMD ["make", "test-openapi-ro"] |
This file contains hidden or 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 hidden or 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,35 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" | ||
| ) | ||
|
|
||
| func TestActionsListRead(t *testing.T) { | ||
| cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() | ||
| client := cxsdk.NewActionsClient(cfg) | ||
|
|
||
| listResp, httpResp, err := client. | ||
| ActionsServiceListActions(context.Background()). | ||
| Execute() | ||
| require.NoError(t, cxsdk.NewAPIError(httpResp, err)) | ||
|
|
||
| if len(listResp.Actions) == 0 { | ||
| t.Skip("no resources to read") | ||
| } | ||
|
|
||
| actionID := listResp.Actions[0].GetId() | ||
| if actionID == "" { | ||
| t.Skip("no resources to read") | ||
| } | ||
|
|
||
| getResp, httpResp, err := client. | ||
| ActionsServiceGetAction(context.Background(), actionID). | ||
| Execute() | ||
| require.NoError(t, cxsdk.NewAPIError(httpResp, err)) | ||
| require.Equal(t, actionID, getResp.GetAction().Id) | ||
| } |
This file contains hidden or 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,35 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" | ||
| ) | ||
|
|
||
| func TestAlertsListRead(t *testing.T) { | ||
| cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() | ||
| client := cxsdk.NewAlertsClient(cfg) | ||
|
|
||
| listResp, httpResp, err := client. | ||
| AlertDefsServiceListAlertDefs(context.Background()). | ||
| Execute() | ||
| require.NoError(t, cxsdk.NewAPIError(httpResp, err)) | ||
|
|
||
| if len(listResp.AlertDefs) == 0 { | ||
| t.Skip("no resources to read") | ||
| } | ||
|
|
||
| alertID := listResp.AlertDefs[0].GetId() | ||
| if alertID == "" { | ||
| t.Skip("no resources to read") | ||
| } | ||
|
|
||
| getResp, httpResp, err := client. | ||
| AlertDefsServiceGetAlertDef(context.Background(), alertID). | ||
| Execute() | ||
| require.NoError(t, cxsdk.NewAPIError(httpResp, err)) | ||
| require.Equal(t, alertID, *getResp.GetAlertDef().Id) | ||
| } |
This file contains hidden or 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,35 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" | ||
| ) | ||
|
|
||
| func TestAPIKeysListRead(t *testing.T) { | ||
| cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() | ||
| client := cxsdk.NewAPIKeysClient(cfg) | ||
|
|
||
| listResp, httpResp, err := client. | ||
| ApiKeysServiceGetSendDataApiKeys(context.Background()). | ||
| Execute() | ||
| require.NoError(t, cxsdk.NewAPIError(httpResp, err)) | ||
|
|
||
| if len(listResp.Keys) == 0 { | ||
| t.Skip("no resources to read") | ||
| } | ||
|
|
||
| keyID := listResp.Keys[0].GetId() | ||
| if keyID == "" { | ||
| t.Skip("no resources to read") | ||
| } | ||
|
|
||
| getResp, httpResp, err := client. | ||
| ApiKeysServiceGetApiKey(context.Background(), keyID). | ||
| Execute() | ||
| require.NoError(t, cxsdk.NewAPIError(httpResp, err)) | ||
| require.Equal(t, keyID, *getResp.GetKeyInfo().Id) | ||
| } |
This file contains hidden or 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,35 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "context" | ||
| "reflect" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" | ||
| ) | ||
|
|
||
| func TestArchiveLogsListRead(t *testing.T) { | ||
| cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() | ||
| client := cxsdk.NewArchiveLogsClient(cfg) | ||
|
|
||
| listResp, httpResp, err := client. | ||
| S3TargetServiceGetTarget(context.Background()). | ||
| Execute() | ||
| require.NoError(t, cxsdk.NewAPIError(httpResp, err)) | ||
|
|
||
| listTarget := listResp.Target.GetActualInstance() | ||
| if listTarget == nil { | ||
| t.Skip("no resources to read") | ||
| } | ||
|
|
||
| getResp, httpResp, err := client. | ||
| S3TargetServiceGetTarget(context.Background()). | ||
| Execute() | ||
| require.NoError(t, cxsdk.NewAPIError(httpResp, err)) | ||
|
|
||
| getTarget := getResp.Target.GetActualInstance() | ||
| require.NotNil(t, getTarget) | ||
| require.Equal(t, reflect.TypeOf(listTarget), reflect.TypeOf(getTarget)) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.