-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
commands.go
80 lines (64 loc) · 1.79 KB
/
commands.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package internal
import (
"os"
"os/signal"
"syscall"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink/e2e-tests/docker/test_env"
"github.com/smartcontractkit/chainlink/e2e-tests/testconfig"
)
var NodeCountFlag = "node-count"
var StartNodesCmd = &cobra.Command{
Use: "start-nodes",
Short: "Start Chainlink nodes",
RunE: func(cmd *cobra.Command, _ []string) error {
nodeCount, err := cmd.Flags().GetInt(NodeCountFlag)
if err != nil {
return err
}
log.Logger = logging.GetLogger(nil, "CORE_DOCKER_ENV_LOG_LEVEL")
log.Info().Msg("Starting docker test env with Chainlink nodes..")
config, err := testconfig.GetConfig("Smoke", testconfig.OCR2)
if err != nil {
return err
}
ethBuilder := ctf_test_env.NewEthereumNetworkBuilder()
network, err := ethBuilder.
WithExistingConfig(*config.GetPrivateEthereumNetworkConfig()).
Build()
if err != nil {
return err
}
_, err = test_env.NewCLTestEnvBuilder().
WithTestConfig(&config).
WithPrivateEthereumNetwork(network.EthereumNetworkConfig).
WithMockAdapter().
WithCLNodes(nodeCount).
WithoutCleanup().
Build()
if err != nil {
return err
}
log.Info().Msg("Test env is ready")
handleExitSignal()
return nil
},
}
func init() {
StartNodesCmd.PersistentFlags().Int(
NodeCountFlag,
6,
"Number of Chainlink nodes",
)
}
func handleExitSignal() {
// Create a channel to receive exit signals
exitChan := make(chan os.Signal, 1)
signal.Notify(exitChan, os.Interrupt, syscall.SIGTERM)
log.Info().Msg("Press Ctrl+C to destroy the test environment")
// Block until an exit signal is received
<-exitChan
}