testplanet

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: AGPL-3.0 Imports: 66 Imported by: 0

Documentation

Overview

Package testplanet implements the full network wiring for testing

Index

Constants

This section is empty.

Variables

View Source
var DisablePeerCAWhitelist = Reconfigure{
	Bootstrap: func(index int, config *bootstrap.Config) {
		config.Server.UsePeerCAWhitelist = false
	},
	Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
		config.Server.UsePeerCAWhitelist = false
	},
	StorageNode: func(index int, config *storagenode.Config) {
		config.Server.UsePeerCAWhitelist = false
	},
}

DisablePeerCAWhitelist returns a `Reconfigure` that sets `UsePeerCAWhitelist` for all node types that use kademlia.

Functions

func Run

func Run(t *testing.T, config Config, test func(t *testing.T, ctx *testcontext.Context, planet *Planet))

Run runs testplanet in multiple configurations.

Types

type Config

type Config struct {
	SatelliteCount   int
	StorageNodeCount int
	UplinkCount      int

	Identities      *testidentity.Identities
	IdentityVersion *storj.IDVersion
	Reconfigure     Reconfigure
}

Config describes planet configuration

type Peer

type Peer interface {
	ID() storj.NodeID
	Addr() string
	Local() overlay.NodeDossier

	Run(context.Context) error
	Close() error
}

Peer represents one of StorageNode or Satellite

type Planet

type Planet struct {
	Bootstrap      *bootstrap.Peer
	VersionControl *versioncontrol.Peer
	Satellites     []*satellite.Peer
	StorageNodes   []*storagenode.Peer
	Uplinks        []*Uplink
	// contains filtered or unexported fields
}

Planet is a full storj system setup.

func New

func New(t zaptest.TestingT, satelliteCount, storageNodeCount, uplinkCount int) (*Planet, error)

New creates a new full system with the given number of nodes.

func NewCustom

func NewCustom(log *zap.Logger, config Config) (*Planet, error)

NewCustom creates a new full system with the specified configuration.

func NewWithIdentityVersion added in v0.9.0

func NewWithIdentityVersion(t zaptest.TestingT, identityVersion *storj.IDVersion, satelliteCount, storageNodeCount, uplinkCount int) (*Planet, error)

NewWithIdentityVersion creates a new full system with the given version for node identities and the given number of nodes.

func NewWithLogger

func NewWithLogger(log *zap.Logger, satelliteCount, storageNodeCount, uplinkCount int) (*Planet, error)

NewWithLogger creates a new full system with the given number of nodes.

func (*Planet) Identities

func (planet *Planet) Identities() *testidentity.Identities

Identities returns the identity provider for this planet.

func (*Planet) NewIdentity

func (planet *Planet) NewIdentity() (*identity.FullIdentity, error)

NewIdentity creates a new identity for a node

func (*Planet) NewListener

func (planet *Planet) NewListener() (net.Listener, error)

NewListener creates a new listener

func (*Planet) NewVersionConfig

func (planet *Planet) NewVersionConfig() version.Config

NewVersionConfig returns the Version Config for this planet with tuned metrics.

func (*Planet) NewVersionInfo

func (planet *Planet) NewVersionInfo() version.Info

NewVersionInfo returns the Version Info for this planet with tuned metrics.

func (*Planet) Reconnect

func (planet *Planet) Reconnect(ctx context.Context)

Reconnect reconnects all nodes with each other.

func (*Planet) Shutdown

func (planet *Planet) Shutdown() error

Shutdown shuts down all the nodes and deletes temporary directories.

func (*Planet) Size

func (planet *Planet) Size() int

Size returns number of nodes in the network

func (*Planet) Start

func (planet *Planet) Start(ctx context.Context)

Start starts all the nodes.

func (*Planet) StopPeer

func (planet *Planet) StopPeer(peer Peer) error

StopPeer stops a single peer in the planet

func (*Planet) WriteWhitelist

func (planet *Planet) WriteWhitelist(version storj.IDVersion) (string, error)

WriteWhitelist writes the pregenerated signer's CA cert to a "CA whitelist", PEM-encoded.

type Reconfigure

type Reconfigure struct {
	NewBootstrapDB func(index int) (bootstrap.DB, error)
	Bootstrap      func(index int, config *bootstrap.Config)

	NewSatelliteDB func(log *zap.Logger, index int) (satellite.DB, error)
	Satellite      func(log *zap.Logger, index int, config *satellite.Config)

	NewStorageNodeDB func(index int) (storagenode.DB, error)
	StorageNode      func(index int, config *storagenode.Config)
	NewIPCount       int
}

Reconfigure allows to change node configurations

type Uplink struct {
	Log              *zap.Logger
	Info             pb.Node
	Identity         *identity.FullIdentity
	Transport        transport.Client
	StorageNodeCount int
	APIKey           map[storj.NodeID]string
}

Uplink is a general purpose

func (*Uplink) Addr

func (uplink *Uplink) Addr() string

Addr returns uplink address

func (*Uplink) Delete

func (uplink *Uplink) Delete(ctx context.Context, satellite *satellite.Peer, bucket string, path storj.Path) error

Delete data to specific satellite

func (*Uplink) DialMetainfo

func (uplink *Uplink) DialMetainfo(ctx context.Context, destination Peer, apikey string) (metainfo.Client, error)

DialMetainfo dials destination with apikey and returns metainfo Client

func (*Uplink) DialPiecestore

func (uplink *Uplink) DialPiecestore(ctx context.Context, destination Peer) (*piecestore.Client, error)

DialPiecestore dials destination storagenode and returns a piecestore client.

func (*Uplink) Download

func (uplink *Uplink) Download(ctx context.Context, satellite *satellite.Peer, bucket string, path storj.Path) ([]byte, error)

Download data from specific satellite

func (*Uplink) DownloadStream

func (uplink *Uplink) DownloadStream(ctx context.Context, satellite *satellite.Peer, bucket string, path storj.Path) (*stream.Download, error)

DownloadStream returns stream for downloading data.

func (*Uplink) GetConfig

func (uplink *Uplink) GetConfig(satellite *satellite.Peer) uplink.Config

GetConfig returns a default config for a given satellite.

func (*Uplink) ID

func (uplink *Uplink) ID() storj.NodeID

ID returns uplink id

func (*Uplink) Local

func (uplink *Uplink) Local() pb.Node

Local returns uplink info

func (*Uplink) Shutdown

func (uplink *Uplink) Shutdown() error

Shutdown shuts down all uplink dependencies

func (*Uplink) Upload

func (uplink *Uplink) Upload(ctx context.Context, satellite *satellite.Peer, bucket string, path storj.Path, data []byte) error

Upload data to specific satellite

func (*Uplink) UploadWithConfig

func (uplink *Uplink) UploadWithConfig(ctx context.Context, satellite *satellite.Peer, redundancy *uplink.RSConfig, bucket string, path storj.Path, data []byte) error

UploadWithConfig uploads data to specific satellite with configured values

func (*Uplink) UploadWithExpiration added in v0.11.0

func (uplink *Uplink) UploadWithExpiration(ctx context.Context, satellite *satellite.Peer, bucket string, path storj.Path, data []byte, expiration time.Time) error

UploadWithExpiration data to specific satellite

Jump to

Keyboard shortcuts

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