github.com/Jeffail/benthos/v3@v3.65.0/lib/test/integration/amqp_1_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 8 "github.com/Azure/go-amqp" 9 "github.com/Jeffail/benthos/v3/internal/integration" 10 "github.com/ory/dockertest/v3" 11 "github.com/stretchr/testify/assert" 12 "github.com/stretchr/testify/require" 13 ) 14 15 var _ = registerIntegrationTest("amqp_1", func(t *testing.T) { 16 t.Parallel() 17 18 pool, err := dockertest.NewPool("") 19 require.NoError(t, err) 20 21 pool.MaxWait = time.Second * 30 22 resource, err := pool.Run("rmohr/activemq", "latest", nil) 23 require.NoError(t, err) 24 t.Cleanup(func() { 25 assert.NoError(t, pool.Purge(resource)) 26 }) 27 28 resource.Expire(900) 29 require.NoError(t, pool.Retry(func() error { 30 client, err := amqp.Dial(fmt.Sprintf("amqp://guest:guest@localhost:%v/", resource.GetPort("5672/tcp"))) 31 if err == nil { 32 client.Close() 33 } 34 return err 35 })) 36 37 template := ` 38 output: 39 amqp_1: 40 url: amqp://guest:guest@localhost:$PORT/ 41 target_address: "queue:/$ID" 42 max_in_flight: $MAX_IN_FLIGHT 43 metadata: 44 exclude_prefixes: [ $OUTPUT_META_EXCLUDE_PREFIX ] 45 46 input: 47 amqp_1: 48 url: amqp://guest:guest@localhost:$PORT/ 49 source_address: "queue:/$ID" 50 ` 51 suite := integration.StreamTests( 52 integration.StreamTestOpenClose(), 53 integration.StreamTestSendBatch(10), 54 integration.StreamTestStreamSequential(1000), 55 integration.StreamTestStreamParallel(1000), 56 integration.StreamTestStreamParallelLossy(1000), 57 integration.StreamTestStreamParallelLossyThroughReconnect(1000), 58 integration.StreamTestMetadata(), 59 integration.StreamTestMetadataFilter(), 60 ) 61 suite.Run( 62 t, template, 63 integration.StreamTestOptSleepAfterInput(100*time.Millisecond), 64 integration.StreamTestOptSleepAfterOutput(100*time.Millisecond), 65 integration.StreamTestOptPort(resource.GetPort("5672/tcp")), 66 ) 67 t.Run("with max in flight", func(t *testing.T) { 68 t.Parallel() 69 suite.Run( 70 t, template, 71 integration.StreamTestOptSleepAfterInput(100*time.Millisecond), 72 integration.StreamTestOptSleepAfterOutput(100*time.Millisecond), 73 integration.StreamTestOptPort(resource.GetPort("5672/tcp")), 74 integration.StreamTestOptMaxInFlight(10), 75 ) 76 }) 77 })