Skip to content

Commit b4c041b

Browse files
mihaitodortwmb
authored andcommitted
fix integration test action
1 parent 0a0076f commit b4c041b

File tree

4 files changed

+46
-35
lines changed

4 files changed

+46
-35
lines changed

Diff for: .github/workflows/lint-and-test.yml

+33-30
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
golangci:
1515
if: github.repository == 'twmb/franz-go'
1616
runs-on: ubuntu-latest
17-
name: 'golangci-lint on amd64'
17+
name: "golangci-lint on amd64"
1818
steps:
1919
- uses: actions/checkout@v3
2020
- uses: actions/setup-go@v3
@@ -28,7 +28,7 @@ jobs:
2828
if: github.repository == 'twmb/franz-go'
2929
needs: golangci
3030
runs-on: ubuntu-latest
31-
name: 'vet on arm'
31+
name: "vet on arm"
3232
steps:
3333
- uses: actions/checkout@v3
3434
with:
@@ -58,31 +58,34 @@ jobs:
5858
echo "staticcheck ./..."
5959
staticcheck -checks 'all,-ST1003,-SA1012,-ST1016,-SA1019,-SA2001' ./... # actually contains atomicalign check
6060
61-
# TODO: fix
62-
# integration-test:
63-
# if: github.repository == 'twmb/franz-go'
64-
# needs: golangci
65-
# runs-on: ubuntu-latest
66-
# name: 'integration test kafka'
67-
# container: golang:1.19.2
68-
# services:
69-
# zk:
70-
# image: bitnami/zookeeper:latest
71-
# ports:
72-
# - 2181:2181
73-
# env:
74-
# ALLOW_ANONYMOUS_LOGIN: yes
75-
# kafka:
76-
# image: bitnami/kafka:latest
77-
# ports:
78-
# - 9092:9092
79-
# env:
80-
# ALLOW_PLAINTEXT_LISTENER: yes
81-
# KAFKA_CFG_ZOOKEEPER_CONNECT: zk:2181
82-
# steps:
83-
# - uses: actions/checkout@v3
84-
# - run: go test ./...
85-
# env:
86-
# KGO_TEST_RF: 1
87-
# KGO_SEEDS: kafka:9092
88-
# KGO_TEST_RECORDS: 50000
61+
integration-test:
62+
if: github.repository == 'twmb/franz-go'
63+
needs: golangci
64+
runs-on: ubuntu-latest
65+
name: "integration test kafka"
66+
container: golang:1.19.2
67+
services:
68+
kafka:
69+
image: bitnami/kafka:latest
70+
ports:
71+
- 9092:9092
72+
env:
73+
KAFKA_ENABLE_KRAFT: yes
74+
KAFKA_CFG_PROCESS_ROLES: controller,broker
75+
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
76+
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
77+
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
78+
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: [email protected]:9093
79+
# Set this to "PLAINTEXT://127.0.0.1:9092" if you want to run this container on localhost via Docker
80+
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
81+
KAFKA_CFG_BROKER_ID: 1
82+
ALLOW_PLAINTEXT_LISTENER: yes
83+
KAFKA_KRAFT_CLUSTER_ID: XkpGZQ27R3eTl3OdTm2LYA # 16 byte base64-encoded UUID
84+
# BITNAMI_DEBUG: true # Enable this to get more info on startup failures
85+
steps:
86+
- uses: actions/checkout@v3
87+
- run: go test ./...
88+
env:
89+
KGO_TEST_RF: 1
90+
KGO_SEEDS: kafka:9092
91+
KGO_TEST_RECORDS: 50000

Diff for: pkg/kgo/group_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestGroupETL(t *testing.T) {
3737

3838
go func() {
3939
cl, _ := NewClient(
40+
getSeedBrokers(),
4041
WithLogger(BasicLogger(os.Stderr, testLogLevel, nil)),
4142
MaxBufferedRecords(10000),
4243
UnknownTopicRetries(-1), // see txn_test comment
@@ -117,6 +118,7 @@ func (c *testConsumer) etl(etlsBeforeQuit int) {
117118
netls := 0 // for if etlsBeforeQuit is non-negative
118119

119120
opts := []Opt{
121+
getSeedBrokers(),
120122
UnknownTopicRetries(-1), // see txn_test comment
121123
WithLogger(testLogger()),
122124
ConsumerGroup(c.group),

Diff for: pkg/kgo/helpers_test.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ var (
2525
)
2626

2727
func init() {
28-
seeds := os.Getenv("KGO_SEEDS")
29-
if seeds == "" {
30-
seeds = "127.0.0.1:9092"
31-
}
3228
var err error
33-
adm, err = NewClient(SeedBrokers(strings.Split(seeds, ",")...))
29+
adm, err = NewClient(getSeedBrokers())
3430
if err != nil {
3531
panic(fmt.Sprintf("unable to create admin client: %v", err))
3632
}
@@ -43,6 +39,14 @@ func init() {
4339
}
4440
}
4541

42+
func getSeedBrokers() Opt {
43+
seeds := os.Getenv("KGO_SEEDS")
44+
if seeds == "" {
45+
seeds = "127.0.0.1:9092"
46+
}
47+
return SeedBrokers(strings.Split(seeds, ",")...)
48+
}
49+
4650
var loggerNum int64
4751

4852
var testLogLevel = func() LogLevel {

Diff for: pkg/kgo/txn_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func TestTxnEtl(t *testing.T) {
2828

2929
go func() {
3030
cl, err := NewClient(
31+
getSeedBrokers(),
3132
WithLogger(BasicLogger(os.Stderr, testLogLevel, nil)),
3233
TransactionalID("p"+randsha()),
3334
TransactionTimeout(2*time.Minute),
@@ -136,6 +137,7 @@ func (c *testConsumer) goTransact(txnsBeforeQuit int) {
136137
func (c *testConsumer) transact(txnsBeforeQuit int) {
137138
defer c.wg.Done()
138139
txnSess, _ := NewGroupTransactSession(
140+
getSeedBrokers(),
139141
// Kraft sometimes has massive hangs internally when completing
140142
// transactions. Against zk Kafka, we could rely on our
141143
// internal mitigations to never have KIP-447 problems.

0 commit comments

Comments
 (0)