Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go 忽略librd kafka中的测试_Go_Apache Kafka_Dockerfile_Librdkafka - Fatal编程技术网

Go 忽略librd kafka中的测试

Go 忽略librd kafka中的测试,go,apache-kafka,dockerfile,librdkafka,Go,Apache Kafka,Dockerfile,Librdkafka,我的golang项目依赖于librd kafka 当我试图从jenkin那里运行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/

我的golang项目依赖于librd kafka

当我试图从jenkin那里运行
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"
            }
        }
    }

我只需要运行它
-tags musl


转到vet-tags musl./…

使用-run标志并指定regex模式以跳过给定的供应商。看,这可能会有帮助。我的项目有多个测试,当我从jenkins pipeleine运行时,我希望运行项目中的所有测试,而忽略依赖的libradkafka/gcc测试<代码>-运行只会对我有所帮助,因为我只想运行一个测试,对吧。。。。但是我有不止一个选项`-runregex`,我必须为我的所有测试引入一个唯一的命名,这样regex就可以选择它。这是我想要避免的事情。为什么不编写一个bash脚本,将其转到所需的目录并调用
go test