Vikrant Gupta c322657666
feat(organization): schema changes for the organizations entity (#7684)
* feat(organization): add hname and alias for organization

* fix: boolean values are not shown in the list panel's column

* fix: moved logic to component level

* fix: added type

* fix: added test cases

* fix: added test cases

* chore: update copy webpack plugin

* Revert "fix: display same key with multiple data types in filter suggestions by enhancing the deduping logic (#7255)"

This reverts commit 1e85981a17a8e715e948308d3e85072d976907d3.

* fix: use query search v2 for traces data source to handle multiple data types for the same key

* fix(QueryBuilderSearchV2): add user typed option if it doesn't exist in the payload

* fix(QueryBuilderSearchV2): increase the height of search dropdown for non-logs data sources

* fix: display span scope selector for trace data source

* chore: remove the span scope selector from qb search v1 and move the component to search v2

* fix: write test to ensure that we display span scope selector for traces data source

* fix: limit converting  ->   only to log data source

* fix: don't display empty suggestion if only spaces are typed

* chore: tests for span scope selector

* chore: qb search flow (key, operator, value) test cases

* refactor: fix the Maximum update depth reached issue while running tests

* chore: overall improvements to span scope selector tests

Resource attr filter: style fix and quick filter changes (#7691)

* chore: resource attr filter init

* chore: resource attr filter api integration

* chore: operator config updated

* chore: fliter show hide logic and styles

* chore: add support for custom operator list to qb

* chore: minor refactor

* chore: minor code refactor

* test: quick filters test suite added

* test: quick filters test suite added

* test: all errors test suite added

* chore: style fix

* test: all errors mock fix

* chore: test case fix and mixpanel update

* chore: color update

* chore: minor refactor

* chore: style fix

* chore: set default query in exceptions tab

* chore: style fix

* chore: minor refactor

* chore: minor refactor

* chore: minor refactor

* chore: test update

* chore: fix filter header with no query name

* fix: scroll fix

* chore: add data source traces to quick filters

* chore: replace div with fragment

---------

Co-authored-by: Aditya Singh <adityasingh@Adityas-MacBook-Pro.local>

fix: handle rate operators for table panel (#7695)

* fix: handle rate operators for table panel

chore: fix error rate (#7701)

Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>

* feat(organization): minor cleanups

* feat(organization): better naming for api and usecase

* feat(organization): better packaging for modules

* feat(organization): change hname to displayName

* feat(organization): update the migration to use dialect

* feat(organization): update the migration to use dialect

* feat(organization): update the migration to use dialect

* feat(organization): revert back to impl

* feat(organization): remove DI from organization

* feat(organization): address review comments

* feat(organization): address review comments

* feat(organization): address review comments

---------

Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
2025-04-25 19:38:15 +05:30

231 lines
6.0 KiB
Go

package integrations
import (
"context"
"slices"
"testing"
"github.com/SigNoz/signoz/pkg/modules/organization"
"github.com/SigNoz/signoz/pkg/query-service/auth"
"github.com/SigNoz/signoz/pkg/query-service/constants"
"github.com/SigNoz/signoz/pkg/query-service/dao"
"github.com/SigNoz/signoz/pkg/query-service/model"
v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"
"github.com/SigNoz/signoz/pkg/query-service/utils"
"github.com/SigNoz/signoz/pkg/sqlstore"
"github.com/SigNoz/signoz/pkg/types"
"github.com/SigNoz/signoz/pkg/types/pipelinetypes"
ruletypes "github.com/SigNoz/signoz/pkg/types/ruletypes"
"github.com/google/uuid"
)
func NewTestIntegrationsManager(t *testing.T) (*Manager, sqlstore.SQLStore) {
testDB := utils.NewQueryServiceDBForTests(t)
installedIntegrationsRepo, err := NewInstalledIntegrationsSqliteRepo(testDB)
if err != nil {
t.Fatalf("could not init sqlite DB for installed integrations: %v", err)
}
return &Manager{
availableIntegrationsRepo: &TestAvailableIntegrationsRepo{},
installedIntegrationsRepo: installedIntegrationsRepo,
}, testDB
}
func createTestUser(organizationModule organization.Module) (*types.User, *model.ApiError) {
// Create a test user for auth
ctx := context.Background()
organization := types.NewOrganization("test")
err := organizationModule.Create(ctx, organization)
if err != nil {
return nil, model.InternalError(err)
}
group, apiErr := dao.DB().GetGroupByName(ctx, constants.AdminGroup)
if apiErr != nil {
return nil, model.InternalError(apiErr)
}
auth.InitAuthCache(ctx)
userId := uuid.NewString()
return dao.DB().CreateUser(
ctx,
&types.User{
ID: userId,
Name: "test",
Email: userId[:8] + "test@test.com",
Password: "test",
OrgID: organization.ID.StringValue(),
GroupID: group.ID,
},
true,
)
}
type TestAvailableIntegrationsRepo struct{}
func (t *TestAvailableIntegrationsRepo) list(
ctx context.Context,
) ([]IntegrationDetails, *model.ApiError) {
return []IntegrationDetails{
{
IntegrationSummary: IntegrationSummary{
Id: "test-integration-1",
Title: "Test Integration 1",
Description: "A test integration",
Author: IntegrationAuthor{
Name: "signoz",
Email: "integrations@signoz.io",
HomePage: "https://signoz.io",
},
Icon: `data:image/svg+xml;utf8,<svg ... > ... </svg>`,
},
Categories: []string{"testcat1", "testcat2"},
Overview: "test integration overview",
Configuration: []IntegrationConfigStep{
{
Title: "Step 1",
Instructions: "Set source attrib on your signals",
},
},
DataCollected: DataCollectedForIntegration{
Logs: []CollectedLogAttribute{},
Metrics: []CollectedMetric{},
},
Assets: IntegrationAssets{
Logs: LogsAssets{
Pipelines: []pipelinetypes.PostablePipeline{
{
Name: "pipeline1",
Alias: "pipeline1",
Enabled: true,
Filter: &v3.FilterSet{
Operator: "AND",
Items: []v3.FilterItem{
{
Key: v3.AttributeKey{
Key: "source",
DataType: v3.AttributeKeyDataTypeString,
Type: v3.AttributeKeyTypeTag,
},
Operator: "=",
Value: "nginx",
},
},
},
Config: []pipelinetypes.PipelineOperator{
{
OrderId: 1,
ID: "add",
Type: "add",
Field: "attributes.test",
Value: "val",
Enabled: true,
Name: "test add",
},
},
},
},
},
Dashboards: []types.DashboardData{},
Alerts: []ruletypes.PostableRule{},
},
ConnectionTests: &IntegrationConnectionTests{
Logs: &LogsConnectionTest{
AttributeKey: "source",
AttributeValue: "nginx",
},
},
}, {
IntegrationSummary: IntegrationSummary{
Id: "test-integration-2",
Title: "Test Integration 2",
Description: "Another test integration",
Author: IntegrationAuthor{
Name: "signoz",
Email: "integrations@signoz.io",
HomePage: "https://signoz.io",
},
Icon: `data:image/svg+xml;utf8,<svg ... > ... </svg>`,
},
Categories: []string{"testcat1", "testcat2"},
Overview: "test integration overview",
Configuration: []IntegrationConfigStep{
{
Title: "Step 1",
Instructions: "Set source attrib on your signals",
},
},
DataCollected: DataCollectedForIntegration{
Logs: []CollectedLogAttribute{},
Metrics: []CollectedMetric{},
},
Assets: IntegrationAssets{
Logs: LogsAssets{
Pipelines: []pipelinetypes.PostablePipeline{
{
Name: "pipeline2",
Alias: "pipeline2",
Enabled: true,
Filter: &v3.FilterSet{
Operator: "AND",
Items: []v3.FilterItem{
{
Key: v3.AttributeKey{
Key: "source",
DataType: v3.AttributeKeyDataTypeString,
Type: v3.AttributeKeyTypeTag,
},
Operator: "=",
Value: "redis",
},
},
},
Config: []pipelinetypes.PipelineOperator{
{
OrderId: 1,
ID: "add",
Type: "add",
Field: "attributes.test",
Value: "val",
Enabled: true,
Name: "test add",
},
},
},
},
},
Dashboards: []types.DashboardData{},
Alerts: []ruletypes.PostableRule{},
},
ConnectionTests: &IntegrationConnectionTests{
Logs: &LogsConnectionTest{
AttributeKey: "source",
AttributeValue: "nginx",
},
},
},
}, nil
}
func (t *TestAvailableIntegrationsRepo) get(
ctx context.Context, ids []string,
) (map[string]IntegrationDetails, *model.ApiError) {
availableIntegrations, apiErr := t.list(ctx)
if apiErr != nil {
return nil, apiErr
}
result := map[string]IntegrationDetails{}
for _, ai := range availableIntegrations {
if slices.Contains(ids, ai.Id) {
result[ai.Id] = ai
}
}
return result, nil
}