diff --git a/README.md b/README.md index 47a46d55..2679ba6e 100644 --- a/README.md +++ b/README.md @@ -54,17 +54,17 @@ Further details on how to proceed in each case are provided below. ### From GitHub -We have created a mock-avs repository to understand the structure of an AVS Node Software package and to test all the features of the `eigenlayer` CLI tool. The following command shows how to install `mock-avs` using the `eigenlayer` tool: +We have created a mock-avs-pkg repository to understand the structure of an AVS Node Software package and to test all the features of the `eigenlayer` CLI tool. The following command shows how to install `mock-avs-pkg` using the `eigenlayer` tool: ```bash -eigenlayer install https://github.com/NethermindEth/mock-avs +eigenlayer install https://github.com/NethermindEth/mock-avs-pkg ``` Executing this command triggers an interactive installation process. During this process, the user can manually select the desired profile and all necessary options. Below is the final output after options have been selected. ```bash INFO[0000] Version not specified, using latest. -INFO[0000] Using version v3.1.0 +INFO[0000] Using version v5.4.0 ? Select a profile option-returner ? main-container-name option-returner ? main-port 8080 @@ -89,14 +89,14 @@ To skip the interactive installation, the user can use the available flags of th $ eigenlayer install \ --profile option-returner \ --no-prompt \ - https://github.com/NethermindEth/mock-avs + https://github.com/NethermindEth/mock-avs-pkg ``` Output: ```bash INFO[0000] Version not specified, using latest. -INFO[0000] Using version v3.1.0 +INFO[0000] Using version v5.4.0 INFO[0002] Installed successfully with instance id: mock-avs-default INFO[0002] The installed node software has a plugin. ``` @@ -113,14 +113,14 @@ $ eigenlayer install \ --profile option-returner \ --no-prompt \ --option.main-port 8081 \ - https://github.com/NethermindEth/mock-avs + https://github.com/NethermindEth/mock-avs-pkg ``` Output: ```bash INFO[0000] Version not specified, using latest. -INFO[0000] Using version v3.1.0 +INFO[0000] Using version v5.4.0 INFO[0002] Installed successfully with instance id: mock-avs-default INFO[0002] The installed node software has a plugin. ``` @@ -131,20 +131,20 @@ In this case, the `main-port` has a value of 8081 instead of the default value o > THIS INSTALLATION METHOD IS INSECURE -Installing from a local directory can be helpful for AVS developers who want to test Node Software packaging before releasing it to a public Git repository. To install an AVS Node Software from a local directory, use the `eigenlayer local-install` command. To illustrate local installation, let's clone the `mock-avs` to a local directory, and use it as a local package. +Installing from a local directory can be helpful for AVS developers who want to test Node Software packaging before releasing it to a public Git repository. To install an AVS Node Software from a local directory, use the `eigenlayer local-install` command. To illustrate local installation, let's clone the `mock-avs-pkg` to a local directory, and use it as a local package. -First, clone the `mock-avs` package: +First, clone the `mock-avs-pkg` package: > If you already have a local package, you can skip this step ```bash -git clone --branch v3.1.0 https://github.com/NethermindEth/mock-avs +git clone --branch v5.4.0 https://github.com/NethermindEth/mock-avs-pkg ``` -Now we can install the package from the `mock-avs` directory with the following command: +Now we can install the package from the `mock-avs-pkg` directory with the following command: ```bash -eigenlayer local-install ./mock-avs --profile option-returner +eigenlayer local-install ./mock-avs-pkg --profile option-returner ``` Output: diff --git a/cli/init_test.go b/cli/init_test.go new file mode 100644 index 00000000..63eac312 --- /dev/null +++ b/cli/init_test.go @@ -0,0 +1,12 @@ +package cli + +import ( + "github.com/NethermindEth/eigenlayer/internal/common" +) + +func init() { + err := common.SetMockAVSs() + if err != nil { + panic(err) + } +} diff --git a/cli/install.go b/cli/install.go index e3075acc..4703caed 100644 --- a/cli/install.go +++ b/cli/install.go @@ -170,6 +170,7 @@ the user to know which options are available for each profile. } instanceId, err := d.Install(daemon.InstallOptions{ + Name: pullResult.Name, URL: url, Version: pullResult.Version, SpecVersion: pullResult.SpecVersion, diff --git a/cli/install_test.go b/cli/install_test.go index aa6fee3b..1d07a5a2 100644 --- a/cli/install_test.go +++ b/cli/install_test.go @@ -10,6 +10,7 @@ import ( daemonMock "github.com/NethermindEth/eigenlayer/cli/mocks" prompterMock "github.com/NethermindEth/eigenlayer/cli/prompter/mocks" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/NethermindEth/eigenlayer/pkg/daemon" ) @@ -37,7 +38,7 @@ func TestInstall(t *testing.T) { }, { name: "valid arguments, run confirmed", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: nil, daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -47,9 +48,9 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -73,20 +74,20 @@ func TestInstall(t *testing.T) { d.EXPECT().InitMonitoring(false, false).Return(nil), d.EXPECT(). Install(daemon.InstallOptions{ - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "profile1", Options: []daemon.Option{option}, Tag: "default", - }).Return("mock-avs-default", nil), + }).Return("mock-avs-pkg-default", nil), p.EXPECT().Confirm("Run the new instance now?").Return(true, nil), - d.EXPECT().Run("mock-avs-default").Return(nil), + d.EXPECT().Run("mock-avs-pkg-default").Return(nil), ) }, }, { name: "valid arguments, run confirmed, init monitoring error", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: assert.AnError, daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -96,9 +97,9 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -115,7 +116,7 @@ func TestInstall(t *testing.T) { }, { name: "valid arguments, run confirmed and failed", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: assert.AnError, daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -125,9 +126,9 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -141,20 +142,20 @@ func TestInstall(t *testing.T) { d.EXPECT().InitMonitoring(false, false).Return(nil), d.EXPECT(). Install(daemon.InstallOptions{ - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "profile1", Options: []daemon.Option{option}, Tag: "default", - }).Return("mock-avs-default", nil), + }).Return("mock-avs-pkg-default", nil), p.EXPECT().Confirm("Run the new instance now?").Return(true, nil), - d.EXPECT().Run("mock-avs-default").Return(assert.AnError), + d.EXPECT().Run("mock-avs-pkg-default").Return(assert.AnError), ) }, }, { name: "valid arguments, run confirm error", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: assert.AnError, daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -164,9 +165,9 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -180,19 +181,19 @@ func TestInstall(t *testing.T) { d.EXPECT().InitMonitoring(false, false).Return(nil), d.EXPECT(). Install(daemon.InstallOptions{ - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "profile1", Options: []daemon.Option{option}, Tag: "default", - }).Return("mock-avs-default", nil), + }).Return("mock-avs-pkg-default", nil), p.EXPECT().Confirm("Run the new instance now?").Return(true, assert.AnError), ) }, }, { name: "valid arguments, with --yes", - args: []string{"https://github.com/NethermindEth/mock-avs", "--yes"}, + args: []string{common.MockAvsPkg.Repo(), "--yes"}, err: nil, daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -202,9 +203,9 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -218,19 +219,19 @@ func TestInstall(t *testing.T) { d.EXPECT().InitMonitoring(false, false).Return(nil), d.EXPECT(). Install(daemon.InstallOptions{ - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "profile1", Options: []daemon.Option{option}, Tag: "default", - }).Return("mock-avs-default", nil), - d.EXPECT().Run("mock-avs-default").Return(nil), + }).Return("mock-avs-pkg-default", nil), + d.EXPECT().Run("mock-avs-pkg-default").Return(nil), ) }, }, { name: "valid arguments, with --yes, run error", - args: []string{"https://github.com/NethermindEth/mock-avs", "--yes"}, + args: []string{common.MockAvsPkg.Repo(), "--yes"}, err: assert.AnError, daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -240,9 +241,9 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -256,19 +257,19 @@ func TestInstall(t *testing.T) { d.EXPECT().InitMonitoring(false, false).Return(nil), d.EXPECT(). Install(daemon.InstallOptions{ - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "profile1", Options: []daemon.Option{option}, Tag: "default", - }).Return("mock-avs-default", nil), - d.EXPECT().Run("mock-avs-default").Return(assert.AnError), + }).Return("mock-avs-pkg-default", nil), + d.EXPECT().Run("mock-avs-pkg-default").Return(assert.AnError), ) }, }, { name: "input string error", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: errors.New("input string error"), daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -278,9 +279,9 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -296,24 +297,24 @@ func TestInstall(t *testing.T) { }, { name: "pull error", - args: []string{"-v", "v3.1.1", "https://github.com/NethermindEth/mock-avs"}, + args: []string{"-v", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()}, err: errors.New("pull error"), daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{Version: "v3.1.1"}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{Version: common.MockAvsPkg.Version()}, true). Return(daemon.PullResult{}, errors.New("pull error")) }, }, { name: "select profile error", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: errors.New("select profile error"), daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {}, }, @@ -324,14 +325,14 @@ func TestInstall(t *testing.T) { }, { name: "invalid profile", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: errors.New("profile invalid-profile not found"), daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {}, }, @@ -342,7 +343,7 @@ func TestInstall(t *testing.T) { }, { name: "install error", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: errors.New("install error"), daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -352,9 +353,9 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -366,25 +367,25 @@ func TestInstall(t *testing.T) { d.EXPECT().InitMonitoring(false, false).Return(nil), d.EXPECT(). Install(daemon.InstallOptions{ - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "profile1", Options: []daemon.Option{option}, Tag: "default", - }).Return("mock-avs-default", errors.New("install error")), + }).Return("mock-avs-pkg-default", errors.New("install error")), ) }, }, { name: "hardware requirements not met", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: errors.New("hardware requirements not met"), daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {}, }, @@ -409,14 +410,14 @@ func TestInstall(t *testing.T) { }, { name: "hardware not met and stop", - args: []string{"https://github.com/NethermindEth/mock-avs"}, + args: []string{common.MockAvsPkg.Repo()}, err: errors.New("profile profile1 does not meet the hardware requirements"), daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{}, true). Return(daemon.PullResult{ - Version: "v3.1.1", + Version: common.MockAvsPkg.Version(), Options: map[string][]daemon.Option{ "profile1": {}, }, @@ -441,7 +442,7 @@ func TestInstall(t *testing.T) { }, { name: "commit specified", - args: []string{"--commit", "d1d4bb7009549c431d7b3317f004a56e2c3b2031", "https://github.com/NethermindEth/mock-avs"}, + args: []string{"--commit", common.MockAvsPkg.CommitHash(), common.MockAvsPkg.Repo()}, err: nil, daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) { option := daemonMock.NewMockOption(gomock.NewController(t)) @@ -451,10 +452,10 @@ func TestInstall(t *testing.T) { gomock.InOrder( d.EXPECT(). - Pull("https://github.com/NethermindEth/mock-avs", daemon.PullTarget{Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031"}, true). + Pull(common.MockAvsPkg.Repo(), daemon.PullTarget{Commit: common.MockAvsPkg.CommitHash()}, true). Return(daemon.PullResult{ - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Options: map[string][]daemon.Option{ "profile1": {option}, }, @@ -478,15 +479,15 @@ func TestInstall(t *testing.T) { d.EXPECT().InitMonitoring(false, false).Return(nil), d.EXPECT(). Install(daemon.InstallOptions{ - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Profile: "profile1", Options: []daemon.Option{option}, Tag: "default", - }).Return("mock-avs-default", nil), + }).Return("mock-avs-pkg-default", nil), p.EXPECT().Confirm("Run the new instance now?").Return(true, nil), - d.EXPECT().Run("mock-avs-default").Return(nil), + d.EXPECT().Run("mock-avs-pkg-default").Return(nil), ) }, }, diff --git a/cli/local_install.go b/cli/local_install.go index 6b38edc7..38d54f03 100644 --- a/cli/local_install.go +++ b/cli/local_install.go @@ -86,9 +86,7 @@ profile.`, if err != nil { return err } - if name == "" { - name = filepath.Base(path) - } + name = filepath.Base(path) return nil }, RunE: func(cmd *cobra.Command, args []string) error { @@ -145,7 +143,6 @@ profile.`, } cmd.Flags().BoolVar(&logDebug, "log-debug", false, "enable debug logs") cmd.Flags().BoolVarP(&run, "run", "r", false, "run the new instance after installation") - cmd.Flags().StringVar(&name, "name", "", "name to use for the new instance name. If not specified, the directory name will be used.") cmd.Flags().StringVarP(&profile, "profile", "p", "", "profile to use for the new instance. If not specified, the installation will fail.") cmd.Flags().StringVarP(&tag, "tag", "t", "default", "tag to use for the new instance.") return &cmd diff --git a/cli/ls_test.go b/cli/ls_test.go index e62cbe87..5f49dca9 100644 --- a/cli/ls_test.go +++ b/cli/ls_test.go @@ -5,6 +5,7 @@ import ( "testing" daemonMock "github.com/NethermindEth/eigenlayer/cli/mocks" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/NethermindEth/eigenlayer/pkg/daemon" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" @@ -27,22 +28,22 @@ func TestList(t *testing.T) { Running: true, Health: daemon.NodeHealthy, Comment: "comment1", - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, { ID: "id2", Running: false, Health: daemon.NodeHealthUnknown, Comment: "comment2", - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, nil) }, stdOut: []byte( "AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT \n" + - "id1 true healthy v3.1.1 d1d4bb700954 comment1 \n" + - "id2 false unknown v3.1.1 d1d4bb700954 comment2 \n", + "id1 true healthy " + common.MockAvsPkg.Version() + " " + common.MockAvsPkg.CommitHash()[:12] + " comment1 \n" + + "id2 false unknown " + common.MockAvsPkg.Version() + " " + common.MockAvsPkg.CommitHash()[:12] + " comment2 \n", ), }, { @@ -54,22 +55,22 @@ func TestList(t *testing.T) { Running: true, Health: daemon.NodeHealthy, Comment: "comment1", - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, { ID: "id2", Running: false, Health: daemon.NodeHealthUnknown, Comment: "comment2", - Version: "v3.1.1", - Commit: "d1d4bb7", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash()[:7], }, }, nil) }, stdOut: []byte( "AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT \n" + - "id1 true healthy v3.1.1 d1d4bb700954 comment1 \n" + - "id2 false unknown v3.1.1 d1d4bb7 comment2 \n", + "id1 true healthy " + common.MockAvsPkg.Version() + " " + common.MockAvsPkg.CommitHash()[:12] + " comment1 \n" + + "id2 false unknown " + common.MockAvsPkg.Version() + " " + common.MockAvsPkg.CommitHash()[:7] + " comment2 \n", ), }, { diff --git a/cli/utils_test.go b/cli/utils_test.go index d509503d..00ff3d6b 100644 --- a/cli/utils_test.go +++ b/cli/utils_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/stretchr/testify/assert" ) @@ -20,28 +21,28 @@ func TestValidateURL(t *testing.T) { }, { name: "HTTP URL", - url: "http://github.com/NethermidEth/mock-avs.git", + url: "http://github.com/NethermindEth/mock-avs-pkg.git", err: nil, }, { name: "HTTPS URL", - url: "https://github.com/NethermidEth/mock-avs.git", + url: common.MockAvsPkg.Repo() + ".git", err: nil, }, { name: "non HTTP or HTTPS URL", - url: "ftp://github.com/NethermidEth/mock-avs.git", + url: "ftp://github.com/NethermidEth/mock-avs-pkg.git", err: fmt.Errorf("%w: URL must be HTTP or HTTPS", ErrInvalidURL), }, { name: "URL with IP instead of domain", - url: "https://80.58.61.250/NethermidEth/mock-avs.git", + url: "https://80.58.61.250/NethermidEth/mock-avs-pkg.git", err: nil, }, { name: "non absolute URL", - url: "github.com/NethermidEth/mock-avs.git", - err: fmt.Errorf("%w: parse \"github.com/NethermidEth/mock-avs.git\": invalid URI for request", ErrInvalidURL), + url: "github.com/NethermidEth/mock-avs-pkg.git", + err: fmt.Errorf("%w: parse \"github.com/NethermidEth/mock-avs-pkg.git\": invalid URI for request", ErrInvalidURL), }, } for _, tc := range ts { diff --git a/e2e/init_test.go b/e2e/init_test.go new file mode 100644 index 00000000..0573a5b6 --- /dev/null +++ b/e2e/init_test.go @@ -0,0 +1,12 @@ +package e2e + +import ( + "github.com/NethermindEth/eigenlayer/internal/common" +) + +func init() { + err := common.SetMockAVSs() + if err != nil { + panic(err) + } +} diff --git a/e2e/install_test.go b/e2e/install_test.go index 673d19bf..a6a27d8f 100644 --- a/e2e/install_test.go +++ b/e2e/install_test.go @@ -4,16 +4,11 @@ import ( "testing" "time" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -const ( - mockAVSRepo = "https://github.com/NethermindEth/mock-avs" - latestMockAVSVersion = "v5.2.0" - latestMockAVSCommitHash = "a7ca2dca2cc9a91cdab8f30c2daf86a5f2dc4c55" -) - func TestInstall_WithoutArguments(t *testing.T) { // Test context var ( @@ -52,7 +47,7 @@ func TestInstall_ValidArgument(t *testing.T) { }, // Act func(t *testing.T, egnPath string) { - runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { @@ -82,7 +77,7 @@ func TestInstall_FromCommitHash(t *testing.T) { }, // Act func(t *testing.T, egnPath string) { - runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--commit", latestMockAVSCommitHash, mockAVSRepo) + runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--commit", common.MockAvsPkg.CommitHash(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { @@ -119,7 +114,7 @@ func TestInstall_ValidArgumentWithMonitoring(t *testing.T) { }, // Act func(t *testing.T, egnPath string) { - runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { @@ -154,7 +149,7 @@ func TestInstall_ValidArgumentNotRun(t *testing.T) { }, // Act func(t *testing.T, egnPath string) { - runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { @@ -180,11 +175,11 @@ func TestInstall_DuplicatedID(t *testing.T) { if err := buildMockAvsImages(t); err != nil { return err } - return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--tag", "integration", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--tag", "integration", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Act func(t *testing.T, egnPath string) { - runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--tag", "integration", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--tag", "integration", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { @@ -217,13 +212,13 @@ func TestInstall_DuplicatedContainerNameWithMonitoring(t *testing.T) { if err != nil { return err } - return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Act func(t *testing.T, egnPath string) { // Uses different tag, but docker compose create will fail because of duplicated container name // The install should fail but the monitoring stack should be running and the instance should be cleaned up - runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--tag", "integration", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--tag", "integration", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { @@ -261,9 +256,9 @@ func TestInstall_MultipleAVS(t *testing.T) { }, // Act func(t *testing.T, egnPath string) { - runErr[0] = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--tag", "option-returner-1", "--option.main-container-name", "main-service-1", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") - runErr[1] = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--tag", "option-returner-2", "--option.main-container-name", "main-service-2", "--option.main-port", "8081", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") - runErr[2] = runCommand(t, egnPath, "install", "--profile", "health-checker", "--no-prompt", "--tag", "health-checker", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr[0] = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--tag", "option-returner-1", "--option.main-container-name", "main-service-1", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) + runErr[1] = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--tag", "option-returner-2", "--option.main-container-name", "main-service-2", "--option.main-port", "8081", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) + runErr[2] = runCommand(t, egnPath, "install", "--profile", "health-checker", "--no-prompt", "--tag", "health-checker", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { @@ -309,11 +304,11 @@ func TestInstall_MultipleAVSWithMonitoring(t *testing.T) { }, // Act func(t *testing.T, egnPath string) { - runErr[0] = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--tag", "option-returner-1", "--option.main-container-name", "main-service-1", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr[0] = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--tag", "option-returner-1", "--option.main-container-name", "main-service-1", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) time.Sleep(5 * time.Second) - runErr[1] = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--tag", "option-returner-2", "--option.main-container-name", "main-service-2", "--option.main-port", "8081", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr[1] = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--tag", "option-returner-2", "--option.main-container-name", "main-service-2", "--option.main-port", "8081", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) time.Sleep(5 * time.Second) - runErr[2] = runCommand(t, egnPath, "install", "--profile", "health-checker", "--no-prompt", "--yes", "--tag", "health-checker", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr[2] = runCommand(t, egnPath, "install", "--profile", "health-checker", "--no-prompt", "--yes", "--tag", "health-checker", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { @@ -358,7 +353,7 @@ func TestInstall_HighRequirements(t *testing.T) { }, // Act func(t *testing.T, egnPath string) { - runErr = runCommand(t, egnPath, "install", "--profile", "high-requirements", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + runErr = runCommand(t, egnPath, "install", "--profile", "high-requirements", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { diff --git a/e2e/local_install_test.go b/e2e/local_install_test.go index 28884fac..d7b1180e 100644 --- a/e2e/local_install_test.go +++ b/e2e/local_install_test.go @@ -5,6 +5,7 @@ import ( "path/filepath" "testing" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -28,7 +29,7 @@ func TestLocalInstall(t *testing.T) { if err != nil { return err } - err = runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err = runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } @@ -72,7 +73,7 @@ func TestLocalInstallNotRunning(t *testing.T) { if err != nil { return err } - err = runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err = runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } @@ -117,7 +118,7 @@ func TestLocalInstallWithMonitoring(t *testing.T) { if err != nil { return err } - err = runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err = runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } @@ -166,7 +167,7 @@ func TestLocalInstallInvalidManifest(t *testing.T) { if err != nil { return err } - err = runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err = runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } @@ -213,7 +214,7 @@ func TestLocalInstallInvalidManifestCleanup(t *testing.T) { if err != nil { return err } - err = runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err = runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } @@ -265,7 +266,7 @@ func TestLocalInstallInvalidManifestCleanupWithMonitoring(t *testing.T) { if err != nil { return err } - err = runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err = runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } @@ -315,7 +316,7 @@ func TestLocalInstallInvalidComposeCleanup(t *testing.T) { if err != nil { return err } - err = runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err = runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } @@ -366,7 +367,7 @@ func TestLocalInstall_DuplicatedContainerNameWithMonitoring(t *testing.T) { if err != nil { return err } - err = runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err = runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } diff --git a/e2e/ls_test.go b/e2e/ls_test.go index 762e5340..ffda379c 100644 --- a/e2e/ls_test.go +++ b/e2e/ls_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/NethermindEth/eigenlayer/internal/data" "github.com/stretchr/testify/assert" ) @@ -44,7 +45,7 @@ func TestLs_NotRunning(t *testing.T) { if err != nil { return err } - return runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + return runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, func(t *testing.T, eigenlayerPath string) { out, lsErr = runCommandOutput(t, eigenlayerPath, "ls") @@ -53,7 +54,7 @@ func TestLs_NotRunning(t *testing.T) { assert.NoError(t, lsErr, "ls command should not return an error") assert.Equal(t, out, []byte( "AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT \n"+ - "mock-avs-default false unknown "+latestMockAVSVersion+" a7ca2dca2cc9 \n", + "mock-avs-default false unknown "+common.MockAvsPkg.Version()+" "+common.MockAvsPkg.CommitHash()[:12]+" \n", )) }) e2eTest.run() @@ -71,7 +72,7 @@ func TestLs_RunningHealthy(t *testing.T) { if err != nil { return err } - err = runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -84,7 +85,7 @@ func TestLs_RunningHealthy(t *testing.T) { assert.NoError(t, lsErr, "ls command should not return an error") assert.Equal(t, out, []byte( "AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT \n"+ - "mock-avs-default true healthy "+latestMockAVSVersion+" a7ca2dca2cc9 \n", + "mock-avs-default true healthy "+common.MockAvsPkg.Version()+" "+common.MockAvsPkg.CommitHash()[:12]+" \n", )) }) e2eTest.run() @@ -102,7 +103,7 @@ func TestLs_RunningPartiallyHealthy(t *testing.T) { if err != nil { return err } - err = runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -119,7 +120,7 @@ func TestLs_RunningPartiallyHealthy(t *testing.T) { assert.NoError(t, lsErr, "ls command should not return an error") assert.Equal(t, out, []byte( "AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT \n"+ - "mock-avs-default true partially healthy "+latestMockAVSVersion+" a7ca2dca2cc9 \n", + "mock-avs-default true partially healthy "+common.MockAvsPkg.Version()+" "+common.MockAvsPkg.CommitHash()[:12]+" \n", )) }) e2eTest.run() @@ -137,7 +138,7 @@ func TestLs_RunningUnhealthy(t *testing.T) { if err != nil { return err } - err = runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -154,7 +155,7 @@ func TestLs_RunningUnhealthy(t *testing.T) { assert.NoError(t, lsErr, "ls command should not return an error") assert.Equal(t, out, []byte( "AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT \n"+ - "mock-avs-default true unhealthy "+latestMockAVSVersion+" a7ca2dca2cc9 \n", + "mock-avs-default true unhealthy "+common.MockAvsPkg.Version()+" "+common.MockAvsPkg.CommitHash()[:12]+" \n", )) }) e2eTest.run() @@ -173,7 +174,7 @@ func TestLs_Comment(t *testing.T) { if err != nil { return err } - err = runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, eigenlayerPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -202,7 +203,7 @@ func TestLs_Comment(t *testing.T) { } assert.Equal(t, []byte( "AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT"+ds+" \n"+ - "mock-avs-default true unknown "+latestMockAVSVersion+" a7ca2dca2cc9 API container is running but health check failed: Get \"http://"+containerIP+":8081/eigen/node/health\": dial tcp "+containerIP+":8081: connect: connection refused \n", + "mock-avs-default true unknown "+common.MockAvsPkg.Version()+" "+common.MockAvsPkg.CommitHash()[:12]+" API container is running but health check failed: Get \"http://"+containerIP+":8081/eigen/node/health\": dial tcp "+containerIP+":8081: connect: connection refused \n", ), out) }) e2eTest.run() diff --git a/e2e/monitoring_stack_test.go b/e2e/monitoring_stack_test.go index c98a48c9..39310e66 100644 --- a/e2e/monitoring_stack_test.go +++ b/e2e/monitoring_stack_test.go @@ -3,6 +3,7 @@ package e2e import ( "testing" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/stretchr/testify/assert" ) @@ -135,7 +136,7 @@ func TestMonitoring_Restart(t *testing.T) { if err != nil { return err } - err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--tag", "tag-1", "--option.main-container-name", "main-service-1", "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--tag", "tag-1", "--option.main-container-name", "main-service-1", common.MockAvsPkg.Repo()) if err != nil { return err } @@ -147,7 +148,7 @@ func TestMonitoring_Restart(t *testing.T) { }, // Act func(t *testing.T, egnPath string) { - runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--tag", "tag-2", "--option.main-container-name", "main-service-2", "--option.network-name", "eigenlayer-2", "--option.main-port", "8081", "https://github.com/NethermindEth/mock-avs") + runErr = runCommand(t, egnPath, "install", "--profile", "option-returner", "--yes", "--no-prompt", "--tag", "tag-2", "--option.main-container-name", "main-service-2", "--option.network-name", "eigenlayer-2", "--option.main-port", "8081", common.MockAvsPkg.Repo()) }, // Assert func(t *testing.T) { diff --git a/e2e/plugin_test.go b/e2e/plugin_test.go index 96927147..bd4b875f 100644 --- a/e2e/plugin_test.go +++ b/e2e/plugin_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/NethermindEth/eigenlayer/e2e/docker" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/NethermindEth/eigenlayer/internal/package_handler" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -33,7 +34,7 @@ func TestPlugin_LocalInstall(t *testing.T) { if err := os.MkdirAll(pkgDir, 0o755); err != nil { return err } - err := runCommand(t, "git", "clone", "--single-branch", "-b", latestMockAVSVersion, mockAVSRepo, pkgDir) + err := runCommand(t, "git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir) if err != nil { return err } @@ -103,7 +104,7 @@ func TestPlugin_Install_Run(t *testing.T) { if err := buildMockAvsImages(t); err != nil { return err } - return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Act func(t *testing.T, egnPath string) { @@ -123,7 +124,7 @@ func TestPlugin_Install_Run(t *testing.T) { require.NoError(t, err, "docker events should succeed") events.CheckInOrder(t, - docker.NewContainerCreated("mock-avs-plugin:latest", &pluginContainerID), + docker.NewContainerCreated(common.PluginImage.Image(), &pluginContainerID), docker.NewNetworkConnect(&pluginContainerID, &networkID), docker.NewNetworkDisconnect(&pluginContainerID, &networkID), docker.NewContainerDies(&pluginContainerID), @@ -150,7 +151,7 @@ func TestPlugin_Volume_File(t *testing.T) { if err := buildMockAvsImages(t); err != nil { return err } - err := runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err := runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -187,7 +188,7 @@ func TestPlugin_Volume_File(t *testing.T) { require.NoError(t, err, "docker events should succeed") events.CheckInOrder(t, - docker.NewContainerCreated("mock-avs-plugin:latest", &pluginContainerID), + docker.NewContainerCreated(common.PluginImage.Image(), &pluginContainerID), docker.NewNetworkConnect(&pluginContainerID, &networkID), docker.NewNetworkDisconnect(&pluginContainerID, &networkID), docker.NewContainerDies(&pluginContainerID), @@ -215,7 +216,7 @@ func TestPlugin_Volume_Existing_Dir(t *testing.T) { if err := buildMockAvsImages(t); err != nil { return err } - err := runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err := runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -254,7 +255,7 @@ func TestPlugin_Volume_Existing_Dir(t *testing.T) { require.NoError(t, err, "docker events should succeed") events.CheckInOrder(t, - docker.NewContainerCreated("mock-avs-plugin:latest", &pluginContainerID), + docker.NewContainerCreated(common.PluginImage.Image(), &pluginContainerID), docker.NewNetworkConnect(&pluginContainerID, &networkID), docker.NewNetworkDisconnect(&pluginContainerID, &networkID), docker.NewContainerDies(&pluginContainerID), @@ -282,7 +283,7 @@ func TestPlugin_Volume_NonExisting_Dir(t *testing.T) { if err := buildMockAvsImages(t); err != nil { return err } - err := runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err := runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -319,7 +320,7 @@ func TestPlugin_Volume_NonExisting_Dir(t *testing.T) { require.NoError(t, err, "docker events should succeed") events.CheckInOrder(t, - docker.NewContainerCreated("mock-avs-plugin:latest", &pluginContainerID), + docker.NewContainerCreated(common.PluginImage.Image(), &pluginContainerID), docker.NewNetworkConnect(&pluginContainerID, &networkID), docker.NewNetworkDisconnect(&pluginContainerID, &networkID), docker.NewContainerDies(&pluginContainerID), @@ -344,7 +345,7 @@ func TestPlugin_Install_Run_HostNetwork(t *testing.T) { if err := buildMockAvsImages(t); err != nil { return err } - return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, // Act func(t *testing.T, egnPath string) { @@ -362,7 +363,7 @@ func TestPlugin_Install_Run_HostNetwork(t *testing.T) { require.NoError(t, err, "docker events should succeed") events.CheckInOrder(t, - docker.NewContainerCreated("mock-avs-plugin:latest", &pluginContainerID), + docker.NewContainerCreated(common.PluginImage.Image(), &pluginContainerID), docker.NewContainerDies(&pluginContainerID), docker.NewContainerDestroy(&pluginContainerID), ) @@ -387,7 +388,7 @@ func TestPlugin_ExitsWithError(t *testing.T) { if err := buildMockAvsImages(t); err != nil { return err } - err := runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err := runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -424,7 +425,7 @@ func TestPlugin_ExitsWithError(t *testing.T) { require.NoError(t, err, "docker events should succeed") events.CheckInOrder(t, - docker.NewContainerCreated("mock-avs-plugin:latest", &pluginContainerID), + docker.NewContainerCreated(common.PluginImage.Image(), &pluginContainerID), docker.NewNetworkConnect(&pluginContainerID, &networkID), docker.NewNetworkDisconnect(&pluginContainerID, &networkID), docker.NewContainerDies(&pluginContainerID), diff --git a/e2e/run_test.go b/e2e/run_test.go index 4bff3c4c..f970bd72 100644 --- a/e2e/run_test.go +++ b/e2e/run_test.go @@ -5,6 +5,7 @@ import ( "time" "github.com/NethermindEth/eigenlayer/e2e/docker" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/stretchr/testify/require" ) @@ -21,7 +22,7 @@ func Test_Run(t *testing.T) { if err != nil { return err } - return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + return runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) }, func(t *testing.T, egnPath string) { runErr = runCommand(t, egnPath, "run", "mock-avs-default") @@ -49,7 +50,7 @@ func Test_Run_StoppedInstance(t *testing.T) { if err != nil { return err } - err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -81,7 +82,7 @@ func Test_Run_AlreadyRunningInstance(t *testing.T) { if err != nil { return err } - err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } diff --git a/e2e/stop_test.go b/e2e/stop_test.go index 71b740cb..584084d0 100644 --- a/e2e/stop_test.go +++ b/e2e/stop_test.go @@ -5,6 +5,7 @@ import ( "time" "github.com/NethermindEth/eigenlayer/e2e/docker" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/stretchr/testify/require" ) @@ -21,7 +22,7 @@ func Test_Stop(t *testing.T) { if err != nil { return err } - err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } diff --git a/e2e/uninstall_test.go b/e2e/uninstall_test.go index b095c541..afdc0973 100644 --- a/e2e/uninstall_test.go +++ b/e2e/uninstall_test.go @@ -5,6 +5,7 @@ import ( "time" "github.com/NethermindEth/eigenlayer/e2e/docker" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/stretchr/testify/require" ) @@ -22,7 +23,7 @@ func Test_Uninstall(t *testing.T) { return err } // Install the mock-avs option-returner profile - err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } @@ -55,7 +56,7 @@ func Test_Uninstall_After_Stop(t *testing.T) { return err } // Install the mock-avs option-returner profile - err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", latestMockAVSVersion, "https://github.com/NethermindEth/mock-avs") + err = runCommand(t, egnPath, "install", "--profile", "option-returner", "--no-prompt", "--yes", "--version", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo()) if err != nil { return err } diff --git a/e2e/utils.go b/e2e/utils.go index c957f893..09cd0c6c 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/NethermindEth/eigenlayer/internal/data" "github.com/cenkalti/backoff" "github.com/docker/docker/api/types" @@ -36,15 +37,15 @@ func runCommandOutput(t *testing.T, path string, args ...string) ([]byte, error) func buildMockAvsImages(t *testing.T) error { t.Helper() - err := runCommand(t, "docker", "build", "-t", "mock-avs-option-returner:latest", "https://github.com/NethermindEth/mock-avs-src.git#main:option-returner") + err := runCommand(t, "docker", "build", "-t", common.OptionReturnerImage.Image(), "https://github.com/NethermindEth/mock-avs.git#main:option-returner") if err != nil { return err } - err = runCommand(t, "docker", "build", "-t", "mock-avs-plugin:latest", "https://github.com/NethermindEth/mock-avs-src.git#main:plugin") + err = runCommand(t, "docker", "build", "-t", common.PluginImage.Image(), "https://github.com/NethermindEth/mock-avs.git#main:plugin") if err != nil { return err } - return runCommand(t, "docker", "build", "-t", "mock-avs-health-checker:latest", "https://github.com/NethermindEth/mock-avs-src.git#main:health-checker") + return runCommand(t, "docker", "build", "-t", common.HealthCheckerImage.Image(), "https://github.com/NethermindEth/mock-avs.git#main:health-checker") } func repoPath(t *testing.T) string { diff --git a/internal/common/mock-avs.go b/internal/common/mock-avs.go new file mode 100644 index 00000000..db6b1cad --- /dev/null +++ b/internal/common/mock-avs.go @@ -0,0 +1,156 @@ +package common + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "time" + + "github.com/cenkalti/backoff" + log "github.com/sirupsen/logrus" +) + +const ( + mockAVSRepo = "https://github.com/NethermindEth/mock-avs" + mockAVSPkgRepo = "https://github.com/NethermindEth/mock-avs-pkg" + optionReturnerImageName = "mock-avs-option-returner" + healthCheckerImageName = "mock-avs-health-checker" + pluginImageName = "mock-avs-plugin" +) + +var ( + MockAvsSrc MockAVS + MockAvsPkg MockAVS + OptionReturnerImage MockAVSImage + HealthCheckerImage MockAVSImage + PluginImage MockAVSImage +) + +type MockAVS struct { + repo string + version string + commitHash string +} + +func NewMockAVS(repo string, version string, commitHash string) *MockAVS { + return &MockAVS{ + repo: repo, + version: version, + commitHash: commitHash, + } +} + +func (m *MockAVS) Repo() string { + return m.repo +} + +func (m *MockAVS) Version() string { + return m.version +} + +func (m *MockAVS) CommitHash() string { + return m.commitHash +} + +type MockAVSImage struct { + image string +} + +func NewMockAVSImage(image, tag string) *MockAVSImage { + return &MockAVSImage{ + image: fmt.Sprintf("%s:%s", image, tag), + } +} + +func (m *MockAVSImage) Image() string { + return m.image +} + +type Tag struct { + Name string `json:"name"` + Commit struct { + Sha string `json:"sha"` + } `json:"commit"` +} + +func latestGitTagAndCommitHash(repoURL string) (string, string, error) { + // Extract the repo owner and name from the URL + parts := strings.Split(strings.TrimRight(strings.TrimPrefix(repoURL, "https://github.com/"), "/"), "/") + if len(parts) != 2 { + return "", "", fmt.Errorf("invalid repo URL") + } + owner, repo := parts[0], parts[1] + + // GitHub API endpoint to get tags + apiURL := fmt.Sprintf("https://api.github.com/repos/%s/%s/tags", owner, repo) + + var tag, commitHash string + + operation := func() error { + resp, err := http.Get(apiURL) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != 200 { + return fmt.Errorf("failed to fetch data from GitHub API, status code: %d", resp.StatusCode) + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + var tags []Tag + if err := json.Unmarshal(body, &tags); err != nil { + return err + } + + if len(tags) == 0 { + return fmt.Errorf("no tags found in the repository") + } + + log.Debugf("Latest Tag: %s\nCommit Hash: %s\n", tags[0].Name, tags[0].Commit.Sha) + tag = tags[0].Name + commitHash = tags[0].Commit.Sha + return nil + } + + // Using exponential backoff for retries + bo := backoff.NewExponentialBackOff() + bo.MaxElapsedTime = 5 * time.Second + if err := backoff.Retry(operation, bo); err != nil { + return "", "", err + } + + return tag, commitHash, nil +} + +// SetMockAVSs set up the MockAVS and MockAVSPkg data structures with +// the latest versions of the mock-avs and mock-avs-pkg repositories. +// It also sets up the OptionReturnerImage, HealthCheckerImage and +// PluginImage data structures using as tag the latest version of the +// mock-avs repository. +func SetMockAVSs() error { + repos := []string{mockAVSRepo, mockAVSPkgRepo} + for _, repo := range repos { + tag, commitHash, err := latestGitTagAndCommitHash(repo) + if err != nil { + return err + } + if repo == mockAVSRepo { + MockAvsSrc = *NewMockAVS(repo, tag, commitHash) + } else { + MockAvsPkg = *NewMockAVS(repo, tag, commitHash) + } + } + + OptionReturnerImage = *NewMockAVSImage(optionReturnerImageName, MockAvsSrc.Version()) + HealthCheckerImage = *NewMockAVSImage(healthCheckerImageName, MockAvsSrc.Version()) + PluginImage = *NewMockAVSImage(pluginImageName, MockAvsSrc.Version()) + + return nil +} diff --git a/internal/common/spec.go b/internal/common/spec.go new file mode 100644 index 00000000..9b9b8e94 --- /dev/null +++ b/internal/common/spec.go @@ -0,0 +1,5 @@ +package common + +const ( + SpecVersion = "v0.1.0" +) diff --git a/internal/data/datadir_test.go b/internal/data/datadir_test.go index 72dcc32b..632c376b 100644 --- a/internal/data/datadir_test.go +++ b/internal/data/datadir_test.go @@ -7,6 +7,7 @@ import ( "path/filepath" "testing" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/NethermindEth/eigenlayer/internal/locker/mocks" "github.com/golang/mock/gomock" "github.com/spf13/afero" @@ -94,7 +95,7 @@ func TestDataDir_Instance(t *testing.T) { if err != nil { t.Fatal(err) } - _, err = stateFile.WriteString(`{"name":"mock-avs","url":"https://github.com/NethermindEth/mock-avs","version":"v2.0.2","profile":"option-returner","tag":"default"}`) + _, err = stateFile.WriteString(`{"name":"mock-avs","url":"` + common.MockAvsPkg.Repo() + `","version":"` + common.MockAvsPkg.Version() + `","profile":"option-returner","tag":"default"}`) if err != nil { t.Fatal(err) } @@ -104,8 +105,8 @@ func TestDataDir_Instance(t *testing.T) { path: path, instance: &Instance{ Name: "mock-avs", - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v2.0.2", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Tag: "default", Profile: "option-returner", path: filepath.Join(path, nodesDirName, "mock-avs-default"), @@ -126,7 +127,7 @@ func TestDataDir_Instance(t *testing.T) { if err != nil { t.Fatal(err) } - _, err = stateFile.WriteString(`{"url":"https://github.com/NethermindEth/mock-avs","version":"v2.0.2","profile":"option-returner","tag":"default"}`) + _, err = stateFile.WriteString(`{"url":"` + common.MockAvsPkg.Repo() + `","version":"` + common.MockAvsPkg.Version() + `","profile":"option-returner","tag":"default"}`) if err != nil { t.Fatal(err) } @@ -206,8 +207,8 @@ func TestDataDir_InitInstance(t *testing.T) { instance: &Instance{ Name: "mock-avs", Tag: "default", - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v2.0.2", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "option-returner", fs: fs, locker: locker, @@ -224,7 +225,7 @@ func TestDataDir_InitInstance(t *testing.T) { instance: &Instance{ Name: "mock-avs", Tag: "default", - Version: "v2.0.2", + Version: common.MockAvsPkg.Version(), Profile: "option-returner", fs: fs, }, @@ -247,8 +248,8 @@ func TestDataDir_InitInstance(t *testing.T) { instance: &Instance{ Name: "mock-avs", Tag: "default", - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v2.0.2", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "option-returner", fs: fs, locker: locker, diff --git a/internal/data/init_test.go b/internal/data/init_test.go new file mode 100644 index 00000000..070419da --- /dev/null +++ b/internal/data/init_test.go @@ -0,0 +1,12 @@ +package data + +import ( + "github.com/NethermindEth/eigenlayer/internal/common" +) + +func init() { + err := common.SetMockAVSs() + if err != nil { + panic(err) + } +} diff --git a/internal/data/instance_test.go b/internal/data/instance_test.go index 5c6a720b..9c0ee9b6 100644 --- a/internal/data/instance_test.go +++ b/internal/data/instance_test.go @@ -5,6 +5,7 @@ import ( "path/filepath" "testing" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/NethermindEth/eigenlayer/internal/data/testdata" "github.com/NethermindEth/eigenlayer/internal/locker/mocks" "github.com/golang/mock/gomock" @@ -70,7 +71,7 @@ func TestNewInstance(t *testing.T) { t.Fatal(err) } defer stateFile.Close() - _, err = io.WriteString(stateFile, `{"name":"test_name","url":"https://github.com/NethermindEth/mock-avs","version":"v3.1.1","commit":"d1d4bb7009549c431d7b3317f004a56e2c3b2031","profile":"mainnet","tag":"test_tag"}`) + _, err = io.WriteString(stateFile, `{"name":"test_name","url":"`+common.MockAvsPkg.Repo()+`","version":"`+common.MockAvsPkg.Version()+`","commit":"`+common.MockAvsPkg.CommitHash()+`","profile":"mainnet","tag":"test_tag"}`) if err != nil { t.Fatal(err) } @@ -81,9 +82,9 @@ func TestNewInstance(t *testing.T) { instance: &Instance{ Name: "test_name", Tag: "test_tag", - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Profile: "mainnet", path: testDir, }, @@ -97,7 +98,7 @@ func TestNewInstance(t *testing.T) { t.Fatal(err) } defer stateFile.Close() - _, err = io.WriteString(stateFile, `{"name":"test_name","url":"https://github.com/NethermindEth/mock-avs","version":"v0.1.0"}`) + _, err = io.WriteString(stateFile, `{"name":"test_name","url":"`+common.MockAvsPkg.Repo()+`","version":"`+common.SpecVersion+`"}`) if err != nil { t.Fatal(err) } @@ -117,13 +118,13 @@ func TestNewInstance(t *testing.T) { defer stateFile.Close() _, err = io.WriteString(stateFile, `{ "name":"test_name", - "url":"https://github.com/NethermindEth/mock-avs", - "version":"v3.1.1", - "commit":"d1d4bb7009549c431d7b3317f004a56e2c3b2031", + "url":"`+common.MockAvsPkg.Repo()+`", + "version":"`+common.MockAvsPkg.Version()+`", + "commit":"`+common.MockAvsPkg.CommitHash()+`", "profile":"mainnet", "tag":"test_tag", "plugin":{ - "image":"mock-avs-plugin:latest" + "image":"`+common.PluginImage.Image()+`" } }`) if err != nil { @@ -136,12 +137,12 @@ func TestNewInstance(t *testing.T) { instance: &Instance{ Name: "test_name", Tag: "test_tag", - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Profile: "mainnet", Plugin: &Plugin{ - Image: "mock-avs-plugin:latest", + Image: common.PluginImage.Image(), }, path: testDir, }, @@ -155,7 +156,7 @@ func TestNewInstance(t *testing.T) { t.Fatal(err) } defer stateFile.Close() - _, err = io.WriteString(stateFile, `{"name":"test_name","url":"https://github.com/NethermindEth/mock-avs","version":"v3.1.1","commit":"d1d4bb7009549c431d7b3317f004a56e2c3b2031","profile":"mainnet","tag":"test_tag","plugin":{}}`) + _, err = io.WriteString(stateFile, `{"name":"test_name","url":"`+common.MockAvsPkg.Repo()+`","version":"`+common.MockAvsPkg.Version()+`","commit":"`+common.MockAvsPkg.CommitHash()+`","profile":"mainnet","tag":"test_tag","plugin":{}}`) if err != nil { t.Fatal(err) } @@ -166,9 +167,9 @@ func TestNewInstance(t *testing.T) { instance: &Instance{ Name: "test_name", Tag: "test_tag", - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Profile: "mainnet", Plugin: &Plugin{}, path: testDir, @@ -219,10 +220,10 @@ func TestInstance_Init(t *testing.T) { instance: &Instance{ Name: "test_name", Tag: "test_tag", - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", - SpecVersion: "v0.1.0", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), + SpecVersion: common.SpecVersion, + Commit: common.MockAvsPkg.CommitHash(), Profile: "option-returner", MonitoringTargets: MonitoringTargets{ Targets: []MonitoringTarget{ @@ -234,7 +235,7 @@ func TestInstance_Init(t *testing.T) { }, }, }, - stateJSON: []byte(`{"name":"test_name","url":"https://github.com/NethermindEth/mock-avs","version":"v3.1.1","spec_version":"v0.1.0","commit":"d1d4bb7009549c431d7b3317f004a56e2c3b2031","profile":"option-returner","tag":"test_tag","monitoring":{"targets":[{"service":"main-service","port":"8080","path":"/metrics"}]}}`), + stateJSON: []byte(`{"name":"test_name","url":"` + common.MockAvsPkg.Repo() + `","version":"` + common.MockAvsPkg.Version() + `","spec_version":"` + common.SpecVersion + `","commit":"` + common.MockAvsPkg.CommitHash() + `","profile":"option-returner","tag":"test_tag","monitoring":{"targets":[{"service":"main-service","port":"8080","path":"/metrics"}]}}`), mocker: func(path string, locker *mocks.MockLocker) { locker.EXPECT().New(filepath.Join(path, ".lock")).Return(locker) }, @@ -286,9 +287,9 @@ func TestInstance_Setup(t *testing.T) { i := Instance{ Name: "mock-avs", - URL: "https://github.com/NethermindEth/mock-avs", - Version: "v3.1.1", - Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031", + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Profile: "option-returner", Tag: "test-tag", } diff --git a/internal/docker/docker_test.go b/internal/docker/docker_test.go index b7ff1b25..e29121da 100644 --- a/internal/docker/docker_test.go +++ b/internal/docker/docker_test.go @@ -1175,7 +1175,7 @@ func TestNetworkDisconnect(t *testing.T) { // tests := []testCase{ // { // name: "success", -// remote: "https://github.com/NethermindEth/mock-avs#main:plugin", +// remote: "https://github.com/NethermindEth/mock-avs-pkg#main:plugin", // tag: "mock-avs-plugin", // setup: func(dockerClient *mocks.MockAPIClient) { // buildBody := io.NopCloser(bytes.NewReader([]byte{})) @@ -1187,7 +1187,7 @@ func TestNetworkDisconnect(t *testing.T) { // Body: loadBody, // } // dockerClient.EXPECT().ImageBuild(context.Background(), nil, types.ImageBuildOptions{ -// RemoteContext: "https://github.com/NethermindEth/mock-avs#main:plugin", +// RemoteContext: "https://github.com/NethermindEth/mock-avs-pkg#main:plugin", // Tags: []string{"mock-avs-plugin"}, // Remove: true, // ForceRemove: true, @@ -1203,7 +1203,7 @@ func TestNetworkDisconnect(t *testing.T) { // } // return testCase{ // name: "success, with build args", -// remote: "https://github.com/NethermindEth/mock-avs#main:plugin", +// remote: "https://github.com/NethermindEth/mock-avs-pkg#main:plugin", // tag: "mock-avs-plugin", // buildArgs: buildArgs, // setup: func(dockerClient *mocks.MockAPIClient) { @@ -1216,7 +1216,7 @@ func TestNetworkDisconnect(t *testing.T) { // Body: loadBody, // } // dockerClient.EXPECT().ImageBuild(context.Background(), nil, types.ImageBuildOptions{ -// RemoteContext: "https://github.com/NethermindEth/mock-avs#main:plugin", +// RemoteContext: "https://github.com/NethermindEth/mock-avs-pkg#main:plugin", // Tags: []string{"mock-avs-plugin"}, // Remove: true, // ForceRemove: true, @@ -1229,11 +1229,11 @@ func TestNetworkDisconnect(t *testing.T) { // }(t), // { // name: "build error", -// remote: "https://github.com/NethermindEth/mock-avs#main:plugin", +// remote: "https://github.com/NethermindEth/mock-avs-pkg#main:plugin", // tag: "mock-avs-plugin", // setup: func(dockerClient *mocks.MockAPIClient) { // dockerClient.EXPECT().ImageBuild(context.Background(), nil, types.ImageBuildOptions{ -// RemoteContext: "https://github.com/NethermindEth/mock-avs#main:plugin", +// RemoteContext: "https://github.com/NethermindEth/mock-avs-pkg#main:plugin", // Tags: []string{"mock-avs-plugin"}, // Remove: true, // ForceRemove: true, diff --git a/internal/package_handler/init_test.go b/internal/package_handler/init_test.go new file mode 100644 index 00000000..5d45c4e1 --- /dev/null +++ b/internal/package_handler/init_test.go @@ -0,0 +1,12 @@ +package package_handler + +import ( + "github.com/NethermindEth/eigenlayer/internal/common" +) + +func init() { + err := common.SetMockAVSs() + if err != nil { + panic(err) + } +} diff --git a/internal/package_handler/package.go b/internal/package_handler/package.go index b6951f4e..086d150d 100644 --- a/internal/package_handler/package.go +++ b/internal/package_handler/package.go @@ -533,3 +533,16 @@ func (p *PackageHandler) SpecVersion() (string, error) { return manifest.Version, nil } + +func (p *PackageHandler) Name() (string, error) { + manifest, err := p.parseManifest() + if err != nil { + return "", err + } + + if err := manifest.validate(); err != nil { + return "", err + } + + return manifest.Name, nil +} diff --git a/internal/package_handler/package_test.go b/internal/package_handler/package_test.go index 32043a23..64d9405b 100644 --- a/internal/package_handler/package_test.go +++ b/internal/package_handler/package_test.go @@ -7,6 +7,7 @@ import ( "path/filepath" "testing" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/NethermindEth/eigenlayer/internal/package_handler/testdata" "github.com/spf13/afero" "github.com/stretchr/testify/assert" @@ -32,7 +33,7 @@ func TestNewPackageHandlerFromURL(t *testing.T) { return testCase{ name: "valid package", path: path, - url: "https://github.com/NethermindEth/mock-avs", + url: common.MockAvsPkg.Repo(), pkgHandler: &PackageHandler{ path: path, }, @@ -157,12 +158,11 @@ func setupPackage(t *testing.T) string { t.Helper() pkgFolder := t.TempDir() - mockTapRepo := "https://github.com/NethermindEth/mock-avs.git" - tag := "v5.2.0" + mockTapRepo := common.MockAvsPkg.Repo() + ".git" - t.Logf("Cloning mock tap repo %s and tag %s into %s", mockTapRepo, tag, pkgFolder) + t.Logf("Cloning mock tap repo %s and tag %s into %s", mockTapRepo, common.MockAvsPkg.Version(), pkgFolder) - if err := exec.Command("git", "clone", "--single-branch", "-b", tag, mockTapRepo, pkgFolder).Run(); err != nil { + if err := exec.Command("git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), mockTapRepo, pkgFolder).Run(); err != nil { t.Fatal("error cloning the mock tap repo: " + err.Error()) } return pkgFolder diff --git a/internal/package_handler/testdata/manifests/invalid-schema/manifest.yml b/internal/package_handler/testdata/manifests/invalid-schema/manifest.yml index 37af8cde..73425c86 100644 --- a/internal/package_handler/testdata/manifests/invalid-schema/manifest.yml +++ b/internal/package_handler/testdata/manifests/invalid-schema/manifest.yml @@ -6,7 +6,7 @@ hardware_requirements: min_free_space: 5120 # ~= 5 Gb stop_if_requirements_are_not_met: true plugin: - build_from: https://github.com/NethermindEth/mock-avs.git#main:plugin + build_from: https://github.com/NethermindEth/mock-avs-pkg.git#main:plugin profiles: - "high-requirements" - "option-returner" diff --git a/internal/utils/init_test.go b/internal/utils/init_test.go new file mode 100644 index 00000000..73599940 --- /dev/null +++ b/internal/utils/init_test.go @@ -0,0 +1,12 @@ +package utils + +import ( + "github.com/NethermindEth/eigenlayer/internal/common" +) + +func init() { + err := common.SetMockAVSs() + if err != nil { + panic(err) + } +} diff --git a/internal/utils/tar_test.go b/internal/utils/tar_test.go index 654377f9..d26cad81 100644 --- a/internal/utils/tar_test.go +++ b/internal/utils/tar_test.go @@ -6,12 +6,11 @@ import ( "path/filepath" "testing" + "github.com/NethermindEth/eigenlayer/internal/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -const mockAVSRepo = "https://github.com/NethermindEth/mock-avs" - func TestCompressToTarGz(t *testing.T) { testDir := t.TempDir() pkgDir := filepath.Join(testDir, "mock-avs") @@ -20,7 +19,7 @@ func TestCompressToTarGz(t *testing.T) { err := os.MkdirAll(pkgDir, 0o755) require.NoError(t, err, "failed to create mock-avs dir") - err = exec.Command("git", "clone", "--single-branch", "-b", "v3.0.3", mockAVSRepo, pkgDir).Run() + err = exec.Command("git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir).Run() require.NoError(t, err, "failed to clone mock-avs repo") outTar, err := os.OpenFile(outTarPath, os.O_CREATE|os.O_RDWR, 0o755) @@ -45,7 +44,7 @@ func TestDecompressTarGz(t *testing.T) { err := os.MkdirAll(pkgDir, 0o755) require.NoError(t, err, "failed to create mock-avs dir") - err = exec.Command("git", "clone", "--single-branch", "-b", "v3.0.3", mockAVSRepo, pkgDir).Run() + err = exec.Command("git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgDir).Run() require.NoError(t, err, "failed to clone mock-avs repo") err = exec.Command("tar", "-czf", tarPath, "-C", pkgDir, ".").Run() diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 1b35270b..267a3bc5 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -124,6 +124,9 @@ type NodeLogsOptions struct { // PullResult is the result of a Pull operation, containing all the necessary // information from the package. type PullResult struct { + // Name is the name of the AVS represented by the pulled package. + Name string + // Version is the version of the pulled package. Version string @@ -146,6 +149,9 @@ type PullResult struct { // InstallOptions is a set of options for installing a node software package. type InstallOptions struct { + // Name is the name of the AVS represented by the package. + Name string + // URL is the URL of the git repository containing the node software package. URL string diff --git a/pkg/daemon/egn_daemon.go b/pkg/daemon/egn_daemon.go index 1f3d81a3..5f02a457 100644 --- a/pkg/daemon/egn_daemon.go +++ b/pkg/daemon/egn_daemon.go @@ -8,7 +8,6 @@ import ( "fmt" "io" "net/http" - "net/url" "os" "path" "path/filepath" @@ -298,6 +297,11 @@ func (d *EgnDaemon) Pull(url string, ref PullTarget, force bool) (result PullRes return } } + // Get AVS name + result.Name, err = pkgHandler.Name() + if err != nil { + return + } // Get Spec version result.SpecVersion, err = pkgHandler.SpecVersion() if err != nil { @@ -382,24 +386,33 @@ func (d *EgnDaemon) LocalInstall(pkgTar io.Reader, options LocalInstallOptions) } func (d *EgnDaemon) localInstall(pkgTar io.Reader, options LocalInstallOptions) (string, string, error) { - instanceID := data.InstanceId(options.Name, options.Tag) - // Check if instance already exists - if d.dataDir.HasInstance(instanceID) { - return instanceID, "", fmt.Errorf("%w: %s", ErrInstanceAlreadyExists, instanceID) - } // Decompress package to temp folder tID := tempID(options.Name) tempPath, err := d.dataDir.InitTemp(tID) if err != nil { - return instanceID, tID, err + return "", tID, err } err = utils.DecompressTarGz(pkgTar, tempPath) if err != nil { - return instanceID, tID, err + return "", tID, err } // Init package handler from temp path pkgHandler := package_handler.NewPackageHandler(tempPath) + + // Get Name + name, err := pkgHandler.Name() + if err != nil { + return "", tID, err + } + + // Get Instance ID + instanceID := data.InstanceId(name, options.Tag) + // Check if instance already exists + if d.dataDir.HasInstance(instanceID) { + return instanceID, "", fmt.Errorf("%w: %s", ErrInstanceAlreadyExists, instanceID) + } + // Get Spec version specVersion, err := pkgHandler.SpecVersion() if err != nil { @@ -497,11 +510,7 @@ func (d *EgnDaemon) remoteInstall(options InstallOptions) (string, string, error return "", tID, err } - instanceName, err := instanceNameFromURL(options.URL) - if err != nil { - return instanceName, tID, err - } - instanceID := data.InstanceId(instanceName, options.Tag) + instanceID := data.InstanceId(options.Name, options.Tag) if d.dataDir.HasInstance(instanceID) { return instanceID, tID, fmt.Errorf("%w: %s", ErrInstanceAlreadyExists, instanceID) @@ -553,7 +562,7 @@ func (d *EgnDaemon) remoteInstall(options InstallOptions) (string, string, error } maps.Copy(env, optionsEnv) - return d.install(instanceName, instanceID, tID, pkgHandler, selectedProfile, env, options) + return d.install(options.Name, instanceID, tID, pkgHandler, selectedProfile, env, options) } func (d *EgnDaemon) install( @@ -857,14 +866,6 @@ func (d *EgnDaemon) NodeLogs(ctx context.Context, w io.Writer, instanceID string }) } -func instanceNameFromURL(u string) (string, error) { - parsedURL, err := url.ParseRequestURI(u) - if err != nil { - return "", err - } - return path.Base(parsedURL.Path), nil -} - func tempID(url string) string { tempHash := sha256.Sum256([]byte(url)) return hex.EncodeToString(tempHash[:]) diff --git a/pkg/daemon/egn_daemon_test.go b/pkg/daemon/egn_daemon_test.go index c6441da9..cdec4143 100644 --- a/pkg/daemon/egn_daemon_test.go +++ b/pkg/daemon/egn_daemon_test.go @@ -36,9 +36,7 @@ import ( ) const ( - MockAVSRepo = "https://github.com/NethermindEth/mock-avs" - MockAVSLatestVersion = "v5.2.0" - MockAVSLatestVersionCommit = "a7ca2dca2cc9a91cdab8f30c2daf86a5f2dc4c55" + MockAVSName = "mock-avs" ) var MockAVSLatestOptions = map[string][]Option{ @@ -506,13 +504,14 @@ func TestPull(t *testing.T) { }{ { name: "pull -> success", - url: MockAVSRepo, + url: common.MockAvsPkg.Repo(), want: PullResult{ - Version: MockAVSLatestVersion, - Commit: MockAVSLatestVersionCommit, + Name: MockAVSName, + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Options: MockAVSLatestOptions, }, - ref: PullTarget{Version: MockAVSLatestVersion}, + ref: PullTarget{Version: common.MockAvsPkg.Version()}, mocker: func(t *testing.T, locker *mock_locker.MockLocker) *data.DataDir { tmp, err := afero.TempDir(afs, "", "egn-pull") require.NoError(t, err) @@ -523,11 +522,12 @@ func TestPull(t *testing.T) { }, { name: "pull -> success, fixed version", - url: MockAVSRepo, - ref: PullTarget{Version: MockAVSLatestVersion}, + url: common.MockAvsPkg.Repo(), + ref: PullTarget{Version: common.MockAvsPkg.Version()}, want: PullResult{ - Version: MockAVSLatestVersion, - Commit: MockAVSLatestVersionCommit, + Name: MockAVSName, + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Options: MockAVSLatestOptions, }, mocker: func(t *testing.T, locker *mock_locker.MockLocker) *data.DataDir { @@ -540,32 +540,34 @@ func TestPull(t *testing.T) { }, { name: "pull -> success, force", - url: MockAVSRepo, + url: common.MockAvsPkg.Repo(), force: true, want: PullResult{ - Version: MockAVSLatestVersion, - Commit: MockAVSLatestVersionCommit, + Name: MockAVSName, + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), Options: MockAVSLatestOptions, }, - ref: PullTarget{Version: MockAVSLatestVersion}, + ref: PullTarget{Version: common.MockAvsPkg.Version()}, mocker: func(t *testing.T, locker *mock_locker.MockLocker) *data.DataDir { tmp, err := afero.TempDir(afs, "", "egn-pull") require.NoError(t, err) dataDir, err := data.NewDataDir(tmp, afs, locker) require.NoError(t, err) - afs.MkdirAll(filepath.Join(tmp, "temp", tempID(MockAVSRepo)), 0o755) + afs.MkdirAll(filepath.Join(tmp, "temp", tempID(common.MockAvsPkg.Repo())), 0o755) return dataDir }, }, { name: "pull -> success, fixed commit hash", - url: MockAVSRepo, + url: common.MockAvsPkg.Repo(), force: true, want: PullResult{ - Commit: MockAVSLatestVersionCommit, + Name: MockAVSName, + Commit: common.MockAvsPkg.CommitHash(), Options: MockAVSLatestOptions, }, - ref: PullTarget{Commit: MockAVSLatestVersionCommit}, + ref: PullTarget{Commit: common.MockAvsPkg.CommitHash()}, mocker: func(t *testing.T, locker *mock_locker.MockLocker) *data.DataDir { tmp, err := afero.TempDir(afs, "", "egn-pull") require.NoError(t, err) @@ -594,8 +596,8 @@ func TestPull(t *testing.T) { } else { require.NoError(t, err) // Deep check the result - assert.Equal(t, tt.want.Version, result.Version) - assert.Equal(t, tt.want.Commit, result.Commit) + assert.Equal(t, tt.want.Version, result.Version, "version mismatch") + assert.Equal(t, tt.want.Commit, result.Commit, "commit mismatch") assert.Len(t, tt.want.Options, len(result.Options)) for k, profile := range tt.want.Options { gotProfile, ok := result.Options[k] @@ -603,7 +605,7 @@ func TestPull(t *testing.T) { for _, wantOption := range profile { for _, gotOption := range gotProfile { if wantOption.Name() == gotOption.Name() { - assert.EqualValues(t, wantOption, gotOption) + assert.EqualValues(t, wantOption, gotOption, "option mismatch") } } } @@ -628,8 +630,9 @@ func TestInstall(t *testing.T) { { name: "install -> success, default tag", options: InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -658,8 +661,9 @@ func TestInstall(t *testing.T) { { name: "install -> success, specific tag, option-returner", options: InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "option-returner", Tag: "specific", }, @@ -688,8 +692,9 @@ func TestInstall(t *testing.T) { { name: "install -> failure, bad tap version, got empty instanceID -> no install cleanup", options: InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "invalid-profile", Tag: "default", }, @@ -710,8 +715,9 @@ func TestInstall(t *testing.T) { { name: "install -> failure, compose create error -> install cleanup with monitoring target removal", options: InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -745,8 +751,9 @@ func TestInstall(t *testing.T) { { name: "install -> failure, compose create error -> install cleanup with monitoring target removal failed", options: InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -779,8 +786,9 @@ func TestInstall(t *testing.T) { { name: "install -> failure, compose create error -> install cleanup with monitoring not installed", options: InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -812,8 +820,9 @@ func TestInstall(t *testing.T) { { name: "install -> failure, compose create error -> install cleanup with monitoring installed but not running", options: InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -935,9 +944,9 @@ func TestRun(t *testing.T) { afs := afero.NewOsFs() instanceID := "mock-avs-default" - commit := MockAVSLatestVersionCommit + commit := common.MockAvsPkg.CommitHash() avsName := "mock-avs" - avsVersion := MockAVSLatestVersion + avsVersion := common.MockAvsPkg.Version() specVersion := "v0.0.1" labels := map[string]string{ @@ -991,8 +1000,9 @@ func TestRun(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), SpecVersion: specVersion, Profile: "health-checker", Tag: "default", @@ -1035,8 +1045,9 @@ func TestRun(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), SpecVersion: specVersion, Profile: "health-checker", Tag: "default", @@ -1063,8 +1074,9 @@ func TestRun(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), SpecVersion: specVersion, Profile: "health-checker", Tag: "default", @@ -1089,8 +1101,9 @@ func TestRun(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), SpecVersion: specVersion, Profile: "health-checker", Tag: "default", @@ -1121,8 +1134,9 @@ func TestRun(t *testing.T) { composeManager.EXPECT().Up(compose.DockerComposeUpOptions{Path: path}).Return(errors.New("error")) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), SpecVersion: specVersion, Profile: "health-checker", Tag: "default", @@ -1211,8 +1225,9 @@ func TestStop(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -1242,8 +1257,9 @@ func TestStop(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -1333,8 +1349,9 @@ func TestUninstall(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -1358,8 +1375,9 @@ func TestUninstall(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -1384,8 +1402,9 @@ func TestUninstall(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -1417,8 +1436,9 @@ func TestUninstall(t *testing.T) { ) }, options: &InstallOptions{ - URL: MockAVSRepo, - Version: MockAVSLatestVersion, + Name: MockAVSName, + URL: common.MockAvsPkg.Repo(), + Version: common.MockAvsPkg.Version(), Profile: "health-checker", Tag: "default", }, @@ -1512,12 +1532,12 @@ func TestListInstances(t *testing.T) { apiServer, apiServerURL := httptestHealth(t, http.StatusOK) t.Cleanup(apiServer.Close) initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -1556,8 +1576,8 @@ func TestListInstances(t *testing.T) { Health: NodeHealthy, Running: true, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -1577,12 +1597,12 @@ func TestListInstances(t *testing.T) { return tInstance{ id: "mock-avs-0", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "0", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `", + "url": "` + common.MockAvsPkg.Repo() + `", "api": { "service": "main-service", "port": "` + apiServerURL.Port() + `" @@ -1597,12 +1617,12 @@ func TestListInstances(t *testing.T) { return tInstance{ id: "mock-avs-1", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "1", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `", + "url": "` + common.MockAvsPkg.Repo() + `", "api": { "service": "main-service", "port": "` + apiServerURL.Port() + `" @@ -1617,12 +1637,12 @@ func TestListInstances(t *testing.T) { return tInstance{ id: "mock-avs-2", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "2", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `", + "url": "` + common.MockAvsPkg.Repo() + `", "api": { "service": "main-service", "port": "` + apiServerURL.Port() + `" @@ -1669,24 +1689,24 @@ func TestListInstances(t *testing.T) { Health: NodeHealthy, Running: true, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, { ID: "mock-avs-1", Health: NodeHealthy, Running: true, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, { ID: "mock-avs-2", Health: NodeHealthy, Running: true, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -1706,12 +1726,12 @@ func TestListInstances(t *testing.T) { return tInstance{ id: "mock-avs-0", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "0", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `", + "url": "` + common.MockAvsPkg.Repo() + `", "api": { "service": "main-service", "port": "` + apiServerURL.Port() + `" @@ -1749,12 +1769,12 @@ func TestListInstances(t *testing.T) { return tInstance{ id: "mock-avs-1", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "1", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `", + "url": "` + common.MockAvsPkg.Repo() + `", "api": { "service": "main-service", "port": "` + apiServerURL.Port() + `" @@ -1784,16 +1804,16 @@ func TestListInstances(t *testing.T) { Health: NodeHealthy, Running: true, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, { ID: "mock-avs-1", Health: NodeHealthUnknown, Running: false, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -1813,12 +1833,12 @@ func TestListInstances(t *testing.T) { return tInstance{ id: "mock-avs-0", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "0", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `", + "url": "` + common.MockAvsPkg.Repo() + `", "api": { "service": "main-service", "port": "` + apiServerURL.Port() + `" @@ -1853,12 +1873,12 @@ func TestListInstances(t *testing.T) { { id: "mock-avs-1", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "1", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `" + "url": "` + common.MockAvsPkg.Repo() + `" }`, mocks: []*gomock.Call{ d.composeManager.EXPECT().PS(compose.DockerComposePsOptions{ @@ -1888,16 +1908,16 @@ func TestListInstances(t *testing.T) { Health: NodeHealthy, Running: true, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, { ID: "mock-avs-1", Health: NodeHealthUnknown, Running: true, Comment: "Instance's package does not specifies an API target for the AVS Specification Metrics's API", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -1916,12 +1936,12 @@ func TestListInstances(t *testing.T) { return tInstance{ id: "mock-avs-0", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "0", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `", + "url": "` + common.MockAvsPkg.Repo() + `", "api": { "service": "main-service", "port": "` + apiServerURL.Port() + `" @@ -1932,12 +1952,12 @@ func TestListInstances(t *testing.T) { { id: "mock-avs-1", stateJSON: `{ - "name": "mock-avs", + "name": "` + MockAVSName + `", "tag": "1", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "` + common.MockAvsPkg.Version() + `", + "commit": "` + common.MockAvsPkg.CommitHash() + `", "profile": "option-returner", - "url": "` + MockAVSRepo + `" + "url": "` + common.MockAvsPkg.Repo() + `" }`, }, } @@ -1959,16 +1979,16 @@ func TestListInstances(t *testing.T) { Health: NodeHealthUnknown, Running: false, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, { ID: "mock-avs-1", Health: NodeHealthUnknown, Running: false, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, }, @@ -1979,12 +1999,12 @@ func TestListInstances(t *testing.T) { t.Cleanup(apiServer.Close) initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -2022,8 +2042,8 @@ func TestListInstances(t *testing.T) { Health: NodeHealthUnknown, Running: true, Comment: "API container is exited", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -2035,12 +2055,12 @@ func TestListInstances(t *testing.T) { name: "1 instance running with many services, api service got exited before health check request", mocker: func(t *testing.T, d *mockerData) { initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -2083,8 +2103,8 @@ func TestListInstances(t *testing.T) { Health: NodeHealthUnknown, Running: true, Comment: fmt.Sprintf(`API container is running but health check failed: Get "http://%s/eigen/node/health": dial tcp %s: connect: connection refused`, apiServerURL.Host, apiServerURL.Host), - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -2097,12 +2117,12 @@ func TestListInstances(t *testing.T) { t.Cleanup(apiServer.Close) initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -2124,8 +2144,8 @@ func TestListInstances(t *testing.T) { Health: NodeHealthUnknown, Running: false, Comment: fmt.Sprintf("Failed to get instance status: %v", assert.AnError), - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -2136,12 +2156,12 @@ func TestListInstances(t *testing.T) { apiServer, apiServerURL := httptestHealth(t, http.StatusServiceUnavailable) t.Cleanup(apiServer.Close) initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -2180,8 +2200,8 @@ func TestListInstances(t *testing.T) { Health: NodeUnhealthy, Running: true, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -2192,12 +2212,12 @@ func TestListInstances(t *testing.T) { apiServer, apiServerURL := httptestHealth(t, http.StatusPartialContent) t.Cleanup(apiServer.Close) initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -2236,8 +2256,8 @@ func TestListInstances(t *testing.T) { Health: NodePartiallyHealthy, Running: true, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -2248,12 +2268,12 @@ func TestListInstances(t *testing.T) { apiServer, apiServerURL := httptestHealth(t, http.StatusFound) t.Cleanup(apiServer.Close) initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -2292,8 +2312,8 @@ func TestListInstances(t *testing.T) { Health: NodeHealthUnknown, Running: true, Comment: fmt.Sprintf("API container is running but health check failed: unexpected status code: %d", http.StatusFound), - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -2304,12 +2324,12 @@ func TestListInstances(t *testing.T) { apiServer, apiServerURL := httptestHealth(t, http.StatusFound) t.Cleanup(apiServer.Close) initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -2331,8 +2351,8 @@ func TestListInstances(t *testing.T) { Health: NodeHealthUnknown, Running: false, Comment: "", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -2343,12 +2363,12 @@ func TestListInstances(t *testing.T) { apiServer, apiServerURL := httptestHealth(t, http.StatusOK) t.Cleanup(apiServer.Close) initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", - "commit": "d61b79ca779700dd4484a9846c4139d5a8c8c805", + "version": "`+common.MockAvsPkg.Version()+`", + "commit": "`+common.MockAvsPkg.CommitHash()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "api": { "service": "main-service", "port": "`+apiServerURL.Port()+`" @@ -2386,8 +2406,8 @@ func TestListInstances(t *testing.T) { Health: NodeHealthUnknown, Running: true, Comment: "API container is restarting", - Version: "v3.0.3", - Commit: "d61b79ca779700dd4484a9846c4139d5a8c8c805", + Version: common.MockAvsPkg.Version(), + Commit: common.MockAvsPkg.CommitHash(), }, }, err: nil, @@ -2493,11 +2513,11 @@ func TestNodeLogs(t *testing.T) { opts: NodeLogsOptions{}, mocker: func(t *testing.T, d *mockerData) { initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`" + "url": "`+common.MockAvsPkg.Repo()+`" }`) d.composeManager.EXPECT().PS(compose.DockerComposePsOptions{ Path: filepath.Join(d.dataDirPath, "nodes", "mock-avs-default", "docker-compose.yml"), @@ -2526,11 +2546,11 @@ func TestNodeLogs(t *testing.T) { instanceID: "mock-avs-default", mocker: func(t *testing.T, d *mockerData) { initInstanceDir(t, d.fs, d.dataDirPath, "mock-avs-default", `{ - "name": "mock-avs", + "name": "`+MockAVSName+`", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`" + "url": "`+common.MockAvsPkg.Repo()+`" }`) d.composeManager.EXPECT().PS(compose.DockerComposePsOptions{ Path: filepath.Join(d.dataDirPath, "nodes", "mock-avs-default", "docker-compose.yml"), @@ -2616,11 +2636,11 @@ func TestRunPlugin(t *testing.T) { initInstanceDir(t, d.fs, d.dataDir.Path(), "mock-avs-default", `{ "name": "mock-avs", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "plugin": { - "image": "mock-avs-plugin:latest" + "image": "`+common.PluginImage.Image()+`" } }`) gomock.InOrder( @@ -2634,7 +2654,7 @@ func TestRunPlugin(t *testing.T) { }, }, nil), d.dockerManager.EXPECT().ContainerNetworks("abc123").Return([]string{"network-el"}, nil), - d.dockerManager.EXPECT().Run("mock-avs-plugin:latest", "network-el", []string{"arg1", "arg2"}, []docker.Mount{ + d.dockerManager.EXPECT().Run(common.PluginImage.Image(), "network-el", []string{"arg1", "arg2"}, []docker.Mount{ { Type: docker.VolumeTypeBind, Source: "/tmp", @@ -2646,7 +2666,7 @@ func TestRunPlugin(t *testing.T) { Target: "/tmp/volume1", }, }), - d.dockerManager.EXPECT().ImageRemove("mock-avs-plugin:latest").Return(nil), + d.dockerManager.EXPECT().ImageRemove(common.PluginImage.Image()).Return(nil), ) }, }, @@ -2667,15 +2687,15 @@ func TestRunPlugin(t *testing.T) { initInstanceDir(t, d.fs, d.dataDir.Path(), "mock-avs-default", `{ "name": "mock-avs", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "plugin": { - "image": "mock-avs-plugin:latest" + "image": "`+common.PluginImage.Image()+`" } }`) gomock.InOrder( - d.dockerManager.EXPECT().Run("mock-avs-plugin:latest", docker.NetworkHost, []string{"arg1", "arg2"}, []docker.Mount{ + d.dockerManager.EXPECT().Run(common.PluginImage.Image(), docker.NetworkHost, []string{"arg1", "arg2"}, []docker.Mount{ { Type: docker.VolumeTypeBind, Source: "/tmp", @@ -2687,7 +2707,7 @@ func TestRunPlugin(t *testing.T) { Target: "/tmp/volume1", }, }), - d.dockerManager.EXPECT().ImageRemove("mock-avs-plugin:latest").Return(nil), + d.dockerManager.EXPECT().ImageRemove(common.PluginImage.Image()).Return(nil), ) }, }, @@ -2704,9 +2724,9 @@ func TestRunPlugin(t *testing.T) { initInstanceDir(t, d.fs, d.dataDir.Path(), "mock-avs-default", `{ "name": "mock-avs", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`" + "url": "`+common.MockAvsPkg.Repo()+`" }`) }, }, @@ -2718,11 +2738,11 @@ func TestRunPlugin(t *testing.T) { initInstanceDir(t, d.fs, d.dataDir.Path(), "mock-avs-default", `{ "name": "mock-avs", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "plugin": { - "image": "mock-avs-plugin:latest" + "image": "`+common.PluginImage.Image()+`" } }`) d.composeManager.EXPECT().PS(compose.DockerComposePsOptions{ @@ -2740,11 +2760,11 @@ func TestRunPlugin(t *testing.T) { initInstanceDir(t, d.fs, d.dataDir.Path(), "mock-avs-default", `{ "name": "mock-avs", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "plugin": { - "image": "mock-avs-plugin:latest" + "image": "`+common.PluginImage.Image()+`" } }`) d.composeManager.EXPECT().PS(compose.DockerComposePsOptions{ @@ -2762,11 +2782,11 @@ func TestRunPlugin(t *testing.T) { initInstanceDir(t, d.fs, d.dataDir.Path(), "mock-avs-default", `{ "name": "mock-avs", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "plugin": { - "image": "mock-avs-plugin:latest" + "image": "`+common.PluginImage.Image()+`" } }`) d.composeManager.EXPECT().PS(compose.DockerComposePsOptions{ @@ -2789,11 +2809,11 @@ func TestRunPlugin(t *testing.T) { initInstanceDir(t, d.fs, d.dataDir.Path(), "mock-avs-default", `{ "name": "mock-avs", "tag": "default", - "version": "v3.0.3", + "version": "`+common.MockAvsPkg.Version()+`", "profile": "option-returner", - "url": "`+MockAVSRepo+`", + "url": "`+common.MockAvsPkg.Repo()+`", "plugin": { - "image": "mock-avs-plugin:latest" + "image": "`+common.PluginImage.Image()+`" } }`) d.composeManager.EXPECT().PS(compose.DockerComposePsOptions{ @@ -2891,7 +2911,7 @@ func TestGetPluginData(t *testing.T) { func(t *testing.T) testCase { name := "plugin with remote image" pkgFolder := t.TempDir() - err := exec.Command("git", "clone", "--single-branch", "-b", MockAVSLatestVersion, MockAVSRepo, pkgFolder).Run() + err := exec.Command("git", "clone", "--single-branch", "-b", common.MockAvsPkg.Version(), common.MockAvsPkg.Repo(), pkgFolder).Run() require.NoError(t, err, "failed to clone mock-avs repo") pkgHandler := package_handler.NewPackageHandler(pkgFolder) changeManifestPluginBuildFrom(t, fs, pkgHandler.ManifestFilePath(), package_handler.Plugin{ diff --git a/pkg/daemon/init_test.go b/pkg/daemon/init_test.go new file mode 100644 index 00000000..780044cb --- /dev/null +++ b/pkg/daemon/init_test.go @@ -0,0 +1,12 @@ +package daemon + +import ( + "github.com/NethermindEth/eigenlayer/internal/common" +) + +func init() { + err := common.SetMockAVSs() + if err != nil { + panic(err) + } +}