Documentation
¶
Index ¶
- func AssertEventuallyTrue(t *testing.T, condition func() bool, timeout time.Duration, message string)
- func CleanupNeo4j(t *testing.T, config *TestConfig)
- func CleanupRedis(t *testing.T, config *TestConfig)
- func CreateTestFile(t *testing.T, content []byte, filename string) string
- func GenerateTestJWT(userID, username, email string, roles []string) string
- func GenerateTestNotebookID() string
- func GenerateTestTenantID() string
- func GenerateTestUserID() string
- func GetTestDocuments() map[string]TestDocument
- func GetTestUsers() map[string]TestUser
- func LoadTestFixture(t *testing.T, config *TestConfig, filename string) []byte
- func MakeHTTPRequest(t *testing.T, method, url string, body io.Reader, headers map[string]string) *http.Response
- func MeasurePerformance(t *testing.T, operation string, fn func()) time.Duration
- func ParseJSONResponse(body io.Reader, target interface{}) error
- func ReadResponseBody(t *testing.T, resp *http.Response) string
- func TeardownTestEnvironment(t *testing.T, config *TestConfig)
- func ValidatePerformanceBenchmarks(t *testing.T, metrics PerformanceMetrics)
- func WaitForService(t *testing.T, url string, timeout time.Duration)
- type APIClient
- func (c *APIClient) GetAvailableStrategies(ctx context.Context) (*StrategiesResponse, error)
- func (c *APIClient) GetChunk(ctx context.Context, fileID, chunkID string) (*ChunkResponse, error)
- func (c *APIClient) GetDocumentStatus(ctx context.Context, documentID string) (*DocumentStatus, error)
- func (c *APIClient) GetFileChunks(ctx context.Context, fileID string, limit, offset int) (*ChunksResponse, error)
- func (c *APIClient) GetOptimalStrategy(ctx context.Context, contentType string, fileSize int64, complexity string) (*StrategyRecommendation, error)
- func (c *APIClient) HealthCheck(ctx context.Context) error
- func (c *APIClient) MakeRequest(ctx context.Context, method, path string, body io.Reader, ...) (*http.Response, error)
- func (c *APIClient) ReprocessFile(ctx context.Context, fileID, strategy string) (*UploadResponse, error)
- func (c *APIClient) SearchChunks(ctx context.Context, req SearchRequest) (*SearchResponse, error)
- func (c *APIClient) SetAuthToken(token string)
- func (c *APIClient) UploadBase64(ctx context.Context, req UploadRequest) (*UploadResponse, error)
- func (c *APIClient) UploadMultipart(ctx context.Context, req UploadRequest) (*UploadResponse, error)
- func (c *APIClient) WaitForProcessingComplete(ctx context.Context, documentID string, timeout time.Duration) (*DocumentStatus, error)
- type AuthHelper
- func (ah *AuthHelper) AuthenticateTestUser(ctx context.Context, userType string) (*TestUser, error)
- func (ah *AuthHelper) CreateTestUser(ctx context.Context, adminToken string, user TestUser) error
- func (ah *AuthHelper) DeleteTestUser(ctx context.Context, adminToken, username string) error
- func (ah *AuthHelper) GetClientCredentialsToken(ctx context.Context) (*TokenResponse, error)
- func (ah *AuthHelper) GetPasswordToken(ctx context.Context, username, password string) (*TokenResponse, error)
- func (ah *AuthHelper) GetUserInfo(ctx context.Context, accessToken string) (*UserInfo, error)
- func (ah *AuthHelper) RefreshToken(ctx context.Context, refreshToken string) (*TokenResponse, error)
- func (ah *AuthHelper) ValidateToken(ctx context.Context, accessToken string) (*UserInfo, error)
- type ChunkResponse
- type ChunksResponse
- type DocumentStatus
- type EmbeddingMetadata
- type FileMetadata
- type PerformanceMetrics
- type SearchRequest
- type SearchResponse
- type StorageVerifier
- func (sv *StorageVerifier) VerifyEmbeddingSearch(t *testing.T, query string, documentID string, expectedResults int) []EmbeddingMetadata
- func (sv *StorageVerifier) VerifyEmbeddingsInDeepLake(t *testing.T, documentID string, expectedChunks int) []EmbeddingMetadata
- func (sv *StorageVerifier) VerifyFileInMinIO(t *testing.T, documentID, fileName string, expectedContent []byte) *FileMetadata
- func (sv *StorageVerifier) VerifyFileNotInMinIO(t *testing.T, documentID, fileName string)
- func (sv *StorageVerifier) VerifyNoEmbeddingsInDeepLake(t *testing.T, documentID string)
- func (sv *StorageVerifier) VerifyStorageCleanup(t *testing.T, documentID string)
- func (sv *StorageVerifier) VerifyStorageIntegrity(t *testing.T, documentID, fileName string, originalContent []byte, ...)
- type StrategiesResponse
- type Strategy
- type StrategyRecommendation
- type TestConfig
- type TestDocument
- type TestUser
- type TokenResponse
- type UploadRequest
- type UploadResponse
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEventuallyTrue ¶
func AssertEventuallyTrue(t *testing.T, condition func() bool, timeout time.Duration, message string)
AssertEventuallyTrue polls a condition until it becomes true or times out
func CleanupNeo4j ¶
func CleanupNeo4j(t *testing.T, config *TestConfig)
CleanupNeo4j removes test data from Neo4j database
func CleanupRedis ¶
func CleanupRedis(t *testing.T, config *TestConfig)
CleanupRedis removes test data from Redis
func CreateTestFile ¶
CreateTestFile creates a temporary test file with given content
func GenerateTestJWT ¶
GenerateTestJWT generates a test JWT token for non-Keycloak scenarios
func GenerateTestNotebookID ¶
func GenerateTestNotebookID() string
GenerateTestNotebookID generates a unique test notebook ID
func GenerateTestTenantID ¶
func GenerateTestTenantID() string
GenerateTestTenantID generates a unique test tenant ID
func GenerateTestUserID ¶
func GenerateTestUserID() string
GenerateTestUserID generates a unique test user ID
func GetTestDocuments ¶
func GetTestDocuments() map[string]TestDocument
GetTestDocuments returns a collection of test documents for different scenarios
func GetTestUsers ¶
GetTestUsers returns predefined test users for different scenarios
func LoadTestFixture ¶
func LoadTestFixture(t *testing.T, config *TestConfig, filename string) []byte
LoadTestFixture loads a test fixture file
func MakeHTTPRequest ¶
func MakeHTTPRequest(t *testing.T, method, url string, body io.Reader, headers map[string]string) *http.Response
MakeHTTPRequest makes an HTTP request and returns the response
func MeasurePerformance ¶
MeasurePerformance measures execution time of a function
func ParseJSONResponse ¶
ParseJSONResponse parses JSON response body into target interface
func ReadResponseBody ¶
ReadResponseBody reads and returns the response body as string
func TeardownTestEnvironment ¶
func TeardownTestEnvironment(t *testing.T, config *TestConfig)
TeardownTestEnvironment cleans up after tests
func ValidatePerformanceBenchmarks ¶
func ValidatePerformanceBenchmarks(t *testing.T, metrics PerformanceMetrics)
ValidatePerformanceBenchmarks validates that performance meets benchmarks
Types ¶
type APIClient ¶
APIClient provides methods to interact with the Aether-BE API
func NewAPIClient ¶
NewAPIClient creates a new API client
func (*APIClient) GetAvailableStrategies ¶
func (c *APIClient) GetAvailableStrategies(ctx context.Context) (*StrategiesResponse, error)
GetAvailableStrategies retrieves available chunking strategies
func (*APIClient) GetDocumentStatus ¶
func (c *APIClient) GetDocumentStatus(ctx context.Context, documentID string) (*DocumentStatus, error)
GetDocumentStatus retrieves the processing status of a document
func (*APIClient) GetFileChunks ¶
func (c *APIClient) GetFileChunks(ctx context.Context, fileID string, limit, offset int) (*ChunksResponse, error)
GetFileChunks retrieves chunks for a specific file
func (*APIClient) GetOptimalStrategy ¶
func (c *APIClient) GetOptimalStrategy(ctx context.Context, contentType string, fileSize int64, complexity string) (*StrategyRecommendation, error)
GetOptimalStrategy gets a strategy recommendation for content
func (*APIClient) HealthCheck ¶
HealthCheck performs a health check
func (*APIClient) MakeRequest ¶
func (c *APIClient) MakeRequest(ctx context.Context, method, path string, body io.Reader, headers map[string]string) (*http.Response, error)
MakeRequest makes a public HTTP request with proper headers (for testing)
func (*APIClient) ReprocessFile ¶
func (c *APIClient) ReprocessFile(ctx context.Context, fileID, strategy string) (*UploadResponse, error)
ReprocessFile reprocesses a file with a different strategy
func (*APIClient) SearchChunks ¶
func (c *APIClient) SearchChunks(ctx context.Context, req SearchRequest) (*SearchResponse, error)
SearchChunks searches for chunks based on query
func (*APIClient) SetAuthToken ¶
SetAuthToken sets the authentication token for requests
func (*APIClient) UploadBase64 ¶
func (c *APIClient) UploadBase64(ctx context.Context, req UploadRequest) (*UploadResponse, error)
UploadBase64 uploads a document using base64 encoding
func (*APIClient) UploadMultipart ¶
func (c *APIClient) UploadMultipart(ctx context.Context, req UploadRequest) (*UploadResponse, error)
UploadMultipart uploads a document using multipart form data
func (*APIClient) WaitForProcessingComplete ¶
func (c *APIClient) WaitForProcessingComplete(ctx context.Context, documentID string, timeout time.Duration) (*DocumentStatus, error)
WaitForProcessingComplete polls until document processing is complete
type AuthHelper ¶
type AuthHelper struct {
KeycloakURL string
Realm string
ClientID string
ClientSecret string
HTTPClient *http.Client
}
AuthHelper provides authentication utilities for testing
func NewAuthHelper ¶
func NewAuthHelper(keycloakURL, realm, clientID, clientSecret string) *AuthHelper
NewAuthHelper creates a new authentication helper
func (*AuthHelper) AuthenticateTestUser ¶
AuthenticateTestUser authenticates a test user and returns token info
func (*AuthHelper) CreateTestUser ¶
CreateTestUser creates a test user in Keycloak (requires admin privileges)
func (*AuthHelper) DeleteTestUser ¶
func (ah *AuthHelper) DeleteTestUser(ctx context.Context, adminToken, username string) error
DeleteTestUser deletes a test user from Keycloak (requires admin privileges)
func (*AuthHelper) GetClientCredentialsToken ¶
func (ah *AuthHelper) GetClientCredentialsToken(ctx context.Context) (*TokenResponse, error)
GetClientCredentialsToken gets a token using client credentials flow
func (*AuthHelper) GetPasswordToken ¶
func (ah *AuthHelper) GetPasswordToken(ctx context.Context, username, password string) (*TokenResponse, error)
GetPasswordToken gets a token using password flow (for testing only)
func (*AuthHelper) GetUserInfo ¶
GetUserInfo retrieves user information using an access token
func (*AuthHelper) RefreshToken ¶
func (ah *AuthHelper) RefreshToken(ctx context.Context, refreshToken string) (*TokenResponse, error)
RefreshToken refreshes an access token using a refresh token
func (*AuthHelper) ValidateToken ¶
ValidateToken validates an access token and returns user info
type ChunkResponse ¶
type ChunkResponse struct {
ID string `json:"id"`
DocumentID string `json:"document_id"`
ChunkIndex int `json:"chunk_index"`
Content string `json:"content"`
StartByte int64 `json:"start_byte"`
EndByte int64 `json:"end_byte"`
Strategy string `json:"strategy"`
QualityScore float64 `json:"quality_score"`
TokenCount int `json:"token_count"`
Metadata map[string]interface{} `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
}
ChunkResponse represents a document chunk
type ChunksResponse ¶
type ChunksResponse struct {
Chunks []ChunkResponse `json:"chunks"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
PageSize int `json:"page_size"`
HasMore bool `json:"has_more"`
}
ChunksResponse represents a collection of chunks
type DocumentStatus ¶
type DocumentStatus struct {
ID string `json:"id"`
Status string `json:"status"`
ProcessingJobID string `json:"processing_job_id"`
Progress float64 `json:"progress"`
ErrorMessage string `json:"error_message,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
DocumentStatus represents the status of a document
type EmbeddingMetadata ¶
type EmbeddingMetadata struct {
ID string `json:"id"`
DocumentID string `json:"document_id"`
ChunkID string `json:"chunk_id"`
Vector []float64 `json:"vector"`
Metadata map[string]interface{} `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
}
EmbeddingMetadata represents embedding metadata in DeepLake
type FileMetadata ¶
type FileMetadata struct {
Key string
Size int64
ETag string
LastModified time.Time
ContentType string
Checksum string
}
FileMetadata represents file metadata in storage
type PerformanceMetrics ¶
type PerformanceMetrics struct {
UploadTime time.Duration
ProcessingTime time.Duration
ChunkTime time.Duration
StorageTime time.Duration
SearchTime time.Duration
}
PerformanceMetrics holds performance measurement data
type SearchRequest ¶
type SearchRequest struct {
Query string `json:"query"`
Filters map[string]interface{} `json:"filters,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Similarity float64 `json:"similarity_threshold,omitempty"`
}
SearchRequest represents a chunk search request
type SearchResponse ¶
type SearchResponse struct {
Results []ChunkResponse `json:"results"`
TotalCount int `json:"total_count"`
Query string `json:"query"`
TimeTaken string `json:"time_taken"`
}
SearchResponse represents search results
type StorageVerifier ¶
type StorageVerifier struct {
// contains filtered or unexported fields
}
StorageVerifier provides methods to verify file storage in MinIO and DeepLake
func NewStorageVerifier ¶
func NewStorageVerifier(minioEndpoint, accessKey, secretKey, bucketName, deeplakeURL string) (*StorageVerifier, error)
NewStorageVerifier creates a new storage verifier
func (*StorageVerifier) VerifyEmbeddingSearch ¶
func (sv *StorageVerifier) VerifyEmbeddingSearch(t *testing.T, query string, documentID string, expectedResults int) []EmbeddingMetadata
VerifyEmbeddingSearch tests embedding similarity search
func (*StorageVerifier) VerifyEmbeddingsInDeepLake ¶
func (sv *StorageVerifier) VerifyEmbeddingsInDeepLake(t *testing.T, documentID string, expectedChunks int) []EmbeddingMetadata
VerifyEmbeddingsInDeepLake verifies that embeddings exist in DeepLake
func (*StorageVerifier) VerifyFileInMinIO ¶
func (sv *StorageVerifier) VerifyFileInMinIO(t *testing.T, documentID, fileName string, expectedContent []byte) *FileMetadata
VerifyFileInMinIO verifies that a file exists in MinIO with correct metadata
func (*StorageVerifier) VerifyFileNotInMinIO ¶
func (sv *StorageVerifier) VerifyFileNotInMinIO(t *testing.T, documentID, fileName string)
VerifyFileNotInMinIO verifies that a file does not exist in MinIO
func (*StorageVerifier) VerifyNoEmbeddingsInDeepLake ¶
func (sv *StorageVerifier) VerifyNoEmbeddingsInDeepLake(t *testing.T, documentID string)
VerifyNoEmbeddingsInDeepLake verifies that no embeddings exist for a document
func (*StorageVerifier) VerifyStorageCleanup ¶
func (sv *StorageVerifier) VerifyStorageCleanup(t *testing.T, documentID string)
VerifyStorageCleanup verifies that files are properly cleaned up from storage
func (*StorageVerifier) VerifyStorageIntegrity ¶
func (sv *StorageVerifier) VerifyStorageIntegrity(t *testing.T, documentID, fileName string, originalContent []byte, expectedChunks int)
VerifyStorageIntegrity performs comprehensive storage integrity checks
type StrategiesResponse ¶
type StrategiesResponse struct {
Strategies []Strategy `json:"strategies"`
}
StrategiesResponse represents available strategies
type Strategy ¶
type Strategy struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]interface{} `json:"parameters"`
Supported []string `json:"supported_mime_types"`
}
Strategy represents a chunking strategy
type StrategyRecommendation ¶
type StrategyRecommendation struct {
Strategy string `json:"strategy"`
Confidence float64 `json:"confidence"`
Reasoning string `json:"reasoning"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
}
StrategyRecommendation represents a strategy recommendation
type TestConfig ¶
type TestConfig struct {
ServerURL string
Neo4jURI string
Neo4jUsername string
Neo4jPassword string
RedisAddr string
MinioEndpoint string
MinioAccessKey string
MinioSecretKey string
AudiModalURL string
DeepLakeURL string
FixturesPath string
}
TestConfig holds test environment configuration
func NewTestConfig ¶
func NewTestConfig() *TestConfig
NewTestConfig creates a new test configuration from environment variables
func SetupTestEnvironment ¶
func SetupTestEnvironment(t *testing.T) *TestConfig
SetupTestEnvironment prepares the test environment
type TestDocument ¶
type TestDocument struct {
Name string
Content []byte
MimeType string
Strategy string
ExpectedChunks int
ExpectedQuality float64
}
TestDocument represents a test document for uploading
type TestUser ¶
type TestUser struct {
Username string
Password string
Email string
FirstName string
LastName string
Roles []string
AccessToken string
UserInfo *UserInfo
}
TestUser represents a test user for authentication
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
RefreshExpiresIn int `json:"refresh_expires_in"`
Scope string `json:"scope"`
}
TokenResponse represents an OAuth2 token response
type UploadRequest ¶
type UploadRequest struct {
Name string `json:"name"`
Content []byte `json:"-"`
Strategy string `json:"strategy,omitempty"`
NotebookID string `json:"notebook_id,omitempty"`
Description string `json:"description,omitempty"`
}
UploadRequest represents a document upload request
type UploadResponse ¶
type UploadResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
UploadedAt time.Time `json:"uploaded_at"`
ProcessingJobID string `json:"processing_job_id,omitempty"`
Message string `json:"message,omitempty"`
}
UploadResponse represents the response from document upload
type UserInfo ¶
type UserInfo struct {
ID string `json:"sub"`
Username string `json:"username"`
Email string `json:"email"`
EmailVerified bool `json:"email_verified"`
Name string `json:"name"`
GivenName string `json:"given_name"`
FamilyName string `json:"family_name"`
Roles []string `json:"roles"`
Groups []string `json:"groups"`
RealmAccess map[string]interface{} `json:"realm_access"`
ResourceAccess map[string]interface{} `json:"resource_access"`
SessionState string `json:"session_state"`
PreferredUsername string `json:"preferred_username"`
}
UserInfo represents user information from Keycloak