Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revamped integration test kit (aka. Operation Sparks Joy) #6329

Merged
merged 102 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
2bcedcf
initial version of the new itest kit.
raulk May 25, 2021
71cd268
fix.
raulk Jun 4, 2021
bcbbd73
Merge branch 'raulk/itests' into raulk/itests-refactor-kit
raulk Jun 10, 2021
019394b
remove debug statements.
raulk Jun 10, 2021
0303a02
rename DealHarness.{TestRetrieval=>PerformRetrieval}.
raulk Jun 10, 2021
0d69c03
deals harness: use require.
raulk Jun 10, 2021
c27fdc2
deals harness: more improvements.
raulk Jun 10, 2021
cf0150e
deals harness: use require.
raulk Jun 10, 2021
3299709
deals tests: begin migration.
raulk Jun 10, 2021
4f2aaa5
deals tests: refactor/simplify TestDealMining; now TestFirstDealEnabl…
raulk Jun 10, 2021
dcd6fc2
deals tests: migrate TestOfflineDealFlow.
raulk Jun 10, 2021
8b037e2
deals tests: migrate deals cycles tests and add coverage.
raulk Jun 10, 2021
e84b8ab
move new kit into kit2, re-enable unmigrated tests against kit1.
raulk Jun 11, 2021
183814a
finish migrating deals test.
raulk Jun 13, 2021
958b6b5
go mod tidy.
raulk Jun 13, 2021
f1ec0d6
fix lint.
raulk Jun 13, 2021
ac67e46
fix test.
raulk Jun 13, 2021
d94a19f
refactor: cli test with kit2
dirkmc Jun 14, 2021
86cca73
refactor: convert multisig tests to kit2
dirkmc Jun 14, 2021
7b00b18
refactor: convert paych to kit2
dirkmc Jun 14, 2021
d2c35db
refactor: convert tape test to kit2
dirkmc Jun 14, 2021
eb5a263
refactor: convert verifreg test to kit2
dirkmc Jun 14, 2021
6fb31a3
start mining way more in the past.
raulk Jun 14, 2021
8a7dba1
add comment.
raulk Jun 14, 2021
dae8be0
migrate to require; use t.Log* instead of fmt.Print*.
raulk Jun 14, 2021
0bb5fff
refactor: clean up code
dirkmc Jun 15, 2021
c27f3de
start mining way more in the past.
raulk Jun 14, 2021
803a3df
refactor: ccupgrade test
dirkmc Jun 14, 2021
4cd0964
refactor: replace if err with require
dirkmc Jun 15, 2021
2d5b798
refactor: cli test with kit2
dirkmc Jun 14, 2021
16cad0e
refactor: convert gateway tests to kit2
dirkmc Jun 15, 2021
c5b7e48
Merge pull request #6467 from filecoin-project/refactor/itests-paych
raulk Jun 15, 2021
5ce482b
refactor: change network upgrade NodeOption to node.Option
dirkmc Jun 15, 2021
2267d15
refactor: update paych cli tests to use kit2
dirkmc Jun 15, 2021
cd53942
refactor: batch deal test to use kit2
dirkmc Jun 15, 2021
cd903be
refactor: sdr upgrade test to use kit2
dirkmc Jun 15, 2021
f0a8a85
Merge pull request #6486 from filecoin-project/refactor/itest-batch-deal
raulk Jun 16, 2021
a0894a8
Merge pull request #6464 from filecoin-project/refactor/itest-cli
raulk Jun 16, 2021
1d768a8
Merge pull request #6484 from filecoin-project/refactor/itest-paych-cli
raulk Jun 16, 2021
06cb3cf
Merge pull request #6488 from filecoin-project/refactor/itest-sdr-upg…
raulk Jun 16, 2021
fea5afd
Merge pull request #6468 from filecoin-project/refactor/itest-tape
raulk Jun 16, 2021
305e324
Merge branch 'master' into raulk/itests-refactor-kit
raulk Jun 16, 2021
4ea73b4
refactor: use genesis preseals from kit2
dirkmc Jun 16, 2021
3014847
Merge pull request #6470 from filecoin-project/refactor/ccupgrade-test
raulk Jun 16, 2021
d2ff0cd
fix verifreg test; add VerifierRootKey() and Account() ensemble opts.
raulk Jun 16, 2021
a3015ca
Merge branch 'raulk/itests-refactor-kit' into refactor/itest-verifreg
raulk Jun 16, 2021
8ed753a
rename RootVerifier option.
raulk Jun 16, 2021
2c30ac3
Merge pull request #6469 from filecoin-project/refactor/itest-verifreg
raulk Jun 16, 2021
f1bf080
Merge branch 'raulk/itests-refactor-kit' into refactor/itest-multisig
raulk Jun 16, 2021
8f608df
refactor: sector pledge test to use kit2
dirkmc Jun 17, 2021
6567887
refactor: sector terminate test to kit2
dirkmc Jun 17, 2021
e9325fe
refactor: wdpost test to kit2
dirkmc Jun 17, 2021
3de6bea
refactor: wdpost dispute test to use kit2
dirkmc Jun 17, 2021
7a9769b
refactor: deadline toggling test to kit2
dirkmc Jun 17, 2021
6562a23
Merge pull request #6506 from filecoin-project/refactor/itest-sector-…
raulk Jun 17, 2021
9436be5
introduce TestFullNode#WaitTillChain(predicate).
raulk Jun 17, 2021
c4e0ac2
Merge pull request #6507 from filecoin-project/refactor/itest-sector-…
raulk Jun 18, 2021
2184805
Merge branch 'raulk/itests-refactor-kit' into refactor/itest-wdpost
raulk Jun 18, 2021
2548c22
switch to TestFullNode#WaitTillChain.
raulk Jun 18, 2021
572277c
Merge pull request #6509 from filecoin-project/refactor/itest-wdpost
raulk Jun 18, 2021
32327c7
Merge branch 'raulk/itests-refactor-kit' into refactor/itest-deadling…
raulk Jun 18, 2021
e85af3c
fix merge error.
raulk Jun 18, 2021
4c2cc8e
Merge branch 'raulk/itests-refactor-kit' into refactor/itest-deadling…
raulk Jun 18, 2021
5548541
fix default proof type to use for non-genesis miners.
raulk Jun 18, 2021
7c329d4
Merge pull request #6511 from filecoin-project/refactor/itest-deadlin…
raulk Jun 18, 2021
3ae42d4
Merge branch 'raulk/itests-refactor-kit' into refactor/itest-multisig
raulk Jun 18, 2021
3d8eb37
cleaner instantiation of lite and gateway nodes + general cleanup.
raulk Jun 18, 2021
9604be6
Merge branch 'raulk/itests-refactor-kit' into refactor/itest-wdpost-d…
raulk Jun 18, 2021
718babd
use miner owner address when posting proofs.
raulk Jun 18, 2021
83de21e
Merge pull request #6483 from filecoin-project/refactor/itest-multisig
raulk Jun 18, 2021
a8bf7e7
Merge pull request #6510 from filecoin-project/refactor/itest-wdpost-…
raulk Jun 18, 2021
a7d8d15
kill old kit 🎉
raulk Jun 18, 2021
8a418bf
rename {kit2=>kit}.
raulk Jun 18, 2021
7ee184e
fix lotus-storage-miner tests.
raulk Jun 21, 2021
d1b291d
fix proof types.
raulk Jun 21, 2021
83ee345
Merge branch 'master' into raulk/itests-refactor-kit
raulk Jun 21, 2021
0879ac4
uncomment lines in TestDealCyclesConcurrent.
raulk Jun 21, 2021
00fa387
remove debug statement.
raulk Jun 21, 2021
70929a9
speed up test.
raulk Jun 21, 2021
132b497
Merge branch 'master' into raulk/itests-refactor-kit
raulk Jun 21, 2021
c22e10c
use mock proofs in TestQuotePriceForUnsealedRetrieval.
raulk Jun 21, 2021
b7a5e3c
Merge branch 'raulk/worker-disable-resource-filtering' into raulk/ite…
raulk Jun 21, 2021
4fcd0b7
disable resource filtering on scheduler.
raulk Jun 21, 2021
e69335b
Merge branch 'master' into raulk/itests-refactor-kit
raulk Jun 21, 2021
e438ef9
fix merge error in window post dispute tests.
raulk Jun 21, 2021
502e104
typo.
raulk Jun 21, 2021
0e2d06f
switch to http API.
raulk Jun 21, 2021
bb032b5
switch back to ws API.
raulk Jun 21, 2021
da78993
fix: bump blocktime of TestQuotePriceForUnsealedRetrieval to 1 second
dirkmc Jun 22, 2021
2a58f83
fix sector_terminate_test.go flakiness.
raulk Jun 22, 2021
71a7270
cleanup gateway RPC.
raulk Jun 22, 2021
098eb6b
try using bg context on constructor.
raulk Jun 22, 2021
9b2efd5
try to deflake window post itests.
raulk Jun 22, 2021
120dd14
avoid double close.
raulk Jun 22, 2021
2e9e1c2
avoid double BlockMiner instantiation.
raulk Jun 22, 2021
f4d0db8
Merge branch 'raulk/circleci-dynamic' into raulk/itests-refactor-kit
raulk Jun 23, 2021
ef8f355
Merge branch 'master' into raulk/itests-refactor-kit
raulk Jun 23, 2021
779626c
fix circleci.
raulk Jun 23, 2021
9b3188d
split deals tests.
raulk Jun 23, 2021
fa4bcc6
Merge branch 'master' into raulk/itests-refactor-kit
raulk Jun 23, 2021
58f348c
add ability to suspend deal-making until CE is stable.
raulk Jun 23, 2021
6a48fbb
increase suspension threshold to 300.
raulk Jun 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
228 changes: 77 additions & 151 deletions itests/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,30 @@ import (

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/exitcode"
lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/node/impl"
"github.com/stretchr/testify/assert"
"github.com/filecoin-project/lotus/itests/kit2"
"github.com/stretchr/testify/require"
)

func TestAPI(t *testing.T) {
t.Run("direct", func(t *testing.T) {
runAPITest(t, kit.Builder)
runAPITest(t)
})
t.Run("rpc", func(t *testing.T) {
runAPITest(t, kit.RPCBuilder)
runAPITest(t, kit2.ThroughRPC())
})
}

type apiSuite struct {
makeNodes kit.APIBuilder
opts []interface{}
}

// runAPITest is the entry point to API test suite
func runAPITest(t *testing.T, b kit.APIBuilder) {
ts := apiSuite{
makeNodes: b,
}
func runAPITest(t *testing.T, opts ...interface{}) {
ts := apiSuite{opts: opts}

t.Run("version", ts.testVersion)
t.Run("id", ts.testID)
Expand All @@ -51,213 +48,142 @@ func (ts *apiSuite) testVersion(t *testing.T) {
lapi.RunningNodeType = lapi.NodeUnknown
})

ctx := context.Background()
apis, _ := ts.makeNodes(t, kit.OneFull, kit.OneMiner)
napi := apis[0]
full, _, _ := kit2.EnsembleMinimal(t, ts.opts...)

v, err := full.Version(context.Background())
require.NoError(t, err)

v, err := napi.Version(ctx)
if err != nil {
t.Fatal(err)
}
versions := strings.Split(v.Version, "+")
if len(versions) <= 0 {
t.Fatal("empty version")
}
require.NotZero(t, len(versions), "empty version")
require.Equal(t, versions[0], build.BuildVersion)
}

func (ts *apiSuite) testSearchMsg(t *testing.T) {
apis, miners := ts.makeNodes(t, kit.OneFull, kit.OneMiner)

api := apis[0]
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
senderAddr, err := api.WalletDefaultAddress(ctx)
if err != nil {
t.Fatal(err)
}

msg := &types.Message{
From: senderAddr,
To: senderAddr,
Value: big.Zero(),
}
bm := kit.NewBlockMiner(t, miners[0])
bm.MineBlocks(ctx, 100*time.Millisecond)
defer bm.Stop()

sm, err := api.MpoolPushMessage(ctx, msg, nil)
if err != nil {
t.Fatal(err)
}
res, err := api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
if err != nil {
t.Fatal(err)
}
if res.Receipt.ExitCode != 0 {
t.Fatal("did not successfully send message")
}

searchRes, err := api.StateSearchMsg(ctx, types.EmptyTSK, sm.Cid(), lapi.LookbackNoLimit, true)
if err != nil {
t.Fatal(err)
}

if searchRes.TipSet != res.TipSet {
t.Fatalf("search ts: %s, different from wait ts: %s", searchRes.TipSet, res.TipSet)
}

}

func (ts *apiSuite) testID(t *testing.T) {
ctx := context.Background()
apis, _ := ts.makeNodes(t, kit.OneFull, kit.OneMiner)
api := apis[0]

id, err := api.ID(ctx)
full, _, _ := kit2.EnsembleMinimal(t, ts.opts...)

id, err := full.ID(ctx)
if err != nil {
t.Fatal(err)
}
assert.Regexp(t, "^12", id.Pretty())
require.Regexp(t, "^12", id.Pretty())
}

func (ts *apiSuite) testConnectTwo(t *testing.T) {
ctx := context.Background()
apis, _ := ts.makeNodes(t, kit.TwoFull, kit.OneMiner)

p, err := apis[0].NetPeers(ctx)
if err != nil {
t.Fatal(err)
}
if len(p) != 0 {
t.Error("Node 0 has a peer")
}
one, two, _, ens := kit2.EnsembleTwoOne(t, ts.opts...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: suggest renaming these ensemble methods to EnsembleTwoFullOneMiner etc for clarity

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, but I think that's too long. We can find a convention like:

kit2.Ensemble2M1F()

WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd err on the side of being verbose - more of a nitpick though, we can address in a later PR


p, err = apis[1].NetPeers(ctx)
if err != nil {
t.Fatal(err)
}
if len(p) != 0 {
t.Error("Node 1 has a peer")
}
p, err := one.NetPeers(ctx)
require.NoError(t, err)
require.Empty(t, p, "node one has peers")

addrs, err := apis[1].NetAddrsListen(ctx)
if err != nil {
t.Fatal(err)
}
p, err = two.NetPeers(ctx)
require.NoError(t, err)
require.Empty(t, p, "node two has peers")

if err := apis[0].NetConnect(ctx, addrs); err != nil {
t.Fatal(err)
}
ens.InterconnectAll()

p, err = apis[0].NetPeers(ctx)
if err != nil {
t.Fatal(err)
}
if len(p) != 1 {
t.Error("Node 0 doesn't have 1 peer")
}
peers, err := one.NetPeers(ctx)
require.NoError(t, err)
require.Lenf(t, peers, 2, "node one doesn't have 2 peers")

p, err = apis[1].NetPeers(ctx)
if err != nil {
t.Fatal(err)
}
if len(p) != 1 {
t.Error("Node 0 doesn't have 1 peer")
}
peers, err = two.NetPeers(ctx)
require.NoError(t, err)
require.Lenf(t, peers, 2, "node two doesn't have 2 peers")
}

func (ts *apiSuite) testMining(t *testing.T) {
func (ts *apiSuite) testSearchMsg(t *testing.T) {
ctx := context.Background()
fulls, miners := ts.makeNodes(t, kit.OneFull, kit.OneMiner)
api := fulls[0]

newHeads, err := api.ChainNotify(ctx)
full, _, ens := kit2.EnsembleMinimal(t, ts.opts...)

senderAddr, err := full.WalletDefaultAddress(ctx)
require.NoError(t, err)
initHead := (<-newHeads)[0]
baseHeight := initHead.Val.Height()

h1, err := api.ChainHead(ctx)
msg := &types.Message{
From: senderAddr,
To: senderAddr,
Value: big.Zero(),
}

ens.BeginMining(100 * time.Millisecond)

sm, err := full.MpoolPushMessage(ctx, msg, nil)
require.NoError(t, err)
require.Equal(t, int64(h1.Height()), int64(baseHeight))

bm := kit.NewBlockMiner(t, miners[0])
bm.MineUntilBlock(ctx, fulls[0], nil)
res, err := full.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
require.NoError(t, err)

<-newHeads
require.Equal(t, exitcode.Ok, res.Receipt.ExitCode, "message not successful")

h2, err := api.ChainHead(ctx)
searchRes, err := full.StateSearchMsg(ctx, types.EmptyTSK, sm.Cid(), lapi.LookbackNoLimit, true)
require.NoError(t, err)
require.Greater(t, int64(h2.Height()), int64(h1.Height()))
}

func (ts *apiSuite) testMiningReal(t *testing.T) {
build.InsecurePoStValidation = false
defer func() {
build.InsecurePoStValidation = true
}()
require.Equalf(t, res.TipSet, searchRes.TipSet, "search ts: %s, different from wait ts: %s", searchRes.TipSet, res.TipSet)
}

func (ts *apiSuite) testMining(t *testing.T) {
ctx := context.Background()
fulls, miners := ts.makeNodes(t, kit.OneFull, kit.OneMiner)
api := fulls[0]

newHeads, err := api.ChainNotify(ctx)
require.NoError(t, err)
at := (<-newHeads)[0].Val.Height()
full, miner, _ := kit2.EnsembleMinimal(t, ts.opts...)

h1, err := api.ChainHead(ctx)
newHeads, err := full.ChainNotify(ctx)
require.NoError(t, err)
require.Equal(t, int64(at), int64(h1.Height()))
initHead := (<-newHeads)[0]
baseHeight := initHead.Val.Height()

bm := kit.NewBlockMiner(t, miners[0])
h1, err := full.ChainHead(ctx)
require.NoError(t, err)
require.Equal(t, int64(h1.Height()), int64(baseHeight))

bm.MineUntilBlock(ctx, fulls[0], nil)
bm := kit2.NewBlockMiner(t, miner)
bm.MineUntilBlock(ctx, full, nil)
require.NoError(t, err)

<-newHeads

h2, err := api.ChainHead(ctx)
h2, err := full.ChainHead(ctx)
require.NoError(t, err)
require.Greater(t, int64(h2.Height()), int64(h1.Height()))

bm.MineUntilBlock(ctx, fulls[0], nil)
bm.MineUntilBlock(ctx, full, nil)
require.NoError(t, err)

<-newHeads

h3, err := api.ChainHead(ctx)
h3, err := full.ChainHead(ctx)
require.NoError(t, err)
require.Greater(t, int64(h3.Height()), int64(h2.Height()))
}

func (ts *apiSuite) testMiningReal(t *testing.T) {
build.InsecurePoStValidation = false
defer func() {
build.InsecurePoStValidation = true
}()

ts.testMining(t)
}

func (ts *apiSuite) testNonGenesisMiner(t *testing.T) {
ctx := context.Background()
n, sn := ts.makeNodes(t,
[]kit.FullNodeOpts{kit.FullNodeWithLatestActorsAt(-1)},
[]kit.StorageMiner{{Full: 0, Preseal: kit.PresealGenesis}},
)

full, ok := n[0].FullNode.(*impl.FullNodeAPI)
if !ok {
t.Skip("not testing with a full node")
return
}
genesisMiner := sn[0]

bm := kit.NewBlockMiner(t, genesisMiner)
bm.MineBlocks(ctx, 4*time.Millisecond)
t.Cleanup(bm.Stop)
full, genesisMiner, ens := kit2.EnsembleMinimal(t, ts.opts...)

ens.BeginMining(4 * time.Millisecond)

gaa, err := genesisMiner.ActorAddress(ctx)
require.NoError(t, err)

gmi, err := full.StateMinerInfo(ctx, gaa, types.EmptyTSK)
_, err = full.StateMinerInfo(ctx, gaa, types.EmptyTSK)
require.NoError(t, err)

testm := n[0].Stb(ctx, t, kit.TestSpt, gmi.Owner)
var newMiner kit2.TestMiner
ens.Miner(&newMiner, full, kit2.OwnerAddr(full.DefaultKey)).Start()

ta, err := testm.ActorAddress(ctx)
ta, err := newMiner.ActorAddress(ctx)
require.NoError(t, err)

tid, err := address.IDFromAddress(ta)
Expand Down
Loading