mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 09:01:31 +00:00
41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
//go:build integration
|
|
|
|
package integration
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mulgadc/spinifex/spinifex/config"
|
|
handlers_ec2_placementgroup "github.com/mulgadc/spinifex/spinifex/handlers/ec2/placementgroup"
|
|
"github.com/nats-io/nats.go"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// StartPlacementGroupDaemonLite subscribes a real
|
|
// handlers_ec2_placementgroup.PlacementGroupServiceImpl — the same production
|
|
// code a live daemon runs — to every ec2.*PlacementGroup*/ec2.Reserve*/
|
|
// ec2.Finalize*/ec2.Release* subject the gateway's NATSPlacementGroupService
|
|
// client calls (gateway/ec2/placementgroup/*.go and RunInstances.go's spread/
|
|
// cluster routing in gateway/ec2/instance/placement.go). Unlike a StubSubject
|
|
// canned reply, this exercises the real KV-backed CAS reservation logic, so a
|
|
// test that checks placement-group strategy routing actually proves the
|
|
// gateway drove a genuine reserve/finalize round trip rather than merely
|
|
// reaching some daemon-shaped subject.
|
|
//
|
|
// Kept separate from StartDaemonLite (matching StartLaunchTemplateDaemonLite's
|
|
// precedent): only a test that actually exercises placement groups should pay
|
|
// for wiring this service.
|
|
func StartPlacementGroupDaemonLite(t *testing.T, gw *Gateway) *handlers_ec2_placementgroup.PlacementGroupServiceImpl {
|
|
t.Helper()
|
|
|
|
cfg := &config.Config{AZ: testAZ}
|
|
svc, err := handlers_ec2_placementgroup.NewPlacementGroupServiceImplWithNATS(t.Context(), cfg, gw.NATSConn)
|
|
require.NoError(t, err, "construct placement group service")
|
|
|
|
nc := gw.NATSConn
|
|
subscribeServiceMethods(t, nc, "ec2", svc)
|
|
sub(t, nc, "ec2.RemoveInstanceFromPlacementGroup", func(m *nats.Msg) { dispatch(m, svc.RemoveInstance) })
|
|
|
|
return svc
|
|
}
|