From 140f151b377ed833463e4f00cc9771c23ca73480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20=22Kang=22=20P=C3=A9rez?= Date: Fri, 4 Oct 2024 10:32:06 +0200 Subject: [PATCH] Upgrade integrations SDK (NR-302384) (#175) * upgrade infra-sdk to a compatible v3 version * add entry to changelog * go mod tidy * go upgrade to 1.23.2 * remove old build comment * add entry to changelog for go 1.22.3 * debug --- CHANGELOG.md | 8 ++++++++ build/Dockerfile | 2 +- go.mod | 9 +++------ go.sum | 6 ++---- src/args/argument_list.go | 4 ++-- src/connection/sql_connection.go | 2 +- src/database/sql_database.go | 6 +++--- src/database/sql_database_test.go | 4 ++-- src/instance/sql_instance.go | 2 +- src/instance/sql_instance_test.go | 2 +- src/inventory/inventory.go | 4 ++-- src/inventory/inventory_test.go | 4 ++-- src/metrics/metrics.go | 8 ++++---- src/metrics/metrics_test.go | 4 ++-- src/mssql.go | 4 ++-- tests/docker-compose.yml | 4 ++-- tests/helper.go | 3 +-- tests/mssql_test.go | 26 +++++++++++++++++++++++++- 18 files changed, 64 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a4173c9..07cc5694 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,14 @@ Unreleased section should follow [Release Toolkit](https://github.com/newrelic/r ## Unreleased +### dependency + +- Upgrade go to 1.23.2 + +### enhancements + +- Upgrade integrations SDK so the interval is variable and allows intervals up to 5 minutes + ## v2.12.8 - 2024-09-17 ### 🐞 Bug fixes diff --git a/build/Dockerfile b/build/Dockerfile index 319d8907..49b8674f 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23.1-bookworm +FROM golang:1.23.2-bookworm ARG GH_VERSION='1.9.2' diff --git a/go.mod b/go.mod index ad56966c..24ac3c7d 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ module github.com/newrelic/nri-mssql -go 1.23.1 +go 1.23.2 require ( github.com/jmoiron/sqlx v1.4.0 github.com/microsoft/go-mssqldb v1.7.2 - github.com/newrelic/infra-integrations-sdk v3.8.2+incompatible + github.com/newrelic/infra-integrations-sdk/v3 v3.9.1 github.com/stretchr/testify v1.9.0 github.com/xeipuuv/gojsonschema v1.2.0 gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 @@ -16,7 +16,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect @@ -25,10 +24,8 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -godebug ( // Allows TLS certs with negative serial numbers. // Before go 1.23 these certificates where accepted, now the corresponding go debug variable is needed // to restore the previous behavior // - x509negativeserial=1 -) +godebug x509negativeserial=1 diff --git a/go.sum b/go.sum index cac0405f..d6b99ce1 100644 --- a/go.sum +++ b/go.sum @@ -35,12 +35,10 @@ github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP3b/PA= github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= -github.com/newrelic/infra-integrations-sdk v3.8.2+incompatible h1:Ktcm1aPAl7CW3o+FXAIKJ+jygWVXDXaUIWFyf2CXQTk= -github.com/newrelic/infra-integrations-sdk v3.8.2+incompatible/go.mod h1:tMUHRMq6mJS0YyBnbWrTXAnREnQqC1AGO6Lu45u5xAM= +github.com/newrelic/infra-integrations-sdk/v3 v3.9.1 h1:dCtVLsYNHWTQ5aAlAaHroomOUlqxlGTrdi6XTlvBDfI= +github.com/newrelic/infra-integrations-sdk/v3 v3.9.1/go.mod h1:yPeidhcq9Cla0QDquGXH0KqvS2k9xtetFOD7aLA0Z8M= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/src/args/argument_list.go b/src/args/argument_list.go index ca75848a..1e8ca8b4 100644 --- a/src/args/argument_list.go +++ b/src/args/argument_list.go @@ -5,8 +5,8 @@ import ( "errors" "os" - sdkArgs "github.com/newrelic/infra-integrations-sdk/args" - "github.com/newrelic/infra-integrations-sdk/log" + sdkArgs "github.com/newrelic/infra-integrations-sdk/v3/args" + "github.com/newrelic/infra-integrations-sdk/v3/log" ) // ArgumentList struct that holds all MSSQL arguments diff --git a/src/connection/sql_connection.go b/src/connection/sql_connection.go index 181f411d..39835c01 100644 --- a/src/connection/sql_connection.go +++ b/src/connection/sql_connection.go @@ -9,7 +9,7 @@ import ( // go-mssqldb is required for mssql driver but isn't used in code "github.com/jmoiron/sqlx" _ "github.com/microsoft/go-mssqldb" - "github.com/newrelic/infra-integrations-sdk/log" + "github.com/newrelic/infra-integrations-sdk/v3/log" "github.com/newrelic/nri-mssql/src/args" ) diff --git a/src/database/sql_database.go b/src/database/sql_database.go index fbf49655..3c0cf18f 100644 --- a/src/database/sql_database.go +++ b/src/database/sql_database.go @@ -4,9 +4,9 @@ package database import ( "reflect" - "github.com/newrelic/infra-integrations-sdk/data/attribute" - "github.com/newrelic/infra-integrations-sdk/data/metric" - "github.com/newrelic/infra-integrations-sdk/integration" + "github.com/newrelic/infra-integrations-sdk/v3/data/attribute" + "github.com/newrelic/infra-integrations-sdk/v3/data/metric" + "github.com/newrelic/infra-integrations-sdk/v3/integration" "github.com/newrelic/nri-mssql/src/connection" ) diff --git a/src/database/sql_database_test.go b/src/database/sql_database_test.go index ad4f9cdb..17a09e6a 100644 --- a/src/database/sql_database_test.go +++ b/src/database/sql_database_test.go @@ -6,8 +6,8 @@ import ( "sort" "testing" - "github.com/newrelic/infra-integrations-sdk/data/attribute" - "github.com/newrelic/infra-integrations-sdk/integration" + "github.com/newrelic/infra-integrations-sdk/v3/data/attribute" + "github.com/newrelic/infra-integrations-sdk/v3/integration" "github.com/newrelic/nri-mssql/src/connection" "gopkg.in/DATA-DOG/go-sqlmock.v1" ) diff --git a/src/instance/sql_instance.go b/src/instance/sql_instance.go index 6d4dcd4f..5d057b8d 100644 --- a/src/instance/sql_instance.go +++ b/src/instance/sql_instance.go @@ -5,7 +5,7 @@ import ( "database/sql" "fmt" - "github.com/newrelic/infra-integrations-sdk/integration" + "github.com/newrelic/infra-integrations-sdk/v3/integration" "github.com/newrelic/nri-mssql/src/connection" ) diff --git a/src/instance/sql_instance_test.go b/src/instance/sql_instance_test.go index 219ce3c2..a802ca94 100644 --- a/src/instance/sql_instance_test.go +++ b/src/instance/sql_instance_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/newrelic/infra-integrations-sdk/integration" + "github.com/newrelic/infra-integrations-sdk/v3/integration" "github.com/newrelic/nri-mssql/src/connection" "github.com/stretchr/testify/assert" "gopkg.in/DATA-DOG/go-sqlmock.v1" diff --git a/src/inventory/inventory.go b/src/inventory/inventory.go index 731e8e91..517151c2 100644 --- a/src/inventory/inventory.go +++ b/src/inventory/inventory.go @@ -2,8 +2,8 @@ package inventory import ( - "github.com/newrelic/infra-integrations-sdk/integration" - "github.com/newrelic/infra-integrations-sdk/log" + "github.com/newrelic/infra-integrations-sdk/v3/integration" + "github.com/newrelic/infra-integrations-sdk/v3/log" "github.com/newrelic/nri-mssql/src/connection" ) diff --git a/src/inventory/inventory_test.go b/src/inventory/inventory_test.go index 82a4fa12..d472e9ca 100644 --- a/src/inventory/inventory_test.go +++ b/src/inventory/inventory_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/jmoiron/sqlx" - "github.com/newrelic/infra-integrations-sdk/data/inventory" - "github.com/newrelic/infra-integrations-sdk/integration" + "github.com/newrelic/infra-integrations-sdk/v3/data/inventory" + "github.com/newrelic/infra-integrations-sdk/v3/integration" "github.com/newrelic/nri-mssql/src/connection" "gopkg.in/DATA-DOG/go-sqlmock.v1" ) diff --git a/src/metrics/metrics.go b/src/metrics/metrics.go index d32f8ca5..0f9d2134 100644 --- a/src/metrics/metrics.go +++ b/src/metrics/metrics.go @@ -9,10 +9,10 @@ import ( "strconv" "sync" - "github.com/newrelic/infra-integrations-sdk/data/attribute" - "github.com/newrelic/infra-integrations-sdk/data/metric" - "github.com/newrelic/infra-integrations-sdk/integration" - "github.com/newrelic/infra-integrations-sdk/log" + "github.com/newrelic/infra-integrations-sdk/v3/data/attribute" + "github.com/newrelic/infra-integrations-sdk/v3/data/metric" + "github.com/newrelic/infra-integrations-sdk/v3/integration" + "github.com/newrelic/infra-integrations-sdk/v3/log" "github.com/newrelic/nri-mssql/src/args" "github.com/newrelic/nri-mssql/src/connection" "github.com/newrelic/nri-mssql/src/database" diff --git a/src/metrics/metrics_test.go b/src/metrics/metrics_test.go index 32605fd0..83138102 100644 --- a/src/metrics/metrics_test.go +++ b/src/metrics/metrics_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/newrelic/infra-integrations-sdk/data/attribute" - "github.com/newrelic/infra-integrations-sdk/integration" + "github.com/newrelic/infra-integrations-sdk/v3/data/attribute" + "github.com/newrelic/infra-integrations-sdk/v3/integration" "github.com/newrelic/nri-mssql/src/args" "github.com/newrelic/nri-mssql/src/connection" "github.com/newrelic/nri-mssql/src/database" diff --git a/src/mssql.go b/src/mssql.go index 8403c049..a26ba430 100644 --- a/src/mssql.go +++ b/src/mssql.go @@ -7,8 +7,8 @@ import ( "runtime" "strings" - "github.com/newrelic/infra-integrations-sdk/integration" - "github.com/newrelic/infra-integrations-sdk/log" + "github.com/newrelic/infra-integrations-sdk/v3/integration" + "github.com/newrelic/infra-integrations-sdk/v3/log" "github.com/newrelic/nri-mssql/src/args" "github.com/newrelic/nri-mssql/src/connection" "github.com/newrelic/nri-mssql/src/instance" diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index b02ac21f..0bc0a002 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -1,7 +1,7 @@ services: mssql: - image: mcr.microsoft.com/mssql/server:2017-latest + image: mcr.microsoft.com/mssql/server:2022-latest container_name: mssql environment: ACCEPT_EULA: Y @@ -9,7 +9,7 @@ services: MSSQL_PID: Developer restart: always nri-mssql: - image: golang:1.23.1-bookworm + image: golang:1.23.2-bookworm container_name: nri_mssql working_dir: /code volumes: diff --git a/tests/helper.go b/tests/helper.go index bf282312..e20ea188 100644 --- a/tests/helper.go +++ b/tests/helper.go @@ -1,5 +1,4 @@ //go:build integration -// +build integration package tests @@ -11,7 +10,7 @@ import ( "path/filepath" "strings" - "github.com/newrelic/infra-integrations-sdk/log" + "github.com/newrelic/infra-integrations-sdk/v3/log" "github.com/xeipuuv/gojsonschema" ) diff --git a/tests/mssql_test.go b/tests/mssql_test.go index 70173810..5ff5a93d 100644 --- a/tests/mssql_test.go +++ b/tests/mssql_test.go @@ -3,13 +3,15 @@ package tests import ( + "bytes" "flag" "fmt" "os" + "os/exec" "testing" "time" - "github.com/newrelic/infra-integrations-sdk/log" + "github.com/newrelic/infra-integrations-sdk/v3/log" "github.com/newrelic/nri-mssql/src/args" "github.com/newrelic/nri-mssql/src/connection" "github.com/stretchr/testify/assert" @@ -54,6 +56,27 @@ func waitForMSSQLIsUpAndRunning(maxTries int) bool { }) if err != nil { log.Warn(err.Error()) + + mssql_command := []string{"docker", "logs", "mssql"} + mssql_cmd := exec.Command(mssql_command[0], mssql_command[1:]...) + var mssql_out bytes.Buffer + mssql_cmd.Stdout = &mssql_out + mssql_cmd.Stderr = &mssql_out + + nri_mssql_command := []string{"docker", "logs", "nri-mssql"} + nri_mssql_cmd := exec.Command(nri_mssql_command[0], nri_mssql_command[1:]...) + var nri_mssql_out bytes.Buffer + nri_mssql_cmd.Stdout = &nri_mssql_out + nri_mssql_cmd.Stderr = &nri_mssql_out + + log.Info("mssql container logs") + _ = mssql_cmd.Run() + log.Info(mssql_out.String()) + + log.Info("nri_mssql container logs") + _ = nri_mssql_cmd.Run() + log.Info(nri_mssql_out.String()) + continue } if conn != nil { @@ -62,6 +85,7 @@ func waitForMSSQLIsUpAndRunning(maxTries int) bool { return true } } + return false }