Skip to content

Commit

Permalink
Merge pull request #224 from MathieuBordere/go-1.19
Browse files Browse the repository at this point in the history
Add go 1.19
  • Loading branch information
Mathieu Borderé authored Mar 7, 2023
2 parents 78005e6 + 5fc49f0 commit 7d04094
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 41 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ jobs:
- 1.14.x
- 1.15.x
- 1.16.x
- 1.17.x
- 1.18.x
- 1.19.x
os:
- ubuntu-18.04
- ubuntu-20.04
- ubuntu-22.04
disk:
- 1
- 0
Expand All @@ -34,27 +37,26 @@ jobs:
sudo add-apt-repository ppa:dqlite/dev -y
sudo apt update
sudo apt install -y golint libsqlite3-dev libuv1-dev liblz4-dev libraft-dev libdqlite-dev
go get github.com/tsenart/deadcode
go get github.com/go-playground/overalls
- name: Build & Test
env:
CGO_LDFLAGS_ALLOW: "-Wl,-z,now"
run: |
go version
go get -t -tags libsqlite3 ./...
go vet -tags libsqlite3 ./...
golint
deadcode
export GO_DQLITE_MULTITHREAD=1
overalls -project ${{ github.workspace }} -covermode=count -- -tags libsqlite3 -timeout 240s
go test -v -coverprofile=coverage.out ./...
VERBOSE=1 DISK=${{ matrix.disk }} ./test/dqlite-demo.sh
VERBOSE=1 DISK=${{ matrix.disk }} ./test/roles.sh
VERBOSE=1 DISK=${{ matrix.disk }} ./test/recover.sh
- name: Coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: overalls.coverprofile
path-to-profile: coverage.out

- name: Benchmark
env:
Expand Down
3 changes: 1 addition & 2 deletions app/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func Example() {
}

fmt.Printf("0x%x %s\n", node.ID(), node.Address())
// Output: 0x2dc171858c3155be 127.0.0.1:9001

if err := node.Close(); err != nil {
return
Expand Down Expand Up @@ -92,7 +91,7 @@ func ExampleWithCluster() {
}

fmt.Println(node1.ID() != node2.ID(), node1.ID() != node3.ID(), node2.ID() != node3.ID())
// Output: true true true
// true true true

// Restart the third node, the only argument we need to pass to
// app.New() is its dir.
Expand Down
30 changes: 13 additions & 17 deletions app/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"

"github.com/canonical/go-dqlite/internal/protocol"
)

// SimpleTLSConfig returns a pair of TLS configuration objects with sane
Expand Down Expand Up @@ -60,17 +58,15 @@ func SimpleTLSConfig(cert tls.Certificate, pool *x509.CertPool) (*tls.Config, *t
//
// The returned config can be used as "listen" parameter for the WithTLS
// option.
//
// A user can modify the returned config to suit their specifig needs.
func SimpleListenTLSConfig(cert tls.Certificate, pool *x509.CertPool) *tls.Config {
// See https://github.com/denji/golang-tls
config := &tls.Config{
MinVersion: tls.VersionTLS12,
CipherSuites: protocol.TLSCipherSuites,
PreferServerCipherSuites: true,
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
Certificates: []tls.Certificate{cert},
RootCAs: pool,
ClientCAs: pool,
ClientAuth: tls.RequireAndVerifyClientCert,
MinVersion: tls.VersionTLS12,
Certificates: []tls.Certificate{cert},
RootCAs: pool,
ClientCAs: pool,
ClientAuth: tls.RequireAndVerifyClientCert,
}
config.BuildNameToCertificate()

Expand All @@ -96,14 +92,14 @@ func SimpleListenTLSConfig(cert tls.Certificate, pool *x509.CertPool) *tls.Confi
// TLS connections using the same `Config` will share a ClientSessionCache.
// You can override this behaviour by setting your own ClientSessionCache or
// nil.
//
// A user can modify the returned config to suit their specifig needs.
func SimpleDialTLSConfig(cert tls.Certificate, pool *x509.CertPool) *tls.Config {
config := &tls.Config{
MinVersion: tls.VersionTLS12,
CipherSuites: protocol.TLSCipherSuites,
PreferServerCipherSuites: true,
RootCAs: pool,
Certificates: []tls.Certificate{cert},
ClientSessionCache: tls.NewLRUClientSessionCache(256),
MinVersion: tls.VersionTLS12,
RootCAs: pool,
Certificates: []tls.Certificate{cert},
ClientSessionCache: tls.NewLRUClientSessionCache(256),
}

x509cert, err := x509.ParseCertificate(cert.Certificate[0])
Expand Down
2 changes: 1 addition & 1 deletion cmd/dqlite-benchmark/dqlite-benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const (
)

func signalChannel() chan os.Signal {
ch := make(chan os.Signal)
ch := make(chan os.Signal, 32)
signal.Notify(ch, unix.SIGPWR)
signal.Notify(ch, unix.SIGINT)
signal.Notify(ch, unix.SIGQUIT)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dqlite-demo/dqlite-demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Complete documentation is available at https://github.com/canonical/go-dqlite`,

go http.Serve(listener, nil)

ch := make(chan os.Signal)
ch := make(chan os.Signal, 32)
signal.Notify(ch, unix.SIGPWR)
signal.Notify(ch, unix.SIGINT)
signal.Notify(ch, unix.SIGQUIT)
Expand Down
4 changes: 2 additions & 2 deletions driver/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestIntegration_ExecBindError(t *testing.T) {
require.NoError(t, err)

_, err = db.ExecContext(ctx, "INSERT INTO test(n) VALUES(1)", 1)
assert.EqualError(t, err, "column index out of range")
assert.EqualError(t, err, "bind parameters")
}

func TestIntegration_QueryBindError(t *testing.T) {
Expand All @@ -123,7 +123,7 @@ func TestIntegration_QueryBindError(t *testing.T) {
defer cancel()

_, err := db.QueryContext(ctx, "SELECT 1", 1)
assert.EqualError(t, err, "column index out of range")
assert.EqualError(t, err, "bind parameters")
}

func TestIntegration_ConfigMultiThread(t *testing.T) {
Expand Down
13 changes: 0 additions & 13 deletions internal/protocol/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package protocol

import (
"context"
"crypto/tls"
"net"
"strings"
)
Expand All @@ -16,15 +15,3 @@ func Dial(ctx context.Context, address string) (net.Conn, error) {
dialer := net.Dialer{}
return dialer.DialContext(ctx, family, address)
}

// TLSCipherSuites are the cipher suites by the go-dqlite TLS helpers.
var TLSCipherSuites = []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
}

0 comments on commit 7d04094

Please sign in to comment.