Browse Source

e2e: split out nightly tests (#6395)

pull/6401/head
Callum Waters 4 years ago
committed by GitHub
parent
commit
be2ac87ab0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 16 deletions
  1. +5
    -3
      .github/workflows/e2e-nightly-master.yml
  2. +35
    -10
      test/e2e/generator/generate.go
  3. +17
    -3
      test/e2e/generator/main.go

+ 5
- 3
.github/workflows/e2e-nightly-master.yml View File

@ -16,6 +16,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
p2p: ['legacy', 'new', 'hybrid']
group: ['00', '01', '02', '03'] group: ['00', '01', '02', '03']
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 60 timeout-minutes: 60
@ -34,11 +35,12 @@ jobs:
- name: Generate testnets - name: Generate testnets
working-directory: test/e2e working-directory: test/e2e
# When changing -g, also change the matrix groups above # When changing -g, also change the matrix groups above
run: ./build/generator -g 4 -d networks/nightly
run: ./build/generator -g 4 -d networks/nightly/{{ matrix.p2p }} -p {{ matrix.p2p }}
- name: Run testnets in group ${{ matrix.group }}
- name: Run {{ matrix.p2p }} p2p testnets in group ${{ matrix.group }}
working-directory: test/e2e working-directory: test/e2e
run: ./run-multiple.sh networks/nightly/*-group${{ matrix.group }}-*.toml
run: ./run-multiple.sh networks/nightly/{{ matrix.p2p }}/*-group${{ matrix.group
}}-*.toml
e2e-nightly-fail-2: e2e-nightly-fail-2:
needs: e2e-nightly-test-2 needs: e2e-nightly-test-2


+ 35
- 10
test/e2e/generator/generate.go View File

@ -16,7 +16,7 @@ var (
testnetCombinations = map[string][]interface{}{ testnetCombinations = map[string][]interface{}{
"topology": {"single", "quad", "large"}, "topology": {"single", "quad", "large"},
"ipv6": {false, true}, "ipv6": {false, true},
"useNewP2P": {false, true, 2},
"p2p": {NewP2PMode, LegacyP2PMode, HybridP2PMode},
"queueType": {"priority"}, // "fifo", "wdrr" "queueType": {"priority"}, // "fifo", "wdrr"
"initialHeight": {0, 1000}, "initialHeight": {0, 1000},
"initialState": { "initialState": {
@ -48,8 +48,15 @@ var (
) )
// Generate generates random testnets using the given RNG. // Generate generates random testnets using the given RNG.
func Generate(r *rand.Rand) ([]e2e.Manifest, error) {
func Generate(r *rand.Rand, opts Options) ([]e2e.Manifest, error) {
manifests := []e2e.Manifest{} manifests := []e2e.Manifest{}
switch opts.P2P {
case NewP2PMode, LegacyP2PMode, HybridP2PMode:
testnetCombinations["p2p"] = []interface{}{opts.P2P}
default:
testnetCombinations["p2p"] = []interface{}{NewP2PMode, LegacyP2PMode, HybridP2PMode}
}
for _, opt := range combinations(testnetCombinations) { for _, opt := range combinations(testnetCombinations) {
manifest, err := generateTestnet(r, opt) manifest, err := generateTestnet(r, opt)
if err != nil { if err != nil {
@ -60,6 +67,20 @@ func Generate(r *rand.Rand) ([]e2e.Manifest, error) {
return manifests, nil return manifests, nil
} }
type Options struct {
P2P P2PMode
}
type P2PMode string
const (
NewP2PMode P2PMode = "new"
LegacyP2PMode P2PMode = "legacy"
HybridP2PMode P2PMode = "hybrid"
// mixed means that all combination are generated
MixedP2PMode P2PMode = "mixed"
)
// generateTestnet generates a single testnet with the given options. // generateTestnet generates a single testnet with the given options.
func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, error) { func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, error) {
manifest := e2e.Manifest{ manifest := e2e.Manifest{
@ -76,12 +97,16 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
var p2pNodeFactor int var p2pNodeFactor int
switch p2pInfo := opt["useNewP2P"].(type) {
case bool:
manifest.DisableLegacyP2P = p2pInfo
case int:
switch opt["p2p"].(P2PMode) {
case NewP2PMode:
manifest.DisableLegacyP2P = true
case LegacyP2PMode:
manifest.DisableLegacyP2P = false manifest.DisableLegacyP2P = false
p2pNodeFactor = p2pInfo
case HybridP2PMode:
manifest.DisableLegacyP2P = false
p2pNodeFactor = 2
default:
return manifest, fmt.Errorf("unknown p2p mode %s", opt["p2p"])
} }
var numSeeds, numValidators, numFulls, numLightClients int var numSeeds, numValidators, numFulls, numLightClients int
@ -92,10 +117,10 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
numValidators = 4 numValidators = 4
case "large": case "large":
// FIXME Networks are kept small since large ones use too much CPU. // FIXME Networks are kept small since large ones use too much CPU.
numSeeds = r.Intn(3)
numSeeds = r.Intn(2)
numLightClients = r.Intn(3) numLightClients = r.Intn(3)
numValidators = 4 + r.Intn(7)
numFulls = r.Intn(5)
numValidators = 4 + r.Intn(4)
numFulls = r.Intn(4)
default: default:
return manifest, fmt.Errorf("unknown topology %q", opt["topology"]) return manifest, fmt.Errorf("unknown topology %q", opt["topology"])
} }


+ 17
- 3
test/e2e/generator/main.go View File

@ -45,25 +45,39 @@ func NewCLI() *CLI {
if err != nil { if err != nil {
return err return err
} }
return cli.generate(dir, groups)
p2pMode, err := cmd.Flags().GetString("p2p")
if err != nil {
return err
}
var opts Options
switch p2pMode {
case "new", "legacy", "split", "mixed":
opts = Options{P2P: P2PMode(p2pMode)}
default:
return fmt.Errorf("p2p mode must be either new, legacy, split or mixed got %s", p2pMode)
}
return cli.generate(dir, groups, opts)
}, },
} }
cli.root.PersistentFlags().StringP("dir", "d", "", "Output directory for manifests") cli.root.PersistentFlags().StringP("dir", "d", "", "Output directory for manifests")
_ = cli.root.MarkPersistentFlagRequired("dir") _ = cli.root.MarkPersistentFlagRequired("dir")
cli.root.PersistentFlags().IntP("groups", "g", 0, "Number of groups") cli.root.PersistentFlags().IntP("groups", "g", 0, "Number of groups")
cli.root.PersistentFlags().StringP("p2p", "p", string(MixedP2PMode),
"P2P typology to be generated [\"new\", \"legacy\", \"hybrid\" or \"mixed\" ]")
return cli return cli
} }
// generate generates manifests in a directory. // generate generates manifests in a directory.
func (cli *CLI) generate(dir string, groups int) error {
func (cli *CLI) generate(dir string, groups int, opts Options) error {
err := os.MkdirAll(dir, 0755) err := os.MkdirAll(dir, 0755)
if err != nil { if err != nil {
return err return err
} }
manifests, err := Generate(rand.New(rand.NewSource(randomSeed)))
manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), opts)
if err != nil { if err != nil {
return err return err
} }


Loading…
Cancel
Save