ytsaurus

package module
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

YTsaurus

Introduction

The Testcontainers module for YTsaurus.

Adding this module to your project dependencies

Please run the following command to add the YTsaurus module to your Go dependencies:

go get github.com/tractoai/testcontainers-ytsaurus

Usage example

ctx := context.Background()

// Start a YTsaurus container
container, err := ytsaurus.RunContainer(ctx, testcontainers.WithImage("ytsaurus/local:stable"))
if err != nil {
    fmt.Printf("Error starting container: %s\n", err)
    return
}

// Clean up the container after the example is complete
defer func() {
    if err := container.Terminate(ctx); err != nil {
        fmt.Printf("Error terminating container: %s\n", err)
    }
}()

Module reference

The YTsaurus module exposes one entrypoint function to create the YTsaurus container, and this function receives two parameters:

func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*YTsaurusContainer, error)
  • context.Context, the Go context.
  • testcontainers.ContainerCustomizer, a variadic argument for passing options.
Container Options

When starting the YTsaurus container, you can pass options in a variadic way to configure it.

Image

If you need to set a different YTsaurus Docker image, you can use testcontainers.WithImage with a valid Docker image for YTsaurus. E.g. testcontainers.WithImage("ytsaurus/local:stable").

Documentation

Index

Examples

Constants

View Source
const (
	DefaultUser     = "admin"
	DefaultPassword = "password"
	DefaultToken    = "password"
)

Variables

This section is empty.

Functions

func WithAuth added in v0.1.6

WithAuth enables authentication on http proxies and creates `admin` user with password and token `password`.

func WithLocalCypressDir added in v0.1.10

func WithLocalCypressDir(hostPath string) testcontainers.CustomizeRequestOption

WithLocalCypressDir bind-mounts hostPath into the container at the path the YTsaurus image expects (/var/lib/yt/local-cypress) so that files there are imported into Cypress on startup. Also enables --wait-tablet-cell-initialization so dynamic tables in the tree can be mounted and populated.

See yt/python/yt/environment/local_cypress.py for the format of the tree (file + .meta sibling; subdirectories with .meta become map_nodes).

Types

type YTsaurusContainer

type YTsaurusContainer struct {
	testcontainers.Container
}

YTsaurusContainer represents the YTsaurus container type used in the module.

func RunContainer

RunContainer creates and starts an instance of the YTsaurus container.

Example
package main

import (
	"context"
	"fmt"

	"github.com/testcontainers/testcontainers-go"
	"go.ytsaurus.tech/yt/go/ypath"

	ytsaurus "github.com/tractoai/testcontainers-ytsaurus"
)

func main() {
	ctx := context.Background()

	// Start a YTsaurus container
	container, err := ytsaurus.RunContainer(ctx, testcontainers.WithImage("ytsaurus/local:stable"))
	if err != nil {
		fmt.Printf("Error starting container: %s\n", err)
		return
	}

	// Clean up the container after the example is complete
	defer func() {
		if err := container.Terminate(ctx); err != nil {
			fmt.Printf("Error terminating container: %s\n", err)
		}
	}()

	// Create a YT client
	ytClient, err := container.NewClient(ctx)
	if err != nil {
		fmt.Printf("Error creating YT client: %s\n", err)
		return
	}

	// List root
	var owner string
	err = ytClient.GetNode(ctx, ypath.Path("//home").Attr("owner"), &owner, nil)
	if err != nil {
		fmt.Printf("Get attr: %+v", err)
		return
	}

	fmt.Printf("Owner: %v\n", owner)

}
Output:
Owner: root

func (*YTsaurusContainer) ConnectionHost

func (y *YTsaurusContainer) ConnectionHost(ctx context.Context) (string, error)

ConnectionHost returns the host and dynamic port for accessing the YTsaurus container.

func (*YTsaurusContainer) GetProxy added in v0.1.5

func (y *YTsaurusContainer) GetProxy(ctx context.Context) (string, error)

GetProxy is an alias for ConnectionHost since `proxy` is more familiar term for in YTsaurus.

func (*YTsaurusContainer) NewClient

func (y *YTsaurusContainer) NewClient(ctx context.Context) (yt.Client, error)

NewClient creates a new YT client connected to the YTsaurus container.

func (*YTsaurusContainer) Token

func (y *YTsaurusContainer) Token() string

Token returns the token for the YTsaurus container.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL