在librd kafka中忽略测试

8cdiaqws  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(500)

我的golang项目依赖于librd kafka
当我想跑的时候 go vet ./... 或者 go test ./... 从我的詹金,我得到以下错误。我想那是因为我在跑步 ./... 但即使我不得不忽略供应商,我也不确定我应该尝试什么 go test $(go list ./... | grep -v /vendor/librdkafka) 但没用。

/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/pkg/mod/gopkg.in/confluentinc/confluent-kafka-go.v1@v1.4.2/kafka/librdkafka/librdkafka_glibc_linux.a(rdkafka_mock_cgrp.o): in function `rd_kafka_mock_cgrp_member_add':

(.text+0x8e5): undefined reference to `__strndup'

/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/pkg/mod/gopkg.in/confluentinc/confluent-kafka-go.v1@v1.4.2/kafka/librdkafka/librdkafka_glibc_linux.a(rdkafka_mock_cgrp.o): in function `rd_kafka_mock_cgrp_get':

(.text+0xd1e): undefined reference to `__strndup'

/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: (.text+0xd46): undefined reference to `__strndup'

/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/pkg/mod/gopkg.in/confluentinc/confluent-kafka-go.v1@v1.4.2/kafka/librdkafka/librdkafka_glibc_linux.a(rdkafka_mock_cgrp.o): in function `rd_kafka_mcgrp_rebalance_timer_cb':

(.text+0x13dd): undefined reference to `__strndup'

我想知道如何在测试我的项目时绕过gcc错误
我的dockerfile:

FROM golang:1.14-alpine AS builder

WORKDIR /src
ENV CGO_ENABLED=0
RUN apk add --no-cache git make
RUN go get \
        github.com/AlekSi/gocov-xml \
        github.com/axw/gocov \
        github.com/tebeka/go2xunit \
        github.com/wadey/gocovmerge

COPY go.mod go.sum ./
RUN  go get -d -v ./...
RUN  go mod download

COPY . .

FROM test AS builder
ENV CGO_ENABLED=1

# this config is for lib rd kafka setup

RUN set -ex &&\
    apk add --no-progress --no-cache \
      gcc \
      musl-dev

WORKDIR /src

RUN go install -tags musl ./...

我的文件片段

stage("Test") {
        agent {
            dockerfile {
                label 'docker'
                additionalBuildArgs '--target test'
                args '-v test:/src/test'
                reuseNode true
            }
        }

        steps {
            parallel(
                    'Unit Test': {
                        sh "make ${makeArgs} test/unit-test"
                    },
                    Coverage: {
                        sh "make ${makeArgs} test/coverage"
                    },
                    Vet: {
                        sh "make ${makeArgs} test/vet"
                    }
            )
        }
        post {
            always {
                junit 'test/*xml'
                publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'test', reportFiles: 'coverage.html', reportName: 'Code Coverage Report'])
                sh "make ${makeArgs} clean"
            }
        }
    }
vfh0ocws

vfh0ocws1#

我只需要运行它 -tags musl 去看兽医-标签musl./。。。

相关问题