From 9ae780902afff4fe501b10dd23aa0d4d6052e78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 14 Jun 2021 22:08:19 +0200 Subject: [PATCH 1/4] Test multicore SDR support --- .../sector-storage/ffiwrapper/sealer_test.go | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/extern/sector-storage/ffiwrapper/sealer_test.go b/extern/sector-storage/ffiwrapper/sealer_test.go index 5d96f187fe3..25a37e47076 100644 --- a/extern/sector-storage/ffiwrapper/sealer_test.go +++ b/extern/sector-storage/ffiwrapper/sealer_test.go @@ -31,6 +31,7 @@ import ( "github.com/filecoin-project/specs-storage/storage" ffi "github.com/filecoin-project/filecoin-ffi" + "github.com/filecoin-project/filecoin-ffi/generated" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper/basicfs" @@ -38,7 +39,34 @@ import ( "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader" ) +var rustLogger = func() *bytes.Buffer { + os.Setenv("RUST_LOG", "info") + + var bb bytes.Buffer + r, w, err := os.Pipe() + if err != nil { + panic(err) + } + + go func() { + _, _ = io.Copy(&bb, r) + runtime.KeepAlive(w) + }() + + resp := generated.FilInitLogFd(int32(w.Fd())) + resp.Deref() + + defer generated.FilDestroyInitLogFdResponse(resp) + + if resp.StatusCode != generated.FCPResponseStatusFCPNoError { + panic(generated.RawString(resp.ErrorMsg).Copy()) + } + + return &bb +}() + func init() { + rustLogger.Reset() logging.SetLogLevel("*", "DEBUG") //nolint: errcheck } @@ -853,3 +881,59 @@ func TestAddPiece512MPadded(t *testing.T) { require.Equal(t, "baga6ea4seaqonenxyku4o7hr5xkzbqsceipf6xgli3on54beqbk6k246sbooobq", c.PieceCID.String()) } + +func TestMulticoreSDR(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + + getGrothParamFileAndVerifyingKeys(sectorSize) + + dir, err := ioutil.TempDir("", "sbtest") + if err != nil { + t.Fatal(err) + } + + miner := abi.ActorID(123) + + sp := &basicfs.Provider{ + Root: dir, + } + sb, err := New(sp) + if err != nil { + t.Fatalf("%+v", err) + } + + cleanup := func() { + if t.Failed() { + fmt.Printf("not removing %s\n", dir) + return + } + if err := os.RemoveAll(dir); err != nil { + t.Error(err) + } + } + defer cleanup() + + si := storage.SectorRef{ + ID: abi.SectorID{Miner: miner, Number: 1}, + ProofType: sealProofType, + } + + s := seal{ref: si} + + // check multicore + _ = os.Setenv("FIL_PROOFS_USE_MULTICORE_SDR", "1") + rustLogger.Reset() + s.precommit(t, sb, si, func() {}) + + ok := false + for _, s := range strings.Split(rustLogger.String(), "\n") { + if strings.Contains(s, "create_label::multi") { + ok = true + break + } + } + + require.True(t, ok) +} From 265afd696edc462da8a339638fb3c6059d009ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 15 Jun 2021 17:46:06 +0200 Subject: [PATCH 2/4] Run TestMulticoreSDR on Circle --- .circleci/config.yml | 12 ++++++++++++ extern/sector-storage/ffiwrapper/sealer_test.go | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5edc0cdaca6..d76be4bdc3b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -133,6 +133,9 @@ jobs: deadline-test: type: string default: "0" + proofs-log-test: + type: string + default: "0" test-suite-name: type: string default: unit @@ -167,6 +170,7 @@ jobs: environment: LOTUS_TEST_WINDOW_POST: << parameters.winpost-test >> LOTUS_TEST_DEADLINE_TOGGLING: << parameters.deadline-test >> + TEST_RUSTPROOFS_LOGS: << parameters.proofs-log-test >> SKIP_CONFORMANCE: "1" command: | mkdir -p /tmp/test-reports/<< parameters.test-suite-name >> @@ -212,6 +216,8 @@ jobs: <<: *test test-terminate: <<: *test + check-proofs-multicore-sdr: + <<: *test test-conformance: description: | Run tests using a corpus of interoperable test vectors for Filecoin @@ -815,6 +821,12 @@ workflows: tags: only: - /^v\d+\.\d+\.\d+(-rc\d+)?$/ + - check-proofs-multicore-sdr: + codecov-upload: true + go-test-flags: "-run=TestMulticoreSDR" + test-suite-name: multicore-sdr-check + packages: "./extern/sector-storage/ffiwrapper" + proofs-log-test: "1" - test-conformance: test-suite-name: conformance packages: "./conformance" diff --git a/extern/sector-storage/ffiwrapper/sealer_test.go b/extern/sector-storage/ffiwrapper/sealer_test.go index 25a37e47076..f0d27203c89 100644 --- a/extern/sector-storage/ffiwrapper/sealer_test.go +++ b/extern/sector-storage/ffiwrapper/sealer_test.go @@ -883,8 +883,8 @@ func TestAddPiece512MPadded(t *testing.T) { } func TestMulticoreSDR(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode") + if os.Getenv("TEST_RUSTPROOFS_LOGS") != "1" { + t.Skip("skipping test without TEST_RUSTPROOFS_LOGS=1") } getGrothParamFileAndVerifyingKeys(sectorSize) From 6b0aed9317c52c556f6161634c02524212072811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 15 Jun 2021 17:53:26 +0200 Subject: [PATCH 3/4] Setup rust logger in the test --- .../sector-storage/ffiwrapper/sealer_test.go | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/extern/sector-storage/ffiwrapper/sealer_test.go b/extern/sector-storage/ffiwrapper/sealer_test.go index f0d27203c89..f88fdc8d0ac 100644 --- a/extern/sector-storage/ffiwrapper/sealer_test.go +++ b/extern/sector-storage/ffiwrapper/sealer_test.go @@ -39,34 +39,7 @@ import ( "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader" ) -var rustLogger = func() *bytes.Buffer { - os.Setenv("RUST_LOG", "info") - - var bb bytes.Buffer - r, w, err := os.Pipe() - if err != nil { - panic(err) - } - - go func() { - _, _ = io.Copy(&bb, r) - runtime.KeepAlive(w) - }() - - resp := generated.FilInitLogFd(int32(w.Fd())) - resp.Deref() - - defer generated.FilDestroyInitLogFdResponse(resp) - - if resp.StatusCode != generated.FCPResponseStatusFCPNoError { - panic(generated.RawString(resp.ErrorMsg).Copy()) - } - - return &bb -}() - func init() { - rustLogger.Reset() logging.SetLogLevel("*", "DEBUG") //nolint: errcheck } @@ -882,7 +855,35 @@ func TestAddPiece512MPadded(t *testing.T) { require.Equal(t, "baga6ea4seaqonenxyku4o7hr5xkzbqsceipf6xgli3on54beqbk6k246sbooobq", c.PieceCID.String()) } +func setupLogger(t *testing.T) *bytes.Buffer { + _ = os.Setenv("RUST_LOG", "info") + + var bb bytes.Buffer + r, w, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + + go func() { + _, _ = io.Copy(&bb, r) + runtime.KeepAlive(w) + }() + + resp := generated.FilInitLogFd(int32(w.Fd())) + resp.Deref() + + defer generated.FilDestroyInitLogFdResponse(resp) + + if resp.StatusCode != generated.FCPResponseStatusFCPNoError { + t.Fatal(generated.RawString(resp.ErrorMsg).Copy()) + } + + return &bb +} + func TestMulticoreSDR(t *testing.T) { + rustLogger := setupLogger(t) + if os.Getenv("TEST_RUSTPROOFS_LOGS") != "1" { t.Skip("skipping test without TEST_RUSTPROOFS_LOGS=1") } From c7c593c74e03d8ba3b591b2e4a8eaa76ff25933d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 15 Jun 2021 17:59:46 +0200 Subject: [PATCH 4/4] TestMulticoreSDR: Setup rust logger after envvar check --- extern/sector-storage/ffiwrapper/sealer_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/sector-storage/ffiwrapper/sealer_test.go b/extern/sector-storage/ffiwrapper/sealer_test.go index f88fdc8d0ac..7f0dc914ff0 100644 --- a/extern/sector-storage/ffiwrapper/sealer_test.go +++ b/extern/sector-storage/ffiwrapper/sealer_test.go @@ -882,12 +882,12 @@ func setupLogger(t *testing.T) *bytes.Buffer { } func TestMulticoreSDR(t *testing.T) { - rustLogger := setupLogger(t) - if os.Getenv("TEST_RUSTPROOFS_LOGS") != "1" { t.Skip("skipping test without TEST_RUSTPROOFS_LOGS=1") } + rustLogger := setupLogger(t) + getGrothParamFileAndVerifyingKeys(sectorSize) dir, err := ioutil.TempDir("", "sbtest")