Skip to content

Commit

Permalink
Remove workaround for minVersion (#3218)
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko authored Nov 7, 2024
1 parent 19cee56 commit 0a56bd1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 106 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.9-ai.4
0.7.9
25 changes: 4 additions & 21 deletions core/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,28 +432,11 @@ func (bcast *Capabilities) LivepeerVersionCompatibleWith(orch *net.Capabilities)
return false
}

// // Ignore prerelease versions as in go-livepeer we actually define post-release suffixes
// minVerNoSuffix, _ := minVer.SetPrerelease("")
// verNoSuffix, _ := ver.SetPrerelease("")

// return !verNoSuffix.LessThan(&minVerNoSuffix)

// TODO: Remove AI-specific cases below when merging into master.
// NOTE: This logic was added to allow the version suffix (i.e. v0.7.6-ai.1) to be
// used correctly during the version constraint filtering.
minVerHasSuffix := minVer.Prerelease() != ""
verHasSuffix := ver.Prerelease() != ""
if !minVerHasSuffix || !verHasSuffix {
minVerNoSuffix, _ := minVer.SetPrerelease("")
verNoSuffix, _ := ver.SetPrerelease("")
minVer = &minVerNoSuffix
ver = &verNoSuffix
}
if minVer.Equal(ver) && minVerHasSuffix && !verHasSuffix {
return false
}
// Ignore prerelease versions as in go-livepeer we actually define post-release suffixes
minVerNoSuffix, _ := minVer.SetPrerelease("")
verNoSuffix, _ := ver.SetPrerelease("")

return !ver.LessThan(minVer)
return !verNoSuffix.LessThan(&minVerNoSuffix)
}

func (bcast *Capabilities) CompatibleWith(orch *net.Capabilities) bool {
Expand Down
84 changes: 0 additions & 84 deletions core/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,51 +345,6 @@ func TestCapability_CompatibleWithNetCap(t *testing.T) {
bcast.constraints.minVersion = "0.4.1"
orch.version = "0.4.1"
assert.True(bcast.CompatibleWith(orch.ToNetCapabilities()))

// TODO: Remove AI-specific cases below when merging into master.
// NOTE: Additional logic was added to the `LivepeerVersionCompatibleWith` method in
// capabilities.go to achieve this behavior.
// AI broadcaster is compatible with AI orchestrator - higher ai suffix
orch = NewCapabilities(nil, nil)
bcast = NewCapabilities(nil, nil)
bcast.constraints.minVersion = "0.7.2"
orch.version = "0.7.2-ai.1"
assert.True(bcast.CompatibleWith(orch.ToNetCapabilities()))

// AI broadcaster is not compatible with AI orchestrator - no ai suffix
orch = NewCapabilities(nil, nil)
bcast = NewCapabilities(nil, nil)
bcast.constraints.minVersion = "0.7.2-ai.1"
orch.version = "0.7.2"
assert.False(bcast.CompatibleWith(orch.ToNetCapabilities()))

// AI broadcaster is not compatible with AI orchestrator - lower ai suffix
orch = NewCapabilities(nil, nil)
bcast = NewCapabilities(nil, nil)
bcast.constraints.minVersion = "0.7.2-ai.2"
orch.version = "0.7.2-ai.1"
assert.False(bcast.CompatibleWith(orch.ToNetCapabilities()))

// AI broadcaster is not compatible with AI orchestrator - lower major version
orch = NewCapabilities(nil, nil)
bcast = NewCapabilities(nil, nil)
bcast.constraints.minVersion = "0.7.2-ai.2"
orch.version = "0.7.1-ai.1"
assert.False(bcast.CompatibleWith(orch.ToNetCapabilities()))

// AI broadcaster is compatible with AI orchestrator - higher ai suffix
orch = NewCapabilities(nil, nil)
bcast = NewCapabilities(nil, nil)
bcast.constraints.minVersion = "0.7.2-ai.1"
orch.version = "0.7.2-ai.2"
assert.True(bcast.CompatibleWith(orch.ToNetCapabilities()))

// AI broadcaster is compatible with AI orchestrator- higher major version
orch = NewCapabilities(nil, nil)
bcast = NewCapabilities(nil, nil)
bcast.constraints.minVersion = "0.7.2-ai.2"
orch.version = "0.7.3-ai.1"
assert.True(bcast.CompatibleWith(orch.ToNetCapabilities()))
}

func TestCapability_RoundTrip_Net(t *testing.T) {
Expand Down Expand Up @@ -666,45 +621,6 @@ func TestLiveeerVersionCompatibleWith(t *testing.T) {
transcoderVersion: "nonparsablesemversion",
expected: false,
},
// TODO: Remove AI-specific cases below when merging into master.
// NOTE: Additional logic was added to the `LivepeerVersionCompatibleWith` method in
// capabilities.go to achieve this behavior.
{
name: "AI broadcaster required version has no AI suffix",
broadcasterMinVersion: "0.7.2",
transcoderVersion: "0.7.2-ai.1",
expected: true,
},
{
name: "AI transcoder version has no AI suffix",
broadcasterMinVersion: "0.7.2-ai.1",
transcoderVersion: "0.7.2",
expected: false,
},
{
name: "AI broadcaster required version AI suffix is higher than AI transcoder AI suffix",
broadcasterMinVersion: "0.7.2-ai.2",
transcoderVersion: "0.7.2-ai.1",
expected: false,
},
{
name: "AI broadcaster required major version is higher than AI transcoder major version",
broadcasterMinVersion: "0.7.2-ai.2",
transcoderVersion: "0.7.2-ai.1",
expected: false,
},
{
name: "AI broadcaster required version AI suffix is lower than AI transcoder AI suffix",
broadcasterMinVersion: "0.7.2-ai.1",
transcoderVersion: "0.7.2-ai.2",
expected: true,
},
{
name: "AI broadcaster required major version is lower than AI transcoder major version",
broadcasterMinVersion: "0.7.2-ai.1",
transcoderVersion: "0.7.3-ai.1",
expected: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 0a56bd1

Please sign in to comment.