Skip to content

Commit bb305f4

Browse files
authored
Merge pull request #116 from cockroachdb/ssl
Run against secure servers
2 parents 77de34a + b5f5165 commit bb305f4

File tree

10 files changed

+112
-42
lines changed

10 files changed

+112
-42
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/cockroachdb/examples-orms
33
go 1.13
44

55
require (
6-
github.com/cockroachdb/cockroach-go/v2 v2.0.5
6+
github.com/cockroachdb/cockroach-go/v2 v2.0.6
77
github.com/denisenkom/go-mssqldb v0.0.0-20200620013148-b91950f658ec // indirect
88
github.com/go-pg/pg/v9 v9.1.6
99
github.com/go-sql-driver/mysql v1.5.0 // indirect

go.sum

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
2-
github.com/cockroachdb/cockroach-go/v2 v2.0.5 h1:kG3i3YDEcg8Sby8PzUu3Wvp67Ienevj4bRAnHDF/xNc=
3-
github.com/cockroachdb/cockroach-go/v2 v2.0.5/go.mod h1:hAuDgiVgDVkfirP9JnhXEfcXEPRKBpYdGz+l7mvYSzw=
2+
github.com/cockroachdb/cockroach-go/v2 v2.0.6 h1:7JKIGouLq/hP+rxHIZ1emZ0J3AXPt8DE7yU/xw8JZPc=
3+
github.com/cockroachdb/cockroach-go/v2 v2.0.6/go.mod h1:nkf7rUmgPdawp3EwRjXIumihI2AYg9usGNWbJ2hsJqI=
44
github.com/codemodus/kace v0.5.1 h1:4OCsBlE2c/rSJo375ggfnucv9eRzge/U5LrrOZd47HA=
55
github.com/codemodus/kace v0.5.1/go.mod h1:coddaHoX1ku1YFSe4Ip0mL9kQjJvKkzb9CfIdG1YR04=
66
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
@@ -13,8 +13,8 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200620013148-b91950f658ec h1:NfhRXXFDP
1313
github.com/denisenkom/go-mssqldb v0.0.0-20200620013148-b91950f658ec/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
1414
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
1515
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
16+
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
1617
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
17-
github.com/go-pg/pg v8.0.7+incompatible h1:ty/sXL1OZLo+47KK9N8llRcmbA9tZasqbQ/OO4ld53g=
1818
github.com/go-pg/pg/v9 v9.0.0-beta.14/go.mod h1:T2Sr6bpTCOr2lUqOUMiXLMJqZHSUBKk1LdgSqjwhZfA=
1919
github.com/go-pg/pg/v9 v9.0.3/go.mod h1:Tm/Q3Vt6gdQOH6TTN1H/xLlIXc+Qrka7TZ6uREtu/eA=
2020
github.com/go-pg/pg/v9 v9.1.6 h1:IqBayenvp9EWjHncRE7//SRmQuktq60oeO1/MkEx3dY=
@@ -36,7 +36,9 @@ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2V
3636
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
3737
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
3838
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
39+
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
3940
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
41+
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
4042
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
4143
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
4244
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
@@ -79,9 +81,11 @@ github.com/julienschmidt/httprouter v1.1.0 h1:7wLdtIiIpzOkC9u6sXOozpBauPdskj3ru4
7981
github.com/julienschmidt/httprouter v1.1.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
8082
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
8183
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
84+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
8285
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
8386
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
8487
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
88+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
8589
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
8690
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
8791
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
@@ -99,7 +103,9 @@ github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOq
99103
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
100104
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
101105
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
106+
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
102107
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
108+
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
103109
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
104110
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
105111
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -160,6 +166,7 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL
160166
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
161167
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
162168
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
169+
golang.org/x/net v0.0.0-20200222033325-078779b8f2d8 h1:4l6HGmcZuPkox4Zl1b7SZQfYo8KIKvPe+5VG6ibuUEg=
163170
golang.org/x/net v0.0.0-20200222033325-078779b8f2d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
164171
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
165172
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -173,8 +180,10 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
173180
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
174181
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
175182
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
183+
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
176184
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
177185
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
186+
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
178187
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
179188
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
180189
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
@@ -184,16 +193,21 @@ golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8T
184193
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
185194
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
186195
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
196+
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
187197
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
188198
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
189199
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
200+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
190201
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
202+
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
191203
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
192204
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
205+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
193206
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
194207
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
195208
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
196209
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
210+
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
197211
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
198212
mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
199213
mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=

go/gopg/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func main() {
3333
func setupDB(addr string) *pg.DB {
3434
opt, err := pg.ParseURL(addr)
3535
if err != nil {
36-
panic(fmt.Sprintf("failed to parse addr URL: %v", err))
36+
panic(fmt.Sprintf("failed to parse addr URL %s: %v", addr, err))
3737
}
3838
db := pg.Connect(opt)
3939
for _, model := range []interface{}{
1.39 KB
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Tue Jan 31 17:56:55 EST 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip

java/hibernate/gradlew

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
3333
# Use the maximum available, or set MAX_FD != -1 to use that value.
3434
MAX_FD="maximum"
3535

36-
warn ( ) {
36+
warn () {
3737
echo "$*"
3838
}
3939

40-
die ( ) {
40+
die () {
4141
echo
4242
echo "$*"
4343
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
155155
fi
156156

157157
# Escape application args
158-
save ( ) {
158+
save () {
159159
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160160
echo " "
161161
}

ruby/activerecord/db/schema.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,29 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 20170207160810) do
13+
ActiveRecord::Schema.define(version: 2017_02_07_160810) do
1414

15-
create_table "customers", id: :bigint, default: -> { "unique_rowid()" }, force: :cascade do |t|
16-
t.text "name", null: false
15+
create_table "customers", force: :cascade do |t|
16+
t.string "name", null: false
1717
end
1818

1919
create_table "order_products", id: false, force: :cascade do |t|
2020
t.bigint "order_id", null: false
2121
t.bigint "product_id", null: false
22+
t.bigserial "rowid", null: false
2223
t.index ["order_id"], name: "index_order_products_on_order_id"
2324
t.index ["product_id"], name: "index_order_products_on_product_id"
2425
end
2526

26-
create_table "orders", id: :bigint, default: -> { "unique_rowid()" }, force: :cascade do |t|
27-
t.decimal "subtotal", null: false
27+
create_table "orders", force: :cascade do |t|
28+
t.decimal "subtotal", precision: 18, scale: 2, default: "0.0", null: false
2829
t.bigint "customer_id", null: false
2930
t.index ["customer_id"], name: "index_orders_on_customer_id"
3031
end
3132

32-
create_table "products", id: :bigint, default: -> { "unique_rowid()" }, force: :cascade do |t|
33-
t.text "name", null: false
34-
t.decimal "price", null: false
33+
create_table "products", force: :cascade do |t|
34+
t.string "name", null: false
35+
t.decimal "price", precision: 18, scale: 2, null: false
3536
end
3637

3738
add_foreign_key "order_products", "orders"

ruby/ar4/db/schema.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ActiveRecord::Schema.define(version: 20170207160810) do
1515

1616
create_table "customers", id: :bigserial, force: :cascade do |t|
17-
t.text "name", null: false
17+
t.string "name", null: false
1818
end
1919

2020
# Could not dump table "order_products" because of following ArgumentError
@@ -24,8 +24,8 @@
2424
# struct size differs
2525

2626
create_table "products", id: :bigserial, force: :cascade do |t|
27-
t.text "name", null: false
28-
t.decimal "price", null: false
27+
t.string "name", null: false
28+
t.decimal "price", precision: 18, scale: 2, null: false
2929
end
3030

3131
add_foreign_key "order_products", "orders"

testing/main_test.go

Lines changed: 73 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,19 @@ var customURLSchemes = map[application]string{
4343
}
4444

4545
type tenantServer interface {
46-
NewTenantServer() (testserver.TestServer, error)
46+
NewTenantServer(proxy bool) (testserver.TestServer, error)
4747
}
4848

4949
// newServer creates a new cockroachDB server.
50-
func newServer(t *testing.T) testserver.TestServer {
50+
func newServer(t *testing.T, insecure bool) testserver.TestServer {
5151
t.Helper()
52-
ts, err := testserver.NewTestServer()
52+
var ts testserver.TestServer
53+
var err error
54+
if insecure {
55+
ts, err = testserver.NewTestServer()
56+
} else {
57+
ts, err = testserver.NewTestServer(testserver.SecureOpt())
58+
}
5359
if err != nil {
5460
t.Fatal(err)
5561
}
@@ -60,7 +66,7 @@ func newServer(t *testing.T) testserver.TestServer {
6066
// TestServer.NewTenantServer for more information.
6167
func newTenant(t *testing.T, ts testserver.TestServer) testserver.TestServer {
6268
t.Helper()
63-
tenant, err := ts.(tenantServer).NewTenantServer()
69+
tenant, err := ts.(tenantServer).NewTenantServer(false /* proxy */)
6470
if err != nil {
6571
t.Fatal(err)
6672
}
@@ -192,12 +198,26 @@ var minRequiredVersionsByORMName = map[string]struct {
192198
// tenants.
193199
var minTenantVersion = version.MustParse("v20.2.0-alpha")
194200

195-
func testORM(
196-
t *testing.T, language, orm string, tableNames testTableNames, columnNames testColumnNames,
197-
) {
201+
type testInfo struct {
202+
language, orm string
203+
tableNames testTableNames // defaults to defaultTestTableNames
204+
columnNames testColumnNames // defaults to defaultTestColumnNames
205+
// insecure is set if ORM does not handle secure servers (client certs).
206+
// In that case, we start an insecure server (and don't test in tenant
207+
// mode).
208+
insecure bool
209+
}
210+
211+
func testORM(t *testing.T, info testInfo) {
212+
if info.tableNames == (testTableNames{}) {
213+
info.tableNames = defaultTestTableNames
214+
}
215+
if info.columnNames.IsEmpty() {
216+
info.columnNames = defaultTestColumnNames
217+
}
198218
app := application{
199-
language: language,
200-
orm: orm,
219+
language: info.language,
220+
orm: info.orm,
201221
}
202222

203223
type testCase struct {
@@ -207,13 +227,13 @@ func testORM(
207227
}
208228
var testCases []testCase
209229
{
210-
ts := newServer(t)
230+
ts := newServer(t, info.insecure)
211231
db, dbURL, stopDB := startServerWithApplication(t, ts, app)
212232
defer stopDB()
213233

214234
crdbVersion := getVersionFromDB(t, db)
215235
// Check that this ORM can be run with the given cockroach version.
216-
if info, ok := minRequiredVersionsByORMName[orm]; ok {
236+
if info, ok := minRequiredVersionsByORMName[info.orm]; ok {
217237
if !crdbVersion.AtLeast(info.v) {
218238
t.Skip(info.skipMsg)
219239
}
@@ -248,8 +268,8 @@ func testORM(
248268
td := testDriver{
249269
db: tc.db,
250270
dbName: app.dbName(),
251-
tableNames: tableNames,
252-
columnNames: columnNames,
271+
tableNames: info.tableNames,
272+
columnNames: info.columnNames,
253273
}
254274

255275
t.Run("FirstRun", func(t *testing.T) {
@@ -331,33 +351,65 @@ func testORM(
331351
}
332352

333353
func TestGORM(t *testing.T) {
334-
testORM(t, "go", "gorm", defaultTestTableNames, defaultTestColumnNames)
354+
testORM(t, testInfo{language: "go", orm: "gorm"})
335355
}
336356

337357
func TestGOPG(t *testing.T) {
338-
testORM(t, "go", "gopg", defaultTestTableNames, defaultTestColumnNames)
358+
testORM(t, testInfo{
359+
language: "go",
360+
orm: "gopg",
361+
// GoPG does not support client certs:
362+
// https://github.com/go-pg/pg/blob/v10/options.go
363+
// If we set up a secure deployment and went through the proxy, it would work (or should anyway), but only
364+
// via the 'database' parameter; GoPG also does not support the 'options' parameter.
365+
insecure: true,
366+
})
339367
}
340368

341369
func TestHibernate(t *testing.T) {
342-
testORM(t, "java", "hibernate", defaultTestTableNames, defaultTestColumnNames)
370+
testORM(t, testInfo{
371+
language: "java",
372+
orm: "hibernate",
373+
// Possibly does not unescape the path correctly:
374+
// Caused by: java.io.FileNotFoundException:
375+
// %2Ftmp%2Fcockroach-testserver913095208%2Fcerts%2Fca.crt (No such file or directory)
376+
insecure: true,
377+
})
343378
}
344379

345380
func TestSequelize(t *testing.T) {
346-
testORM(t, "node", "sequelize", defaultTestTableNames, defaultTestColumnNames)
381+
testORM(t, testInfo{
382+
language: "node",
383+
orm: "sequelize",
384+
// Requires bespoke code to actually use SSL, see:
385+
// https://github.com/sequelize/sequelize/issues/10015
386+
insecure: true,
387+
})
347388
}
348389

349390
func TestSQLAlchemy(t *testing.T) {
350-
testORM(t, "python", "sqlalchemy", defaultTestTableNames, defaultTestColumnNames)
391+
testORM(t, testInfo{
392+
language: "python",
393+
orm: "sqlalchemy",
394+
})
351395
}
352396

353397
func TestDjango(t *testing.T) {
354-
testORM(t, "python", "django", djangoTestTableNames, djangoTestColumnNames)
398+
testORM(t, testInfo{
399+
language: "python",
400+
orm: "django",
401+
tableNames: djangoTestTableNames,
402+
columnNames: djangoTestColumnNames,
403+
// No support for client certs (at least not via the query string).
404+
// psycopg2.OperationalError: fe_sendauth: no password supplied
405+
insecure: true,
406+
})
355407
}
356408

357409
func TestActiveRecord(t *testing.T) {
358-
testORM(t, "ruby", "activerecord", defaultTestTableNames, defaultTestColumnNames)
410+
testORM(t, testInfo{language: "ruby", orm: "activerecord"})
359411
}
360412

361413
func TestActiveRecord4(t *testing.T) {
362-
testORM(t, "ruby", "ar4", defaultTestTableNames, defaultTestColumnNames)
414+
testORM(t, testInfo{language: "ruby", orm: "ar4"})
363415
}

testing/test_driver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ type testColumnNames struct {
2525
ordersProductsColumns []string
2626
}
2727

28+
func (tcn testColumnNames) IsEmpty() bool {
29+
return len(tcn.customersColumns)+len(tcn.ordersColumns)+len(tcn.productsColumns)+len(tcn.ordersProductsColumns) == 0
30+
}
31+
2832
// These need to be variables so that their address can be taken.
2933
var (
3034
customerName1 = "Billy"

0 commit comments

Comments
 (0)