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

WIP Ensure the cli's test commands work | waiting PR 121 #119

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
77 changes: 77 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,75 @@ jobs:
TEST_RUSTPROOFS_LOGS: << parameters.proofs-log-test >>
SKIP_CONFORMANCE: "1"
CURIO_SRC_DIR: /home/circleci/project
CURIO_HARMONYDB_HOSTS: yugabyte
LOTUS_HARMONYDB_HOSTS: yugabyte
command: |
mkdir -p /tmp/test-reports/<< parameters.suite >>
mkdir -p /tmp/test-artifacts
dockerize -wait tcp://yugabyte:5433 -timeout 3m
env
gotestsum \
--format standard-verbose \
--junitfile /tmp/test-reports/<< parameters.suite >>/junit.xml \
--jsonfile /tmp/test-artifacts/<< parameters.suite >>.json \
--packages="<< parameters.target >>" \
-- << parameters.go-test-flags >>
no_output_timeout: 30m
- store_test_results:
path: /tmp/test-reports
- store_artifacts:
path: /tmp/test-artifacts/<< parameters.suite >>.json
test_with_chain:
description: |
Run tests with gotestsum.
working_directory: ~/curio
parameters: &test-params
resource_class:
type: string
default: medium+
go-test-flags:
type: string
default: "-timeout 20m"
description: Flags passed to go test.
target:
type: string
default: "./..."
description: Import paths of packages to be tested.
proofs-log-test:
type: string
default: "0"
get-params:
type: boolean
default: false
suite:
type: string
default: unit
description: Test suite name to report to CircleCI.
docker:
- image: cimg/go:1.22
environment:
CURIO_HARMONYDB_HOSTS: yugabyte
LOTUS_HARMONYDB_HOSTS: yugabyte
- image: yugabytedb/yugabyte:2.21.0.1-b1
command: bin/yugabyted start --daemon=false
name: yugabyte
resource_class: << parameters.resource_class >>
steps:
- install-ubuntu-deps
- attach_workspace:
at: ~/
- when:
condition: << parameters.get-params >>
steps:
- download-params
- run:
name: go test
environment:
TEST_RUSTPROOFS_LOGS: << parameters.proofs-log-test >>
SKIP_CONFORMANCE: "1"
CURIO_SRC_DIR: /home/circleci/project
CURIO_HARMONYDB_HOSTS: yugabyte
LOTUS_HARMONYDB_HOSTS: yugabyte
command: |
mkdir -p /tmp/test-reports/<< parameters.suite >>
mkdir -p /tmp/test-artifacts
Expand Down Expand Up @@ -274,3 +343,11 @@ workflows:
target: "./itests/curio_test.go"
get-params: true
resource_class: 2xlarge
- test_with_chain:
name: test-itest-chain
requires:
- build
suite: itest-chain
target: "./itests_with_chain/cli_post_test.go"
get-params: true
resource_class: 2xlarge
2 changes: 2 additions & 0 deletions cmd/curio/test-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ var wdPostTaskCmd = &cli.Command{
log.Infof("Tasks found in harmony_task: %v", found)
}
}
fmt.Println("All tasks completed successfully")
return nil
},
}
Expand Down Expand Up @@ -244,6 +245,7 @@ It will not send any messages to the chain. Since it can compute any deadline, o
}
}

fmt.Println("All tasks completed successfully")
return nil
},
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ require (
github.com/samber/lo v1.39.0
github.com/snadrus/must v0.0.0-20240605044437-98cedd57f8eb
github.com/stretchr/testify v1.9.0
github.com/test-go/testify v1.1.4
github.com/urfave/cli/v2 v2.25.5
github.com/whyrusleeping/cbor-gen v0.1.1
github.com/yugabyte/pgx/v5 v5.5.3-yb-2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,8 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE=
github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU=
github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
Expand Down
3 changes: 2 additions & 1 deletion harmony/harmonydb/harmonydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"math/rand"
"net"
"os"
"regexp"
"sort"
"strconv"
Expand Down Expand Up @@ -55,7 +56,7 @@ func NewFromConfig(cfg config.HarmonyDB) (*DB, error) {
cfg.Password,
cfg.Database,
cfg.Port,
"",
ITestID(os.Getenv("CURIO_ITEST_DO_NOT_USE")), // ONLY for testing
)
}

Expand Down
16 changes: 9 additions & 7 deletions itests/curio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ import (
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

var dbConfig = config.HarmonyDB{
Hosts: []string{envElse("CURIO_HARMONYDB_HOSTS", "127.0.0.1")},
Database: "yugabyte",
Username: "yugabyte",
Password: "yugabyte",
Port: "5433",
}

func TestCurioNewActor(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -63,13 +71,7 @@ func TestCurioNewActor(t *testing.T) {
require.NoError(t, err)

sharedITestID := harmonydb.ITestNewID()
dbConfig := config.HarmonyDB{
Hosts: []string{envElse("CURIO_HARMONYDB_HOSTS", "127.0.0.1")},
Database: "yugabyte",
Username: "yugabyte",
Password: "yugabyte",
Port: "5433",
}

db, err := harmonydb.NewFromConfigWithITestID(t, dbConfig, sharedITestID)
require.NoError(t, err)

Expand Down
39 changes: 39 additions & 0 deletions itests_with_chain/cli_post_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package itests

import (
"bytes"
"io"
"os"
"os/exec"
"strconv"
"testing"

"github.com/test-go/testify/require"
"golang.org/x/exp/rand"
)

type CliThing struct {
*exec.Cmd
*bytes.Buffer
}

func CliEnv() func(name string, args ...string) *CliThing {
snadrus marked this conversation as resolved.
Show resolved Hide resolved
itest := "CURIO_ITEST_DO_NOT_USE=" + strconv.Itoa(rand.Intn(99999))
return func(name string, args ...string) *CliThing {
cmd := exec.Command(name, args...)
cmd.Env = append(cmd.Env, itest)
cmd.Env = append(cmd.Env, "PATH="+os.Getenv("PATH"))
b := &bytes.Buffer{}
cmd.Stdout = io.MultiWriter(os.Stdout, b)
cmd.Stderr = io.MultiWriter(os.Stderr, b)
return &CliThing{cmd, b}
}
}
func TestCliPost(t *testing.T) {
thistest := CliEnv()
require.NoError(t, os.WriteFile("/tmp/base.toml", []byte(""), 0644))
require.NoError(t, thistest("../curio", "config", "set", "/tmp/base.toml").Run())
cmd := thistest("../curio", "test", "window-post", "here")
require.NoError(t, cmd.Run())
require.Equal(t, "All tasks complete\n", cmd.Buffer.String())
}