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

Feature/modernize channel model #635

Merged
merged 11 commits into from
Oct 18, 2021

Conversation

jimmywarting
Copy link
Contributor

@jimmywarting jimmywarting commented Jul 6, 2021

Time for channel_model.js to be modernized

bf2a8d0 was not done manually... was executed using:

lebab --replace lib/channel_model.js  --transform arrow,let,includes,template,default-param,obj-shorthand,obj-method,arg-spread,arg-rest,for-each,class
Would be grate to get GitHub Actions for proper CI, in the meanwhile here is a log from node v16
npm run test

> amqplib@0.8.0 test
> make test

./node_modules/.bin/mocha --check-leaks -u tdd test/


  ✓ single input
  ✓ single input, resuming stream
  ✓ two sequential inputs
  ✓ two interleaved inputs
  ✓ unpipe
  ✓ roundrobin
  BitSet
    ✓ get bit
    ✓ clear bit
    ✓ next set of empty
    ✓ next set of one bit
    ✓ next set same bit
    ✓ next set following bit
    ✓ next clear of empty
    ✓ next clear of one set

  versionGreaterThan
    ✓ full spec
    ✓ partial spec
    ✓ not greater

  connect
    ✓ at all

  channel open
    ✓ at all
    ✓ open and close

  assert, check, delete
    ✓ assert, check, delete queue (53ms)
    ✓ assert, check, delete exchange (101ms)
    ✓ fail on check non-queue
    ✓ fail on check non-exchange

  bindings
    ✓ bind queue
    ✓ bind exchange

  sending messages
    ✓ send to queue and consume noAck
    ✓ send to queue and consume ack
    ✓ send to and get from queue

  ConfirmChannel
    ✓ Receive confirmation
    ✓ Wait for confirms (52ms)

  Error handling
    ✓ Throw error in connection open callback
    ✓ Channel open callback throws an error
    ✓ RPC callback throws error
    ✓ Get callback throws error
    ✓ Consume callback throws error
    ✓ Get from non-queue invokes error k
    ✓ Consume from non-queue invokes error k

  Connection errors
    ✓ socket close during open
    ✓ bad frame during open

  Connection open
    ✓ happy
    ✓ wrong first frame
    ✓ unexpected socket close

  Connection running
    ✓ wrong frame on channel 0
    ✓ unopened channel
    ✓ unexpected socket close
    ✓ connection.blocked
    ✓ connection.unblocked

  Connection close
    ✓ happy
    ✓ interleaved close frames
    ✓ server error close
    ✓ operator-intiated close
    ✓ double close

  heartbeats
    ✓ send heartbeat after open
    ✓ detect lack of heartbeats (63ms)

  channel open and close
    ✓ open
    ✓ bad server
    ✓ open, close
    ✓ server close
    ✓ overlapping channel/server close
    ✓ double close

  channel machinery
    ✓ RPC
    ✓ Bad RPC
    ✓ RPC on closed channel
    ✓ publish all < single chunk threshold
    ✓ publish content > single chunk threshold
    ✓ publish method & headers > threshold
    ✓ publish zero-length message
    ✓ delivery
    ✓ zero byte msg
    ✓ bad delivery
    ✓ bad content send
    ✓ bad properties send
    ✓ bad consumer
    ✓ bad send in consumer
    ✓ return
    ✓ cancel
    ✓ confirm ack
    ✓ confirm nack
    ✓ out-of-order acks
    ✓ not all out-of-order acks

  connect
    ✓ at all
    ✓ create channel

  assert, check, delete
    ✓ assert and check queue
    ✓ assert and check exchange
    ✓ fail on reasserting queue with different options
    ✓ fail on checking a queue that's not there
    ✓ fail on checking an exchange that's not there
    ✓ fail on reasserting exchange with different type
    ✓ channel break on publishing to non-exchange
    ✓ delete queue (71ms)
    ✓ delete exchange (225ms)

  sendMessage
    ✓ send to queue and get from queue
    ✓ send (and get) zero content to queue

  binding, consuming
    ✓ route message
    ✓ purge queue
    ✓ unbind queue
    ✓ consume via exchange-exchange binding
    ✓ unbind exchange
    ✓ cancel consumer
    ✓ cancelled consumer (52ms)
    ✓ ack
    ✓ nack
    ✓ reject
    ✓ prefetch
    ✓ close

  confirms
    ✓ message is confirmed
    ✓ multiple confirms
    ✓ wait for confirms (43ms)
    ✓ works when channel is closed (67ms)

  Implicit encodings
    ✓ byte
    ✓ byte max value
    ✓ byte min value
    ✓ < -128 promoted to signed short
    ✓ > 127 promoted to short
    ✓ < 2^15 still a short
    ✓ -2^15 still a short
    ✓ >= 2^15 promoted to int
    ✓ < -2^15 promoted to int
    ✓ < 2^31 still an int
    ✓ >= -2^31 still an int
    ✓ >= 2^31 promoted to long
    ✓ < -2^31 promoted to long
    ✓ float value
    ✓ negative float value
    ✓ string
    ✓ byte array from buffer
    ✓ true
    ✓ false
    ✓ null
    ✓ array
    ✓ object
    ✓ timestamp
    ✓ decimal
    ✓ float

  Domains
    ✓ <octet> domain
    ✓ <shortstr> domain
    ✓ <longstr> domain
    ✓ <short-uint> domain
    ✓ <long-uint> domain
    ✓ <longlong-uint> domain
    ✓ <short-int> domain
    ✓ <long-int> domain
    ✓ <longlong-int> domain
    ✓ <bit> domain
    ✓ <double> domain
    ✓ <float> domain
    ✓ <decimal> domain
    ✓ <timestamp> domain
    ✓ <table> domain
    ✓ <field-array> domain (93ms)

  Roundtrip values
    ✓ <octet> roundtrip
    ✓ <shortstr> roundtrip
    ✓ <longstr> roundtrip
    ✓ <short-uint> roundtrip
    ✓ <long-uint> roundtrip
    ✓ <longlong-uint> roundtrip
    ✓ <short-uint> roundtrip
    ✓ <short-int> roundtrip
    ✓ <long-int> roundtrip
    ✓ <bit> roundtrip
    ✓ <decimal> roundtrip
    ✓ <timestamp> roundtrip
    ✓ <double> roundtrip
    ✓ <float> roundtrip
    ✓ <field-array> roundtrip
    ✓ <table> roundtrip

  Roundtrip methods
    ✓ <ConnectionStart> roundtrip
    ✓ <ConnectionStartOk> roundtrip
    ✓ <ConnectionSecure> roundtrip
    ✓ <ConnectionSecureOk> roundtrip
    ✓ <ConnectionTune> roundtrip
    ✓ <ConnectionTuneOk> roundtrip
    ✓ <ConnectionOpen> roundtrip
    ✓ <ConnectionOpenOk> roundtrip
    ✓ <ConnectionClose> roundtrip
    ✓ <ConnectionCloseOk> roundtrip
    ✓ <ConnectionBlocked> roundtrip
    ✓ <ConnectionUnblocked> roundtrip
    ✓ <ChannelOpen> roundtrip
    ✓ <ChannelOpenOk> roundtrip
    ✓ <ChannelFlow> roundtrip
    ✓ <ChannelFlowOk> roundtrip
    ✓ <ChannelClose> roundtrip
    ✓ <ChannelCloseOk> roundtrip
    ✓ <AccessRequest> roundtrip
    ✓ <AccessRequestOk> roundtrip
    ✓ <ExchangeDeclare> roundtrip
    ✓ <ExchangeDeclareOk> roundtrip
    ✓ <ExchangeDelete> roundtrip
    ✓ <ExchangeDeleteOk> roundtrip
    ✓ <ExchangeBind> roundtrip
    ✓ <ExchangeBindOk> roundtrip
    ✓ <ExchangeUnbind> roundtrip
    ✓ <ExchangeUnbindOk> roundtrip
    ✓ <QueueDeclare> roundtrip
    ✓ <QueueDeclareOk> roundtrip
    ✓ <QueueBind> roundtrip
    ✓ <QueueBindOk> roundtrip
    ✓ <QueuePurge> roundtrip
    ✓ <QueuePurgeOk> roundtrip
    ✓ <QueueDelete> roundtrip
    ✓ <QueueDeleteOk> roundtrip
    ✓ <QueueUnbind> roundtrip
    ✓ <QueueUnbindOk> roundtrip
    ✓ <BasicQos> roundtrip
    ✓ <BasicQosOk> roundtrip
    ✓ <BasicConsume> roundtrip
    ✓ <BasicConsumeOk> roundtrip
    ✓ <BasicCancel> roundtrip
    ✓ <BasicCancelOk> roundtrip
    ✓ <BasicPublish> roundtrip
    ✓ <BasicReturn> roundtrip
    ✓ <BasicDeliver> roundtrip
    ✓ <BasicGet> roundtrip
    ✓ <BasicGetOk> roundtrip
    ✓ <BasicGetEmpty> roundtrip
    ✓ <BasicAck> roundtrip
    ✓ <BasicReject> roundtrip
    ✓ <BasicRecoverAsync> roundtrip
    ✓ <BasicRecover> roundtrip
    ✓ <BasicRecoverOk> roundtrip
    ✓ <BasicNack> roundtrip
    ✓ <TxSelect> roundtrip
    ✓ <TxSelectOk> roundtrip
    ✓ <TxCommit> roundtrip
    ✓ <TxCommitOk> roundtrip
    ✓ <TxRollback> roundtrip
    ✓ <TxRollbackOk> roundtrip
    ✓ <ConfirmSelect> roundtrip
    ✓ <ConfirmSelectOk> roundtrip

  Roundtrip properties
    ✓ <BasicProperties> roundtrip

  Credentials
    ✓ no creds
    ✓ usual user:pass
    ✓ missing user
    ✓ missing password
    ✓ escaped colons

  Connect API
    ✓ Connection refused
    ✓ bad URL
    ✓ wrongly typed open option
    ✓ serverProperties
    ✓ using custom heartbeat option
    ✓ wrongly typed heartbeat option
    ✓ using plain credentials
    ✓ using amqplain credentials
    ✓ using unsupported mechanism
    ✓ with a given connection timeout (53ms)

  Explicit parsing
    ✓ Parse heartbeat
    ✓ Parse partitioned
    ✓ Wrong sized frame
    ✓ Unknown method frame
    ✓ > max frame

  Parsing
    ✓ Parse trace of methods
    ✓ Parse concat'd methods (39ms)
    ✓ Parse partitioned methods

  Content framing
    ✓ Adhere to frame max (120ms)


  256 passing (2s)

@squaremo
Copy link
Collaborator

I transferred the CI to travis-ci.com; but I seems it won't run until there's some new activity on the branch :-/

jimmywarting@a20ce31 "revert some failing test" is interesting, that's the same places as #624 (review) has a similar problem (native promises don't behave the same as bluebird promises). It's not necessary to figure it out here though.

@kibertoad
Copy link
Collaborator

I'll try to setup GitHub Actions, Travis is really not a good option anymore.

@squaremo
Copy link
Collaborator

If you rebase on main, it'll run the tests in GitHub Actions.

@squaremo squaremo force-pushed the feature/modernize-channel-model branch from 98884d8 to c25440e Compare October 18, 2021 08:27
@squaremo
Copy link
Collaborator

Whoops, that duplicated all the commits. I've tidied up with git rebase -i, removing the duplicates.

Copy link
Collaborator

@squaremo squaremo left a comment

Choose a reason for hiding this comment

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

Another module dragged into the 202nd decade! Thank you @jimmywarting 🙏

@squaremo squaremo merged commit 243aef8 into amqp-node:main Oct 18, 2021
@jimmywarting jimmywarting deleted the feature/modernize-channel-model branch October 18, 2021 09:05
@jimmywarting
Copy link
Contributor Author

ups, sorry about that, did rebase incorrectly

@cressie176 cressie176 mentioned this pull request May 9, 2022
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.

3 participants