Skip to content

Commit

Permalink
Merge pull request #5265 from oasisprotocol/peternose/internal/upgrad…
Browse files Browse the repository at this point in the history
…e-tests-refactoring

go/oasis-test-runner: Refactor e2e tests
  • Loading branch information
peternose committed May 24, 2023
2 parents 372f56f + 28622d3 commit 9287700
Show file tree
Hide file tree
Showing 58 changed files with 922 additions and 946 deletions.
4 changes: 2 additions & 2 deletions .buildkite/scripts/test_e2e.sh
Expand Up @@ -50,11 +50,11 @@ ${test_runner_binary} \
--e2e.node.binary ${node_binary} \
--e2e/runtime.runtime.binary_dir.default ${WORKDIR}/target/default/debug \
--e2e/runtime.runtime.binary_dir.intel-sgx ${WORKDIR}/target/sgx/x86_64-fortanix-unknown-sgx/debug \
--e2e/runtime.runtime.source_dir ${WORKDIR}/tests/runtimes \
--e2e/runtime.runtime.target_dir ${WORKDIR}/target \
--e2e/runtime.runtime.loader ${WORKDIR}/target/default/debug/oasis-core-runtime-loader \
--e2e/runtime.tee_hardware ${OASIS_TEE_HARDWARE:-""} \
--e2e/runtime.ias.mock=${ias_mock} \
--e2e/runtime/trust-root/{simple,change,change-fails}.runtime.source_dir=${WORKDIR}/tests/runtimes \
--e2e/runtime/trust-root/{simple,change,change-fails}.runtime.target_dir=${WORKDIR}/target \
--remote-signer.binary ${WORKDIR}/go/oasis-remote-signer/oasis-remote-signer \
--plugin-signer.name example \
--plugin-signer.binary ${WORKDIR}/go/oasis-test-runner/scenario/pluginsigner/example_signer_plugin/example_signer_plugin \
Expand Down
Empty file added .changelog/5265.trivial.md
Empty file.
29 changes: 29 additions & 0 deletions go/oasis-test-runner/oasis/cli/registry.go
Expand Up @@ -7,9 +7,11 @@ import (
"path/filepath"
"strconv"

fileSigner "github.com/oasisprotocol/oasis-core/go/common/crypto/signature/signers/file"
cmdCommon "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common"
"github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/consensus"
"github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/flags"
cmdSigner "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/signer"
cmdRegRt "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/registry/runtime"
registry "github.com/oasisprotocol/oasis-core/go/registry/api"
)
Expand Down Expand Up @@ -53,3 +55,30 @@ func (r *RegistryHelpers) GenerateRegisterRuntimeTx(
}
return nil
}

// GenerateRegisterEntityTx is a wrapper for "registry entity gen_register" subcommand.
func (r *RegistryHelpers) GenerateRegisterEntityTx(
entDir string,
nonce uint64,
txPath string,
) error {
r.logger.Info("generating register entity tx")

args := []string{
"registry", "entity", "gen_register",
"--" + consensus.CfgTxNonce, strconv.FormatUint(nonce, 10),
"--" + consensus.CfgTxFile, txPath,
"--" + consensus.CfgTxFeeAmount, strconv.Itoa(0), // TODO: Make fee configurable.
"--" + consensus.CfgTxFeeGas, strconv.Itoa(10000), // TODO: Make fee configurable.
"--" + flags.CfgDebugDontBlameOasis,
"--" + cmdCommon.CfgDebugAllowTestKeys,
"--" + cmdSigner.CfgSigner, fileSigner.SignerName,
"--" + cmdSigner.CfgCLISignerDir, entDir,
"--" + flags.CfgGenesisFile, r.cfg.GenesisFile,
}

if out, err := r.runSubCommandWithOutput("registry-entity-gen_register", args); err != nil {
return fmt.Errorf("failed to run 'registry entity gen_register': error: %w output: %s", err, out.String())
}
return nil
}
8 changes: 8 additions & 0 deletions go/oasis-test-runner/oasis/entity.go
Expand Up @@ -52,6 +52,14 @@ func (ent *Entity) ID() signature.PublicKey {
return ent.entity.ID
}

// Dir returns the path to the entity directory.
func (ent *Entity) Dir() string {
if ent.isDebugTestEntity {
return ""
}
return ent.dir.String()
}

// EntityKeyPath returns the path to the entity private key.
func (ent *Entity) EntityKeyPath() string {
if ent.isDebugTestEntity {
Expand Down
2 changes: 2 additions & 0 deletions go/oasis-test-runner/oasis/fixture.go
Expand Up @@ -238,6 +238,7 @@ type RuntimeFixture struct { // nolint: maligned
Pruner RuntimePrunerCfg `json:"pruner,omitempty"`

ExcludeFromGenesis bool `json:"exclude_from_genesis,omitempty"`
KeepBundles bool `json:"keep_bundles,omitempty"`
}

// Create instantiates the runtime described by the fixture.
Expand Down Expand Up @@ -275,6 +276,7 @@ func (f *RuntimeFixture) Create(netFixture *NetworkFixture, net *Network) (*Runt
GenesisStateRoot: f.GenesisStateRoot,
Pruner: f.Pruner,
ExcludeFromGenesis: f.ExcludeFromGenesis,
KeepBundles: f.KeepBundles,
GovernanceModel: f.GovernanceModel,
Deployments: f.Deployments,
})
Expand Down
13 changes: 8 additions & 5 deletions go/oasis-test-runner/oasis/runtime.go
Expand Up @@ -81,6 +81,7 @@ type RuntimeCfg struct { // nolint: maligned
Pruner RuntimePrunerCfg

ExcludeFromGenesis bool
KeepBundles bool
}

// DeploymentCfg is a deployment configuration.
Expand Down Expand Up @@ -347,11 +348,13 @@ func (net *Network) NewRuntime(cfg *RuntimeCfg) (*Runtime, error) {
}

// Remove any dynamically generated bundles on cleanup.
net.env.AddOnCleanup(func() {
for _, path := range rt.BundlePaths() {
_ = os.Remove(path)
}
})
if !cfg.KeepBundles {
net.env.AddOnCleanup(func() {
for _, path := range rt.BundlePaths() {
_ = os.Remove(path)
}
})
}

// Save runtime descriptor into file.
rtDescStr, _ := json.Marshal(rt.descriptor)
Expand Down
12 changes: 6 additions & 6 deletions go/oasis-test-runner/scenario/e2e/byzantine_beacon_vrf.go
Expand Up @@ -16,7 +16,7 @@ const byzantineBeaconIdentitySeed = "ekiden byzantine node worker"
var (
// ByzantineVRFBeaconHonest is the honest byzantine VRF beacon scenario.
ByzantineVRFBeaconHonest scenario.Scenario = &byzantineVRFBeaconImpl{
E2E: *NewE2E("byzantine/beacon-vrf-honest"),
Scenario: *NewScenario("byzantine/beacon-vrf-honest"),
extraArgs: []oasis.Argument{
{Name: byzantine.CfgVRFBeaconMode, Values: []string{byzantine.ModeVRFBeaconHonest.String()}},
},
Expand All @@ -25,7 +25,7 @@ var (

// ByzantineVRFBeaconEarly is the early-proof byzantine beacon scenario.
ByzantineVRFBeaconEarly scenario.Scenario = &byzantineVRFBeaconImpl{
E2E: *NewE2E("byzantine/beacon-vrf-early"),
Scenario: *NewScenario("byzantine/beacon-vrf-early"),
extraArgs: []oasis.Argument{
{Name: byzantine.CfgVRFBeaconMode, Values: []string{byzantine.ModeVRFBeaconEarly.String()}},
},
Expand All @@ -34,7 +34,7 @@ var (

// ByzantineVRFBeaconMissing is the missing-proof byzantine beacon scenario.
ByzantineVRFBeaconMissing scenario.Scenario = &byzantineVRFBeaconImpl{
E2E: *NewE2E("byzantine/beacon-vrf-missing"),
Scenario: *NewScenario("byzantine/beacon-vrf-missing"),
extraArgs: []oasis.Argument{
{Name: byzantine.CfgVRFBeaconMode, Values: []string{byzantine.ModeVRFBeaconMissing.String()}},
},
Expand All @@ -43,22 +43,22 @@ var (
)

type byzantineVRFBeaconImpl struct {
E2E
Scenario

extraArgs []oasis.Argument
identitySeed string
}

func (sc *byzantineVRFBeaconImpl) Clone() scenario.Scenario {
return &byzantineVRFBeaconImpl{
E2E: sc.E2E.Clone(),
Scenario: sc.Scenario.Clone(),
extraArgs: sc.extraArgs,
identitySeed: sc.identitySeed,
}
}

func (sc *byzantineVRFBeaconImpl) Fixture() (*oasis.NetworkFixture, error) {
f, err := sc.E2E.Fixture()
f, err := sc.Scenario.Fixture()
if err != nil {
return nil, err
}
Expand Down
Expand Up @@ -215,7 +215,7 @@ var ChangeParametersMinCommissionRate scenario.Scenario = newConsensusParameterU
)

type consensusParameterUpgradeImpl struct {
E2E
Scenario

parameters *api.ChangeParametersProposal
upgradeChecker upgradeChecker
Expand All @@ -229,7 +229,7 @@ type consensusParameterUpgradeImpl struct {

func newConsensusParameterUpgradeImpl(name string, parameters *api.ChangeParametersProposal, upgradeChecker upgradeChecker) scenario.Scenario {
sc := &consensusParameterUpgradeImpl{
E2E: *NewE2E(name),
Scenario: *NewScenario(name),
ctx: context.Background(),
parameters: parameters,
upgradeChecker: upgradeChecker,
Expand All @@ -239,7 +239,7 @@ func newConsensusParameterUpgradeImpl(name string, parameters *api.ChangeParamet

func (sc *consensusParameterUpgradeImpl) Clone() scenario.Scenario {
return &consensusParameterUpgradeImpl{
E2E: sc.E2E.Clone(),
Scenario: sc.Scenario.Clone(),
parameters: sc.parameters,
upgradeChecker: sc.upgradeChecker,
currentEpoch: sc.currentEpoch,
Expand All @@ -249,7 +249,7 @@ func (sc *consensusParameterUpgradeImpl) Clone() scenario.Scenario {
}

func (sc *consensusParameterUpgradeImpl) Fixture() (*oasis.NetworkFixture, error) {
f, err := sc.E2E.Fixture()
f, err := sc.Scenario.Fixture()
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions go/oasis-test-runner/scenario/e2e/consensus_state_sync.go
Expand Up @@ -14,21 +14,21 @@ import (

// ConsensusStateSync is the consensus state sync scenario.
var ConsensusStateSync scenario.Scenario = &consensusStateSyncImpl{
E2E: *NewE2E("consensus-state-sync"),
Scenario: *NewScenario("consensus-state-sync"),
}

type consensusStateSyncImpl struct {
E2E
Scenario
}

func (sc *consensusStateSyncImpl) Clone() scenario.Scenario {
return &consensusStateSyncImpl{
E2E: sc.E2E.Clone(),
Scenario: sc.Scenario.Clone(),
}
}

func (sc *consensusStateSyncImpl) Fixture() (*oasis.NetworkFixture, error) {
f, err := sc.E2E.Fixture()
f, err := sc.Scenario.Fixture()
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions go/oasis-test-runner/scenario/e2e/debond.go
Expand Up @@ -14,21 +14,21 @@ import (

// Debond tests debonding records created in the genesis document.
var Debond scenario.Scenario = &debondImpl{
E2E: *NewE2E("debond"),
Scenario: *NewScenario("debond"),
}

type debondImpl struct {
E2E
Scenario
}

func (s *debondImpl) Clone() scenario.Scenario {
return &debondImpl{
E2E: s.E2E.Clone(),
Scenario: s.Scenario.Clone(),
}
}

func (s *debondImpl) Fixture() (*oasis.NetworkFixture, error) {
f, err := s.E2E.Fixture()
f, err := s.Scenario.Fixture()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 9287700

Please sign in to comment.