Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
feat: Use manifest.name for the instance ID
Browse files Browse the repository at this point in the history
  • Loading branch information
AntiD2ta committed Sep 14, 2023
1 parent 07ee020 commit 8d7d0ae
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 164 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Executing this command triggers an interactive installation process. During this

```bash
INFO[0000] Version not specified, using latest.
INFO[0000] Using version v5.3.0
INFO[0000] Using version v5.4.0
? Select a profile option-returner
? main-container-name option-returner
? main-port 8080
Expand Down Expand Up @@ -96,7 +96,7 @@ Output:

```bash
INFO[0000] Version not specified, using latest.
INFO[0000] Using version v5.3.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.
```
Expand All @@ -120,7 +120,7 @@ Output:

```bash
INFO[0000] Version not specified, using latest.
INFO[0000] Using version v5.3.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.
```
Expand All @@ -138,7 +138,7 @@ First, clone the `mock-avs-pkg` package:
> If you already have a local package, you can skip this step
```bash
git clone --branch v5.3.0 https://github.com/NethermindEth/mock-avs-pkg
git clone --branch v5.4.0 https://github.com/NethermindEth/mock-avs-pkg
```

Now we can install the package from the `mock-avs-pkg` directory with the following command:
Expand Down
44 changes: 22 additions & 22 deletions cli/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {option},
},
Expand All @@ -74,7 +74,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Install(daemon.InstallOptions{
URL: "https://github.com/NethermindEth/mock-avs-pkg",
Version: "v5.3.0",
Version: "v5.4.0",
Profile: "profile1",
Options: []daemon.Option{option},
Tag: "default",
Expand All @@ -98,7 +98,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {option},
},
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {option},
},
Expand All @@ -142,7 +142,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Install(daemon.InstallOptions{
URL: "https://github.com/NethermindEth/mock-avs-pkg",
Version: "v5.3.0",
Version: "v5.4.0",
Profile: "profile1",
Options: []daemon.Option{option},
Tag: "default",
Expand All @@ -166,7 +166,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {option},
},
Expand All @@ -181,7 +181,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Install(daemon.InstallOptions{
URL: "https://github.com/NethermindEth/mock-avs-pkg",
Version: "v5.3.0",
Version: "v5.4.0",
Profile: "profile1",
Options: []daemon.Option{option},
Tag: "default",
Expand All @@ -204,7 +204,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {option},
},
Expand All @@ -219,7 +219,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Install(daemon.InstallOptions{
URL: "https://github.com/NethermindEth/mock-avs-pkg",
Version: "v5.3.0",
Version: "v5.4.0",
Profile: "profile1",
Options: []daemon.Option{option},
Tag: "default",
Expand All @@ -242,7 +242,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {option},
},
Expand All @@ -257,7 +257,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Install(daemon.InstallOptions{
URL: "https://github.com/NethermindEth/mock-avs-pkg",
Version: "v5.3.0",
Version: "v5.4.0",
Profile: "profile1",
Options: []daemon.Option{option},
Tag: "default",
Expand All @@ -280,7 +280,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {option},
},
Expand All @@ -296,11 +296,11 @@ func TestInstall(t *testing.T) {
},
{
name: "pull error",
args: []string{"-v", "v5.3.0", "https://github.com/NethermindEth/mock-avs-pkg"},
args: []string{"-v", "v5.4.0", "https://github.com/NethermindEth/mock-avs-pkg"},
err: errors.New("pull error"),
daemonMock: func(d *daemonMock.MockDaemon, p *prompterMock.MockPrompter) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{Version: "v5.3.0"}, true).
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{Version: "v5.4.0"}, true).
Return(daemon.PullResult{}, errors.New("pull error"))
},
},
Expand All @@ -313,7 +313,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {},
},
Expand All @@ -331,7 +331,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {},
},
Expand All @@ -354,7 +354,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {option},
},
Expand All @@ -367,7 +367,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Install(daemon.InstallOptions{
URL: "https://github.com/NethermindEth/mock-avs-pkg",
Version: "v5.3.0",
Version: "v5.4.0",
Profile: "profile1",
Options: []daemon.Option{option},
Tag: "default",
Expand All @@ -384,7 +384,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {},
},
Expand Down Expand Up @@ -416,7 +416,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Options: map[string][]daemon.Option{
"profile1": {},
},
Expand Down Expand Up @@ -453,7 +453,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Pull("https://github.com/NethermindEth/mock-avs-pkg", daemon.PullTarget{Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031"}, true).
Return(daemon.PullResult{
Version: "v5.3.0",
Version: "v5.4.0",
Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031",
Options: map[string][]daemon.Option{
"profile1": {option},
Expand All @@ -479,7 +479,7 @@ func TestInstall(t *testing.T) {
d.EXPECT().
Install(daemon.InstallOptions{
URL: "https://github.com/NethermindEth/mock-avs-pkg",
Version: "v5.3.0",
Version: "v5.4.0",
Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031",
Profile: "profile1",
Options: []daemon.Option{option},
Expand Down
5 changes: 1 addition & 4 deletions cli/local_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions cli/ls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ func TestList(t *testing.T) {
Running: true,
Health: daemon.NodeHealthy,
Comment: "comment1",
Version: "v5.3.0",
Version: "v5.4.0",
Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031",
}, {
ID: "id2",
Running: false,
Health: daemon.NodeHealthUnknown,
Comment: "comment2",
Version: "v5.3.0",
Version: "v5.4.0",
Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031",
},
}, nil)
},
stdOut: []byte(
"AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT \n" +
"id1 true healthy v5.3.0 d1d4bb700954 comment1 \n" +
"id2 false unknown v5.3.0 d1d4bb700954 comment2 \n",
"id1 true healthy v5.4.0 d1d4bb700954 comment1 \n" +
"id2 false unknown v5.4.0 d1d4bb700954 comment2 \n",
),
},
{
Expand All @@ -54,22 +54,22 @@ func TestList(t *testing.T) {
Running: true,
Health: daemon.NodeHealthy,
Comment: "comment1",
Version: "v5.3.0",
Version: "v5.4.0",
Commit: "d1d4bb7009549c431d7b3317f004a56e2c3b2031",
}, {
ID: "id2",
Running: false,
Health: daemon.NodeHealthUnknown,
Comment: "comment2",
Version: "v5.3.0",
Version: "v5.4.0",
Commit: "d1d4bb7",
},
}, nil)
},
stdOut: []byte(
"AVS Instance ID RUNNING HEALTH VERSION COMMIT COMMENT \n" +
"id1 true healthy v5.3.0 d1d4bb700954 comment1 \n" +
"id2 false unknown v5.3.0 d1d4bb7 comment2 \n",
"id1 true healthy v5.4.0 d1d4bb700954 comment1 \n" +
"id2 false unknown v5.4.0 d1d4bb7 comment2 \n",
),
},
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const (
mockAVSRepo = "https://github.com/NethermindEth/mock-avs-pkg"
latestMockAVSVersion = "v5.3.0"
latestMockAVSVersion = "v5.4.0"
latestMockAVSCommitHash = "a7ca2dca2cc9a91cdab8f30c2daf86a5f2dc4c55"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/data/datadir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

const (
mockAVSLatestVersion = "v5.3.0"
mockAVSLatestVersion = "v5.4.0"
)

func TestNewDataDir(t *testing.T) {
Expand Down Expand Up @@ -98,7 +98,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-pkg","version":mockAVSLatestVersion,"profile":"option-returner","tag":"default"}`)
_, err = stateFile.WriteString(`{"name":"mock-avs","url":"https://github.com/NethermindEth/mock-avs-pkg","version":"` + mockAVSLatestVersion + `","profile":"option-returner","tag":"default"}`)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestDataDir_Instance(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = stateFile.WriteString(`{"url":"https://github.com/NethermindEth/mock-avs-pkg","version":` + mockAVSLatestVersion + `,"profile":"option-returner","tag":"default"}`)
_, err = stateFile.WriteString(`{"url":"https://github.com/NethermindEth/mock-avs-pkg","version":"` + mockAVSLatestVersion + `","profile":"option-returner","tag":"default"}`)
if err != nil {
t.Fatal(err)
}
Expand Down
Loading

0 comments on commit 8d7d0ae

Please sign in to comment.