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

Do not skip flaky test in CI #85

Merged
merged 1 commit into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ func (ch *Channel) sendOpen(msg message) (err error) {
size = len(body)
}

// If the channel is closed, use Channel.sendClosed()
if atomic.LoadInt32(&ch.closed) == 1 {
return ch.sendClosed(msg)
}

if err = ch.connection.send(&methodFrame{
ChannelId: ch.id,
Method: content,
lukebakken marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -260,6 +265,11 @@ func (ch *Channel) sendOpen(msg message) (err error) {
}
}
} else {
// If the channel is closed, use Channel.sendClosed()
if atomic.LoadInt32(&ch.closed) == 1 {
return ch.sendClosed(msg)
}

err = ch.connection.send(&methodFrame{
ChannelId: ch.id,
Method: msg,
Expand Down
1 change: 0 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ func DialConfig(url string, config Config) (*Connection, error) {

client := tls.Client(conn, config.TLSClientConfig)
if err := client.Handshake(); err != nil {

conn.Close()
return nil, err
}
Expand Down
46 changes: 33 additions & 13 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"reflect"
"strconv"
"strings"
"sync"
"testing"
"testing/quick"
Expand Down Expand Up @@ -1540,25 +1539,46 @@ func TestDeadlockConsumerIssue48(t *testing.T) {

// https://github.com/streadway/amqp/issues/46
func TestRepeatedChannelExceptionWithPublishAndMaxProcsIssue46(t *testing.T) {
if strings.Compare(os.Getenv("CI"), "true") == 0 {
t.Skip("FLAKY - https://github.com/rabbitmq/amqp091-go/issues/77")
}
conn := integrationConnection(t, "issue46")
if conn != nil {
t.Cleanup(func() { conn.Close() })
var conn *Connection = nil

for i := 0; i < 100; i++ {
ch, err := conn.Channel()
if err != nil {
t.Fatalf("expected error only on publish, got error on channel.open: %v", err)
t.Cleanup(func() {
if conn != nil {
conn.Close()
}
})

for i := 0; i < 100; i++ {
if conn == nil || conn.IsClosed() {
lukebakken marked this conversation as resolved.
Show resolved Hide resolved
conn = integrationConnection(t, "issue46")
if conn == nil {
t.Fatal("conn is nil")
}
lukebakken marked this conversation as resolved.
Show resolved Hide resolved
}

ch, err := conn.Channel()
if err, ok := err.(Error); ok {
if err.Code != 504 {
t.Fatalf("expected channel only exception i: %d got: %+v", i, err)
}
}
lukebakken marked this conversation as resolved.
Show resolved Hide resolved

for j := 0; j < 10; j++ {
if ch == nil {
continue
}

for j := 0; j < 10; j++ {
if ch.IsClosed() {
break
} else {
err = ch.Publish("not-existing-exchange", "some-key", false, false, Publishing{Body: []byte("some-data")})
if err, ok := err.(Error); ok {
if err.Code != 504 {
t.Fatalf("expected channel only exception, got: %v", err)
t.Fatalf("expected channel only exception i: %d j: %d got: %+v", i, j, err)
}
if cerr := ch.Close(); cerr != nil {
t.Logf("error on channel close i: %d j: %d got: %+v", i, j, cerr)
}
break
}
}
}
Expand Down