Skip to content

Commit

Permalink
chore: itests: cleanup parts forgotten in #12407 (#12427)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribasushi authored Sep 5, 2024
1 parent 0cfc47d commit 6753885
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 73 deletions.
24 changes: 0 additions & 24 deletions itests/kit/ensemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import (
"github.com/filecoin-project/lotus/cmd/lotus-worker/sealworker"
"github.com/filecoin-project/lotus/gateway"
"github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
lotusminer "github.com/filecoin-project/lotus/miner"
"github.com/filecoin-project/lotus/node"
"github.com/filecoin-project/lotus/node/config"
Expand Down Expand Up @@ -374,8 +373,6 @@ func (n *Ensemble) Start() *Ensemble {
n.mn = mocknet.New()
}

sharedITestID := harmonydb.ITestNewID()

// ---------------------
// FULL NODES
// ---------------------
Expand Down Expand Up @@ -620,7 +617,6 @@ func (n *Ensemble) Start() *Ensemble {
cfg.Subsystems.EnableMining = m.options.subsystems.Has(SMining)
cfg.Subsystems.EnableSealing = m.options.subsystems.Has(SSealing)
cfg.Subsystems.EnableSectorStorage = m.options.subsystems.Has(SSectorStorage)
cfg.Subsystems.EnableSectorIndexDB = m.options.subsystems.Has(SHarmony)

if m.options.mainMiner != nil {
token, err := m.options.mainMiner.FullNode.AuthNew(ctx, api.AllPermissions)
Expand Down Expand Up @@ -737,17 +733,6 @@ func (n *Ensemble) Start() *Ensemble {

// upgrades
node.Override(new(stmgr.UpgradeSchedule), n.options.upgradeSchedule),

node.Override(new(harmonydb.ITestID), sharedITestID),
node.Override(new(config.HarmonyDB), func() config.HarmonyDB {
return config.HarmonyDB{
Hosts: []string{envElse("LOTUS_HARMONYDB_HOSTS", "127.0.0.1")},
Database: "yugabyte",
Username: "yugabyte",
Password: "yugabyte",
Port: "5433",
}
}),
}
// append any node builder options.
opts = append(opts, m.options.extraNodeOpts...)
Expand Down Expand Up @@ -917,8 +902,6 @@ func (n *Ensemble) Start() *Ensemble {

auth := http.Header(nil)

// FUTURE: Use m.MinerNode.(BaseAPI).(impl.StorageMinerAPI).HarmonyDB to setup.

remote := paths.NewRemote(localStore, m.MinerNode, auth, 20, &paths.DefaultPartialFileHandler{})
store := m.options.workerStorageOpt(remote)

Expand Down Expand Up @@ -1156,10 +1139,3 @@ func importPreSealMeta(ctx context.Context, meta genesis.Miner, mds dtypes.Metad
size := binary.PutUvarint(buf, uint64(maxSectorID))
return mds.Put(ctx, datastore.NewKey(pipeline.StorageCounterDSPrefix), buf[:size])
}

func envElse(env, els string) string {
if v := os.Getenv(env); v != "" {
return v
}
return els
}
4 changes: 1 addition & 3 deletions itests/kit/node_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ const (
SSealing
SSectorStorage

SHarmony

MinerSubsystems = iota
MinerSubsystems = 0
)

func (ms MinerSubsystem) Add(single MinerSubsystem) MinerSubsystem {
Expand Down
7 changes: 0 additions & 7 deletions itests/kit/node_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ func WithAllSubsystems() NodeOpt {
}
}

func WithSectorIndexDB() NodeOpt {
return func(opts *nodeOpts) error {
opts.subsystems = opts.subsystems.Add(SHarmony)
return nil
}
}

func WithSubsystems(systems ...MinerSubsystem) NodeOpt {
return func(opts *nodeOpts) error {
for _, s := range systems {
Expand Down
29 changes: 1 addition & 28 deletions lib/harmony/harmonydb/harmonydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import (
"context"
"embed"
"fmt"
"math/rand"
"net"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"sync/atomic"
Expand All @@ -23,13 +21,6 @@ import (
"github.com/filecoin-project/lotus/node/config"
)

type ITestID string

// ITestNewID see ITestWithID doc
func ITestNewID() ITestID {
return ITestID(strconv.Itoa(rand.Intn(99999)))
}

type DB struct {
pgx *pgxpool.Pool
cfg *pgxpool.Config
Expand All @@ -52,28 +43,13 @@ func NewFromConfig(cfg config.HarmonyDB) (*DB, error) {
cfg.Password,
cfg.Database,
cfg.Port,
"",
)
}

func NewFromConfigWithITestID(cfg config.HarmonyDB) func(id ITestID) (*DB, error) {
return func(id ITestID) (*DB, error) {
return New(
cfg.Hosts,
cfg.Username,
cfg.Password,
cfg.Database,
cfg.Port,
id,
)
}
}

// New is to be called once per binary to establish the pool.
// log() is for errors. It returns an upgraded database's connection.
// This entry point serves both production and integration tests, so it's more DI.
func New(hosts []string, username, password, database, port string, itestID ITestID) (*DB, error) {
itest := string(itestID)
func New(hosts []string, username, password, database, port string) (*DB, error) {
connString := ""
if len(hosts) > 0 {
connString = "host=" + hosts[0] + " "
Expand All @@ -85,9 +61,6 @@ func New(hosts []string, username, password, database, port string, itestID ITes
}

schema := "curio"
if itest != "" {
schema = "itest_" + itest
}

if err := ensureSchemaExists(connString, schema); err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions node/builder_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func ConfigStorageMiner(c interface{}) Option {
Override(new(paths.SectorIndex), From(new(*paths.DBIndex))),

// sector index db is the only thing on lotus-miner that will use harmonydb
Override(new(*harmonydb.DB), func(cfg config.HarmonyDB, id harmonydb.ITestID) (*harmonydb.DB, error) {
return harmonydb.NewFromConfigWithITestID(cfg)(id)
Override(new(*harmonydb.DB), func(cfg config.HarmonyDB) (*harmonydb.DB, error) {
return harmonydb.NewFromConfig(cfg)
}),
),
If(!cfg.Subsystems.EnableSectorIndexDB,
Expand Down Expand Up @@ -136,7 +136,6 @@ func ConfigStorageMiner(c interface{}) Option {
Override(new(config.SealerConfig), cfg.Storage),
Override(new(config.ProvingConfig), cfg.Proving),
Override(new(config.HarmonyDB), cfg.HarmonyDB),
Override(new(harmonydb.ITestID), harmonydb.ITestID("")),
Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&cfg.Addresses)),
If(build.IsF3Enabled(), Override(F3Participation, modules.F3Participation)),
)
Expand Down
8 changes: 0 additions & 8 deletions node/config/def_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,5 @@ func TestDefaultMinerRoundtrip(t *testing.T) {
c2, err := FromReader(strings.NewReader(s), DefaultStorageMiner())
require.NoError(t, err)

fmt.Println(s)

// Differs between test envs
c.HarmonyDB = HarmonyDB{}
c2.(*StorageMiner).HarmonyDB = HarmonyDB{}

fmt.Println(c)
fmt.Println(c2)
require.True(t, reflect.DeepEqual(c, c2))
}

0 comments on commit 6753885

Please sign in to comment.