Skip to main content

signoz_integrations_test.go

Overview - signoz_integrations_test.go

This file contains integration tests for the SigNoz integrations feature, covering the installation, uninstallation, and management of integrations. It tests the interaction between integrations, log pipelines, and dashboards.

Detailed Documentation

TestSignozIntegrationLifeCycle

  • Purpose: Tests the lifecycle of a SigNoz integration, including installation and uninstallation.
  • Parameters:
    • t (*testing.T): Testing object.
  • Returns: None

TestLogPipelinesForInstalledSignozIntegrations

  • Purpose: Tests the behavior of log pipelines when SigNoz integrations are installed and uninstalled.
  • Parameters:
    • t (*testing.T): Testing object.
  • Returns: None

TestDashboardsForInstalledIntegrationDashboards

  • Purpose: Tests that dashboards get added to the dashboards list after an integration is installed, and removed after an integration is uninstalled
  • Parameters:
    • t (*testing.T): Testing object.
  • Returns: None

IntegrationsTestBed

  • Purpose: Struct that sets up and manages the test environment for integrations.
  • Parameters:
    • t (*testing.T): Testing object.
    • testUser (*types.User): Test user.
    • qsHttpHandler (http.Handler): HTTP handler for the query service.
    • mockClickhouse (mockhouse.ClickConnMockCommon): Mock ClickHouse connection.
  • Returns: None

GetAvailableIntegrationsFromQS

  • Purpose: Retrieves the list of available integrations from the query service.
  • Parameters: None
  • Returns:
    • *integrations.IntegrationsListResponse: A pointer to the response containing the list of available integrations.

GetInstalledIntegrationsFromQS

  • Purpose: Retrieves the list of installed integrations from the query service.
  • Parameters: None
  • Returns:
    • *integrations.IntegrationsListResponse: A pointer to the response containing the list of installed integrations.

GetIntegrationDetailsFromQS

  • Purpose: Retrieves details of a specific integration from the query service.
  • Parameters:
    • integrationId (string): The ID of the integration to retrieve details for.
  • Returns:
    • *integrations.Integration: A pointer to the response containing the integration details.

GetIntegrationConnectionStatus

  • Purpose: Retrieves connection status of a specific integration from the query service.
  • Parameters:
    • integrationId (string): The ID of the integration to retrieve connection status for.
  • Returns:
    • *integrations.IntegrationConnectionStatus: A pointer to the response containing the integration connection status.

RequestQSToInstallIntegration

  • Purpose: Requests the installation of an integration through the query service.
  • Parameters:
    • integrationId (string): The ID of the integration to install.
    • config (map[string]interface{}): The configuration for the integration.
  • Returns: None

RequestQSToUninstallIntegration

  • Purpose: Requests the uninstallation of an integration through the query service.
  • Parameters:
    • integrationId (string): The ID of the integration to uninstall.
  • Returns: None

GetDashboardsFromQS

  • Purpose: Retrieves dashboards list from query service.
  • Parameters: None
  • Returns:
    • []types.Dashboard: A list of dashboards.

GetDashboardByIdFromQS

  • Purpose: Retrieves a dashboard by UUID from the query service.
  • Parameters:
    • dashboardUuid (string): The UUID of the dashboard to retrieve.
  • Returns:
    • *types.Dashboard: A pointer to the Dashboard object.

RequestQS

  • Purpose: Makes a request to the query service with authentication.
  • Parameters:
    • path (string): The path to request.
    • postData (interface{}): The data to post (if any).
  • Returns:
    • *app.ApiResponse: A pointer to the response from the query service.

mockLogQueryResponse

  • Purpose: Mocks the response for log queries from ClickHouse.
  • Parameters:
    • logsInResponse ([]model.SignozLog): The logs to return in the mocked response.
  • Returns: None

mockMetricStatusQueryResponse

  • Purpose: Mocks the response for metric status queries from ClickHouse.
  • Parameters:
    • expectation (*model.MetricStatus): The expected metric status.
  • Returns: None

NewIntegrationsTestBed

  • Purpose: Creates a new instance of IntegrationsTestBed.
  • Parameters:
    • t (*testing.T): Testing object.
    • testDB (sqlstore.SQLStore): Optional SQL store for testing; if nil, a new one is created.
  • Returns:
    • *IntegrationsTestBed: A pointer to the newly created IntegrationsTestBed instance.

postableFromPipelines

  • Purpose: Converts a slice of GettablePipeline to PostablePipelines
  • Parameters:
    • gettablePipelines ([]pipelinetypes.GettablePipeline): The input slice of pipelines.
  • Returns:
    • pipelinetypes.PostablePipelines: The converted PostablePipelines.

Code Examples

// Example of creating an IntegrationsTestBed instance
const testbed = NewIntegrationsTestBed(t, null);

// Example of getting available integrations
const integrations = testbed.GetAvailableIntegrationsFromQS();

Include in Getting Started: NO