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

Refactoring integration tests #830

Merged
merged 15 commits into from
Feb 22, 2023

Conversation

yehor-blox
Copy link
Contributor

@yehor-blox yehor-blox commented Jan 31, 2023

refactor integration tests
remove F+1 test scenario

@yehor-blox yehor-blox marked this pull request as ready for review February 2, 2023 15:18
@yehor-blox yehor-blox marked this pull request as draft February 13, 2023 14:53
@yehor-blox yehor-blox force-pushed the refactoring-integration-tests branch 3 times, most recently from eebddfe to e05c34a Compare February 13, 2023 15:03
@yehor-blox yehor-blox marked this pull request as ready for review February 13, 2023 17:13
@yehor-blox yehor-blox changed the title DRAFT: Refactoring integration tests Refactoring integration tests Feb 13, 2023
Copy link
Contributor

@aaron-blox aaron-blox left a comment

Choose a reason for hiding this comment

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

some high level comments. was curious about code changes outside of integration test directory, if they are needed/intended to be in this PR

.github/workflows/unit-test.yml Show resolved Hide resolved
.github/workflows/lint.yml Show resolved Hide resolved
protocol/v2/ssv/validator/startup.go Outdated Show resolved Hide resolved
protocol/v2/ssv/validator/msgqueue_consumer.go Outdated Show resolved Hide resolved
protocol/v2/qbft/instance/instance.go Outdated Show resolved Hide resolved
integration/qbft/tests/utils.go Outdated Show resolved Hide resolved
integration/qbft/tests/utils.go Outdated Show resolved Hide resolved
integration/qbft/tests/utils.go Outdated Show resolved Hide resolved
network/p2p/test_utils.go Show resolved Hide resolved
network/p2p/test_utils.go Show resolved Hide resolved
Copy link
Contributor

@aaron-blox aaron-blox left a comment

Choose a reason for hiding this comment

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

please fix linting errors

yehor-blox and others added 2 commits February 16, 2023 10:47
Co-authored-by: aaron-blox <123868031+aaron-blox@users.noreply.github.com>

duty := createDuty(getKeySet(s.Committee).ValidatorPK.Serialize(), dutyProp.Slot, dutyProp.ValidatorIndex, role)
require.NoError(t, s.validators[id].StartDuty(duty))
}(id, dutyProp)
Copy link
Contributor

Choose a reason for hiding this comment

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

why not add to queue? in order to mock real behaviour

Copy link
Contributor

Choose a reason for hiding this comment

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

@egorka-sereda @aaron-blox this is resolved?

Copy link
Contributor

Choose a reason for hiding this comment

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

is resolved

// logging stored instance
jsonInstance, err := json.Marshal(storedInstance)
require.NoError(t, err)
fmt.Println(string(jsonInstance))
Copy link
Contributor

Choose a reason for hiding this comment

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

need to print it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, for debugging purposes

Copy link
Contributor

Choose a reason for hiding this comment

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

@egorka-sereda @aaron-blox not sure we need to print the instance.
maybe we can print just the state, or add some debug logging to tests for debug

Copy link
Contributor

Choose a reason for hiding this comment

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

is resolved

panic(err)
}

store := qbftstorage.New(db, logger, "integration-tests", protocolforks.GenesisForkVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

the prefix should be based on the role type and not "integration-tests"
so need to have different instance for each role type

Copy link
Contributor

Choose a reason for hiding this comment

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

resolved

@yehor-blox yehor-blox requested review from nivBlox and removed request for aaron-blox February 16, 2023 14:01
// logging stored instance
jsonInstance, err := json.Marshal(storedInstance)
require.NoError(t, err)
fmt.Println(string(jsonInstance))
Copy link
Contributor

Choose a reason for hiding this comment

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

@egorka-sereda @aaron-blox not sure we need to print the instance.
maybe we can print just the state, or add some debug logging to tests for debug

}

func getKeySet(committee int) *spectestingutils.TestKeySet {
switch committee {
Copy link
Contributor

Choose a reason for hiding this comment

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

@aaron-blox lets use here just the 3f+1 rule. and max to 13

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sometimes we need different number of participants than 4, 7, 10, 13
for example in f+1 decided we want to launch only 3 validators, but we need keysets for them as for 4 validators-committee

}

func quorum(committee int) int {
return (committee*2 + 1) / 3 // committee = 3f+1; quorum = 2f+1 // https://drive.google.com/file/d/1bP_MLq0MM7ZBSR0Ddh7HUPcc42vVUKwz/view?usp=share_link
Copy link
Contributor

Choose a reason for hiding this comment

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

lets remove google drive links.
If we feel we need it then add readme and resource folder in the integration folder

Copy link
Contributor

Choose a reason for hiding this comment

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

resolved

@@ -0,0 +1,111 @@
package tests
Copy link
Contributor

Choose a reason for hiding this comment

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

@aaron-blox while this is still WIP, lets remove from the github actions to run integration tests until they are stable.
you can create a regex rule to run it if the branch starts/ends with integration-test

Copy link
Contributor

Choose a reason for hiding this comment

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

resolved

@yehor-blox
Copy link
Contributor Author

fixed all comments
@lior-blox @aaron-blox
waiting for next review round
Thanks!

@aaron-blox aaron-blox self-requested a review February 20, 2023 12:11
Copy link
Contributor

@aaron-blox aaron-blox left a comment

Choose a reason for hiding this comment

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

i added a suggestion to change the comment but LGTM otherwise

Co-authored-by: aaron-blox <123868031+aaron-blox@users.noreply.github.com>
require.Fail(t, "no commit qourum")
}

require.Equal(t, int(spectypes.OperatorID(2)), int(actual.State.ProposeContainer.Msgs[2][0].Signers[0])) //on second round proposer is 2,
Copy link
Contributor

@aaron-blox aaron-blox Feb 21, 2023

Choose a reason for hiding this comment

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

you should add checks before doing slice access for everything here
actual.State.ProposeContainer.Msgs[2][0].Signers[0]
Each of these can cause a panic if you are trying to access something that does not exist, which can happen when the test fails

@aaron-blox aaron-blox self-requested a review February 21, 2023 10:00
branches:
- "main"
- "stage"
# push:
Copy link
Contributor

Choose a reason for hiding this comment

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

if no need, let's remove

require.Equal(t, int(qbft.FirstRound), int(actual.State.Round), "round not matching")

require.NotNil(t, actual.DecidedMessage, "no decided message")
if quorum(committee) > len(actual.DecidedMessage.Signers) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use require.Greater() instead

require.Equal(t, int(qbft.Round(2)), int(actual.State.Round), "round not matching")

require.NotNil(t, actual.DecidedMessage, "no decided message")
if quorum(committee) > len(actual.DecidedMessage.Signers) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use require.Greater() instead

panic(err)
}

store := qbftstorage.New(db, logger, role.String(), protocolforks.GenesisForkVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

need to create store for each role.
reference - operator/node.go:91

}

func GetSharedData(t *testing.T) SharedData { //singleton B-)
if sharedData == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use require.NotNil

@@ -17,6 +17,7 @@ func (c *Controller) UponFutureMsg(msg *specqbft.SignedMessage) (*specqbft.Signe
}
if c.f1SyncTrigger() {
c.logger.Debug("triggered f+1 sync",
zap.Any("operator-id", c.Share.OperatorID),
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not a place for this log. please revert. we can open a issue to add this if needed

@@ -52,7 +52,7 @@ func NewInstance(
config: config,
processMsgF: spectypes.NewThreadSafeF(),
metrics: newMetrics(msgId),
logger: logger.With(zap.String("publicKey", hex.EncodeToString(msgId.GetPubKey())), zap.String("role", msgId.GetRoleType().String()),
logger: logger.With(zap.Int("operator-id", int(share.OperatorID)), zap.String("publicKey", hex.EncodeToString(msgId.GetPubKey())), zap.String("role", msgId.GetRoleType().String()),
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert it as it not needed in this scope

@@ -102,7 +102,7 @@ func (v *Validator) ConsumeQueue(msgID spectypes.MessageID, handler MessageHandl

// Handle the message.
if err := handler(msg); err != nil {
v.logMsg(msg, "could not handle message", zap.Any("type", msg.SSVMessage.MsgType), zap.Error(err))
v.logMsg(msg, "could not handle message", zap.Int("operator-id", int(v.Share.OperatorID)), zap.Any("type", msg.SSVMessage.MsgType), zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove

@@ -20,6 +20,7 @@ func (v *Validator) Start() error {
for role, r := range v.DutyRunners {
share := r.GetBaseRunner().Share
if share == nil { // TODO: handle missing share?
v.logger.Warn("share is missing")
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add the runner role type to the log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants