Skip to content

Commit

Permalink
Merge branch 'release/0.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
franmoore05 committed May 23, 2023
2 parents f340946 + 6cc3e2a commit 412a082
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 150 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build:

.PHONY: lint
lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0
golangci-lint run ./...

.PHONY: debug
Expand Down
2 changes: 1 addition & 1 deletion ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ image_resource:
type: docker-image
source:
repository: golang
tag: 1.19.2
tag: 1.20.4

inputs:
- name: dp-search-data-finder
Expand Down
2 changes: 1 addition & 1 deletion ci/component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ image_resource:
type: docker-image
source:
repository: golang
tag: 1.19.2
tag: 1.20.4

inputs:
- name: dp-search-data-finder
Expand Down
2 changes: 1 addition & 1 deletion ci/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ image_resource:
type: docker-image
source:
repository: golang
tag: 1.19.2
tag: 1.20.4

inputs:
- name: dp-search-data-finder
Expand Down
2 changes: 1 addition & 1 deletion ci/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ image_resource:
type: docker-image
source:
repository: golang
tag: 1.19.2
tag: 1.20.4

inputs:
- name: dp-search-data-finder
Expand Down
55 changes: 40 additions & 15 deletions features/steps/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
)

const (
gitCommitHash = "3t7e5s1t4272646ef477f8ed755"
appVersion = "v1.2.3"
gitCommitHash = "3t7e5s1t4272646ef477f8ed755"
appVersion = "v1.2.3"
ComponentTestGroup = "component-test" // kafka group name for the component test consumer
)

type state string
Expand All @@ -36,8 +37,8 @@ type Component struct {
errorFeature componenttest.ErrorFeature
errorChan chan error
fakeAPIRouter *FakeAPI
fakeKafkaConsumer kafka.IConsumerGroup
fakeKafkaProducer kafka.IProducer
fakeKafkaConsumer *kafkatest.Consumer
fakeKafkaProducer *kafkatest.Producer
HTTPServer *http.Server
serviceList *service.ExternalServiceList
serviceRunning bool
Expand All @@ -64,14 +65,38 @@ func NewSearchDataFinderComponent() (*Component, error) {

c.cfg = cfg

consumer := kafkatest.NewMessageConsumer(true)
consumer.CheckerFunc = funcCheck
consumer.StartFunc = func() error { return nil }
producer := kafkatest.NewMessageProducer(true)
producer.CheckerFunc = funcCheck
if c.fakeKafkaConsumer, err = kafkatest.NewConsumer(
ctx,
&kafka.ConsumerGroupConfig{
BrokerAddrs: cfg.KafkaConfig.Brokers,
Topic: cfg.KafkaConfig.ReindexRequestedTopic,
GroupName: ComponentTestGroup,
KafkaVersion: &cfg.KafkaConfig.Version,
},
&kafkatest.ConsumerConfig{
NumPartitions: 10,
ChannelBufferSize: 10,
InitAtCreation: true,
},
); err != nil {
return nil, fmt.Errorf("error creating kafka consumer: %w", err)
}

c.fakeKafkaConsumer = consumer
c.fakeKafkaProducer = producer
c.fakeKafkaConsumer.Mock.CheckerFunc = funcCheck
c.fakeKafkaConsumer.Mock.StartFunc = func() error { return nil }

if c.fakeKafkaProducer, err = kafkatest.NewProducer(
ctx,
&kafka.ProducerConfig{
BrokerAddrs: cfg.KafkaConfig.Brokers,
Topic: cfg.KafkaConfig.ContentUpdatedTopic,
KafkaVersion: &cfg.KafkaConfig.Version,
},
nil,
); err != nil {
return nil, fmt.Errorf("error creating kafka producer: %w", err)
}
c.fakeKafkaProducer.Mock.CheckerFunc = funcCheck

c.fakeAPIRouter = NewFakeAPI()
c.cfg.APIRouterURL = c.fakeAPIRouter.fakeHTTP.ResolveURL("")
Expand All @@ -80,13 +105,13 @@ func NewSearchDataFinderComponent() (*Component, error) {

initMock := &mock.InitialiserMock{
DoGetKafkaConsumerFunc: func(ctx context.Context, kafkaCfg *config.KafkaConfig) (kafkaConsumer kafka.IConsumerGroup, err error) {
return c.fakeKafkaConsumer, nil
return c.fakeKafkaConsumer.Mock, nil
},
DoGetKafkaProducerFunc: func(ctx context.Context, config *config.Config) (kafkaConsumer kafka.IProducer, err error) {
return c.fakeKafkaProducer, nil
return c.fakeKafkaProducer.Mock, nil
},
DoGetKafkaProducerForReindexTaskCountsFunc: func(ctx context.Context, config *config.Config) (kafkaConsumer kafka.IProducer, err error) {
return c.fakeKafkaProducer, nil
return c.fakeKafkaProducer.Mock, nil
},
DoGetHealthCheckFunc: getHealthCheckOK,
DoGetHealthClientFunc: c.getHealthClientOK,
Expand Down Expand Up @@ -138,7 +163,7 @@ func (c *Component) Close() error {

func (c *Component) Reset() (*Component, error) {
ctx := context.WithValue(context.Background(), s, "empty")
if err := c.fakeKafkaConsumer.Checker(ctx, healthcheck.NewCheckState("topic-test")); err != nil {
if err := c.fakeKafkaConsumer.Mock.Checker(ctx, healthcheck.NewCheckState("topic-test")); err != nil {
return c, err
}

Expand Down
2 changes: 1 addition & 1 deletion features/steps/fakeapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"net/http"

dphttp "github.com/ONSdigital/dp-net/http"
dphttp "github.com/ONSdigital/dp-net/v2/http"
"github.com/maxcnunes/httpfake"
)

Expand Down
4 changes: 2 additions & 2 deletions features/steps/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func delayTimeByMilliSeconds(milliseconds string) (err error) {

func (c *Component) allOfTheDownstreamServicesAreHealthy() (err error) {
c.fakeAPIRouter.setJSONResponseForGetHealth(200)
err = c.fakeKafkaConsumer.Checker(context.Background(), healthcheck.NewCheckState("topic-test"))
err = c.fakeKafkaConsumer.Mock.Checker(context.Background(), healthcheck.NewCheckState("topic-test"))

return
}
Expand Down Expand Up @@ -198,6 +198,6 @@ func (c *Component) sendToConsumer(e *models.ReindexRequested) error {
return err
}

c.fakeKafkaConsumer.Channels().Upstream <- newMessage
c.fakeKafkaConsumer.Mock.Channels().Upstream <- newMessage
return nil
}
48 changes: 22 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
module github.com/ONSdigital/dp-search-data-finder

go 1.19
go 1.20

// fix vulnerability: CVE-2020-15114 in etcd v3.3.13+incompatible
replace github.com/coreos/etcd => github.com/coreos/etcd v3.3.24+incompatible

require (
github.com/ONSdigital/dp-api-clients-go/v2 v2.191.0
github.com/ONSdigital/dp-api-clients-go/v2 v2.252.1
github.com/ONSdigital/dp-component-test v0.8.0
github.com/ONSdigital/dp-healthcheck v1.5.0
github.com/ONSdigital/dp-kafka/v3 v3.8.0
github.com/ONSdigital/dp-net v1.5.0
github.com/ONSdigital/dp-net/v2 v2.6.0
github.com/ONSdigital/log.go/v2 v2.3.0
github.com/ONSdigital/dp-healthcheck v1.6.1
github.com/ONSdigital/dp-kafka/v3 v3.10.0
github.com/ONSdigital/dp-net/v2 v2.9.1
github.com/ONSdigital/log.go/v2 v2.4.1
github.com/cucumber/godog v0.12.5
github.com/gorilla/mux v1.8.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/maxcnunes/httpfake v1.2.4
github.com/pkg/errors v0.9.1
github.com/rdumont/assistdog v0.0.0-20201106100018-168b06230d14
github.com/smartystreets/goconvey v1.7.2
github.com/stretchr/testify v1.8.0
github.com/smartystreets/goconvey v1.8.0
github.com/stretchr/testify v1.8.1
)

require (
github.com/ONSdigital/dp-api-clients-go v1.43.0 // indirect
github.com/ONSdigital/dp-mongodb-in-memory v1.3.1 // indirect
github.com/Shopify/sarama v1.37.2 // indirect
github.com/aws/aws-sdk-go v1.44.113 // indirect
github.com/Shopify/sarama v1.38.1 // indirect
github.com/chromedp/cdproto v0.0.0-20221007020655-65fa4346613f // indirect
github.com/chromedp/chromedp v0.8.6 // indirect
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
github.com/cucumber/messages-go/v16 v16.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eapache/go-resiliency v1.3.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230111030713-bf00bc1b83b6 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/go-avro/avro v0.0.0-20171219232920-444163702c11 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
Expand All @@ -56,33 +53,32 @@ require (
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.3 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/justinas/alice v1.2.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/smartystreets/assertions v1.13.0 // indirect
github.com/smartystreets/assertions v1.13.1 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.mongodb.org/mongo-driver v1.10.3 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 412a082

Please sign in to comment.