Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switch OS, switch search queries and better datastore tests. #416

Merged
merged 7 commits into from
Feb 23, 2023

Conversation

Gerrit91
Copy link
Contributor

@Gerrit91 Gerrit91 marked this pull request as ready for review February 22, 2023 10:32
@Gerrit91 Gerrit91 requested a review from a team as a code owner February 22, 2023 10:32
Copy link
Contributor

@majst01 majst01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like it, but then we must first test this with released metal-hammer and metal-core

cmd/metal-api/main.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
Comment on lines -52 to -58
if len(macs) > 0 {
macexpr := r.Expr(macs)

q = q.Filter(func(row r.Term) r.Term {
return macexpr.SetIntersection(row.Field("network_interfaces").Field("macAddress")).Count().Gt(1)
})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was never used and also I integration-tested this, it's not working! I removed it.

@@ -123,12 +138,13 @@ func (rs *RethinkStore) SetVrfAtSwitches(m *metal.Machine, vrf string) ([]metal.
}

func (rs *RethinkStore) ConnectMachineWithSwitches(m *metal.Machine) error {
switches, err := rs.SearchSwitchesByPartition(m.PartitionID)
switches, err := rs.ListSwitches()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually allowed because of the following reasoning:

This function is only called when registering a machine. Found out that m.PartitionID is not set in the caller and always "", which effectively turns this into a ListSwitches. The metal-hammer does not send this anymore, so I assume it's a leftover when we started calculating the partition in the metal-api.

)

func TestRethinkStore_ConflictIsReturned(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now already covered in a switch test and will also be covered in all other tests if we start to test like this for the rest of the package. Hence removed.

@@ -85,31 +85,6 @@ func TestRethinkStore_db(t *testing.T) {
}
}

func TestRethinkStore_Mock(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is rather useless and also the linter does not like it, therefore removed.

@Gerrit91
Copy link
Contributor Author

Works on the mini-lab (switch registration plus machine provisioning), so it's compatible with the current metal-core and metal-hammer. No breaking API changes included.

@majst01 majst01 merged commit 2ff533e into master Feb 23, 2023
@majst01 majst01 deleted the switch-os-and-tests branch February 23, 2023 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants