diff --git a/.github/workflows/e2e-nightly-master.yml b/.github/workflows/e2e-nightly-master.yml index 6d1a2c1a7..a498a72bf 100644 --- a/.github/workflows/e2e-nightly-master.yml +++ b/.github/workflows/e2e-nightly-master.yml @@ -16,6 +16,7 @@ jobs: strategy: fail-fast: false matrix: + p2p: ['legacy', 'new', 'hybrid'] group: ['00', '01', '02', '03'] runs-on: ubuntu-latest timeout-minutes: 60 @@ -34,11 +35,12 @@ jobs: - name: Generate testnets working-directory: test/e2e # 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 - 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: needs: e2e-nightly-test-2 diff --git a/test/e2e/generator/generate.go b/test/e2e/generator/generate.go index 2d84fab69..4c6f3ebbe 100644 --- a/test/e2e/generator/generate.go +++ b/test/e2e/generator/generate.go @@ -16,7 +16,7 @@ var ( testnetCombinations = map[string][]interface{}{ "topology": {"single", "quad", "large"}, "ipv6": {false, true}, - "useNewP2P": {false, true, 2}, + "p2p": {NewP2PMode, LegacyP2PMode, HybridP2PMode}, "queueType": {"priority"}, // "fifo", "wdrr" "initialHeight": {0, 1000}, "initialState": { @@ -48,8 +48,15 @@ var ( ) // 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{} + switch opts.P2P { + case NewP2PMode, LegacyP2PMode, HybridP2PMode: + testnetCombinations["p2p"] = []interface{}{opts.P2P} + default: + testnetCombinations["p2p"] = []interface{}{NewP2PMode, LegacyP2PMode, HybridP2PMode} + } + for _, opt := range combinations(testnetCombinations) { manifest, err := generateTestnet(r, opt) if err != nil { @@ -60,6 +67,20 @@ func Generate(r *rand.Rand) ([]e2e.Manifest, error) { 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. func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, error) { manifest := e2e.Manifest{ @@ -76,12 +97,16 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er 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 - 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 @@ -92,10 +117,10 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er numValidators = 4 case "large": // FIXME Networks are kept small since large ones use too much CPU. - numSeeds = r.Intn(3) + numSeeds = r.Intn(2) numLightClients = r.Intn(3) - numValidators = 4 + r.Intn(7) - numFulls = r.Intn(5) + numValidators = 4 + r.Intn(4) + numFulls = r.Intn(4) default: return manifest, fmt.Errorf("unknown topology %q", opt["topology"]) } diff --git a/test/e2e/generator/main.go b/test/e2e/generator/main.go index f17b4f3f4..a965fb720 100644 --- a/test/e2e/generator/main.go +++ b/test/e2e/generator/main.go @@ -45,25 +45,39 @@ func NewCLI() *CLI { if err != nil { 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.MarkPersistentFlagRequired("dir") 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 } // 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) if err != nil { return err } - manifests, err := Generate(rand.New(rand.NewSource(randomSeed))) + manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), opts) if err != nil { return err }