diff --git a/ci/docker/python-debug.sh b/ci/docker/python-debug.sh index 68f17babe2..a9cdb3a044 100755 --- a/ci/docker/python-debug.sh +++ b/ci/docker/python-debug.sh @@ -31,6 +31,7 @@ cat /adbc/ci/conda_env_cpp.txt /adbc/ci/conda_env_python.txt |\ micromamba install -c conda-forge -y \ -f /tmp/spec.txt \ + binutils \ "conda-forge/label/python_debug::python=${PYTHON}.*" micromamba clean --all -y diff --git a/dev/release/verify-release-candidate.sh b/dev/release/verify-release-candidate.sh index 701e71d6e1..3a33eed0e6 100755 --- a/dev/release/verify-release-candidate.sh +++ b/dev/release/verify-release-candidate.sh @@ -511,7 +511,7 @@ test_cpp() { maybe_setup_conda \ --file ci/conda_env_cpp.txt \ compilers \ - go python || exit 1 + go-cgo python || exit 1 if [ "${USE_CONDA}" -gt 0 ]; then export CMAKE_PREFIX_PATH="${CONDA_BACKUP_CMAKE_PREFIX_PATH}:${CMAKE_PREFIX_PATH}" @@ -661,7 +661,7 @@ test_go() { # apache/arrow-adbc#517: `go build` calls git. Don't assume system # has git; even if it's there, go_build.sh sets DYLD_LIBRARY_PATH # which can interfere with system git. - maybe_setup_conda compilers git go || exit 1 + maybe_setup_conda compilers git go-cgo || exit 1 if [ "${USE_CONDA}" -gt 0 ]; then # The CMake setup forces RPATH to be the Conda prefix diff --git a/go/adbc/driver/flightsql/flightsql_adbc_test.go b/go/adbc/driver/flightsql/flightsql_adbc_test.go index 66019995f7..d7dc28c3f4 100644 --- a/go/adbc/driver/flightsql/flightsql_adbc_test.go +++ b/go/adbc/driver/flightsql/flightsql_adbc_test.go @@ -38,6 +38,7 @@ import ( "os" "path/filepath" "runtime" + "runtime/debug" "slices" "strings" "testing" @@ -45,6 +46,7 @@ import ( "github.com/apache/arrow-adbc/go/adbc" driver "github.com/apache/arrow-adbc/go/adbc/driver/flightsql" + "github.com/apache/arrow-adbc/go/adbc/driver/internal/driverbase" "github.com/apache/arrow-adbc/go/adbc/validation" "github.com/apache/arrow-go/v18/arrow" "github.com/apache/arrow-go/v18/arrow/array" @@ -256,16 +258,37 @@ func (s *FlightSQLQuirks) SupportsStatistics() bool { return func (s *FlightSQLQuirks) SupportsTransactions() bool { return true } func (s *FlightSQLQuirks) SupportsGetParameterSchema() bool { return false } func (s *FlightSQLQuirks) SupportsDynamicParameterBinding() bool { return true } + +func expectedDriverVersions() (string, string) { + driverVersion, arrowVersion := driverbase.UnknownVersion, driverbase.UnknownVersion + if info, ok := debug.ReadBuildInfo(); ok { + for _, setting := range info.Settings { + if setting.Key == "vcs.modified" && setting.Value == "true" { + driverVersion = "-dev" + } + } + for _, dep := range info.Deps { + if strings.HasPrefix(dep.Path, "github.com/apache/arrow-go/") { + if dep.Version != "" { + arrowVersion = dep.Version + } + break + } + } + } + return driverVersion, arrowVersion +} + func (s *FlightSQLQuirks) GetMetadata(code adbc.InfoCode) interface{} { switch code { case adbc.InfoDriverName: return "ADBC Flight SQL Driver - Go" - // runtime/debug.ReadBuildInfo doesn't currently work for tests - // github.com/golang/go/issues/33976 case adbc.InfoDriverVersion: - return "(unknown or development build)" + driverVersion, _ := expectedDriverVersions() + return driverVersion case adbc.InfoDriverArrowVersion: - return "(unknown or development build)" + _, arrowVersion := expectedDriverVersions() + return arrowVersion case adbc.InfoDriverADBCVersion: return adbc.AdbcVersion1_1_0 case adbc.InfoVendorName: @@ -1147,12 +1170,12 @@ func (suite *ConnectionTests) TestGetInfo() { case adbc.InfoDriverVersion: { driverVersion = true - // Can't assert on value here since test won't have debug.ReadBuildInfo + // Version values are checked by TestMetadataGetInfo. } case adbc.InfoDriverArrowVersion: { driverArrowVersion = true - // Can't assert on value here since test won't have debug.ReadBuildInfo + // Version values are checked by TestMetadataGetInfo. } } } diff --git a/go/adbc/driver/internal/driverbase/driver_test.go b/go/adbc/driver/internal/driverbase/driver_test.go index ab8efb4c80..2084cd140c 100644 --- a/go/adbc/driver/internal/driverbase/driver_test.go +++ b/go/adbc/driver/internal/driverbase/driver_test.go @@ -22,6 +22,7 @@ import ( "encoding/json" "fmt" "log/slog" + "runtime/debug" "slices" "strings" "testing" @@ -51,6 +52,26 @@ func NewDriver(alloc memory.Allocator, handler slog.Handler, useHelpers bool) ad return driverbase.NewDriver(&driverImpl{DriverImplBase: driverbase.NewDriverImplBase(info, alloc), handler: handler, useHelpers: useHelpers}) } +func expectedDriverVersions() (string, string) { + driverVersion, arrowVersion := driverbase.UnknownVersion, driverbase.UnknownVersion + if info, ok := debug.ReadBuildInfo(); ok { + for _, setting := range info.Settings { + if setting.Key == "vcs.modified" && setting.Value == "true" { + driverVersion = "-dev" + } + } + for _, dep := range info.Deps { + if strings.HasPrefix(dep.Path, "github.com/apache/arrow-go/") { + if dep.Version != "" { + arrowVersion = dep.Version + } + break + } + } + } + return driverVersion, arrowVersion +} + func TestDefaultDriver(t *testing.T) { var handler MockedHandler handler.On("Handle", mock.Anything, mock.Anything).Return(nil) @@ -94,7 +115,8 @@ func TestDefaultDriver(t *testing.T) { // This is what the driverbase provided GetInfo result should look like out of the box, // with one custom setting registered at initialization - expectedGetInfoTable, err := array.TableFromJSON(alloc, adbc.GetInfoSchema, []string{`[ + driverVersion, arrowVersion := expectedDriverVersions() + expectedGetInfoTable, err := array.TableFromJSON(alloc, adbc.GetInfoSchema, []string{fmt.Sprintf(`[ { "info_name": 0, "info_value": [0, "MockDriver"] @@ -113,11 +135,11 @@ func TestDefaultDriver(t *testing.T) { }, { "info_name": 101, - "info_value": [0, "(unknown or development build)"] + "info_value": [0, %q] }, { "info_name": 102, - "info_value": [0, "(unknown or development build)"] + "info_value": [0, %q] }, { "info_name": 103, @@ -127,7 +149,7 @@ func TestDefaultDriver(t *testing.T) { "info_name": 10001, "info_value": [0, "my custom info"] } - ]`}) + ]`, driverVersion, arrowVersion)}) require.NoError(t, err) defer expectedGetInfoTable.Release() @@ -223,7 +245,8 @@ func TestCustomizedDriver(t *testing.T) { // - the default DriverInfo set at initialization // - the DriverInfo set once in the NewDriver constructor // - the DriverInfo set dynamically when GetInfo is called by implementing DriverInfoPreparer interface - expectedGetInfoTable, err := array.TableFromJSON(alloc, adbc.GetInfoSchema, []string{`[ + driverVersion, arrowVersion := expectedDriverVersions() + expectedGetInfoTable, err := array.TableFromJSON(alloc, adbc.GetInfoSchema, []string{fmt.Sprintf(`[ { "info_name": 0, "info_value": [0, "MockDriver"] @@ -250,11 +273,11 @@ func TestCustomizedDriver(t *testing.T) { }, { "info_name": 101, - "info_value": [0, "(unknown or development build)"] + "info_value": [0, %q] }, { "info_name": 102, - "info_value": [0, "(unknown or development build)"] + "info_value": [0, %q] }, { "info_name": 103, @@ -268,7 +291,7 @@ func TestCustomizedDriver(t *testing.T) { "info_name": 10002, "info_value": [0, "this was fetched dynamically"] } - ]`}) + ]`, driverVersion, arrowVersion)}) require.NoError(t, err) defer expectedGetInfoTable.Release()