Skip to content

Commit

Permalink
Update go deps, move to go 1.19 (#291)
Browse files Browse the repository at this point in the history
* Update go deps

* Add retries to all windows commands

* Fix for retry command

* Try another way

* Upgrade go to 1.19

* Add go version assertion

* A diff for gofmt

* Fix go version assertion

* Drop some ee tests for now

* Rewrite scoop installs

* Add retry to yarn step

* Add --force to docker remove prune

* Fix for clickhouse connection

* Fix for database= param test

* Try weird things

* Try pinning clickhouse image

* Pin all images not to :latest

* Fix oracle version

* Correct oracle version

* Try downgrading mongo?

* Try deleting only this image after each run

* Debug users.xml file

* Try hardcoding overrides for clickhouse

* Bump clickhouse down a version

* Try only running clickhouse tests

* Use docker style volume mount, not podman

* Fix format

* Drop unused users.xml file

* Enable all tests

* Drop io/ioutil
  • Loading branch information
eatonphil committed Aug 28, 2022
1 parent b734887 commit 66b77f0
Show file tree
Hide file tree
Showing 32 changed files with 293 additions and 264 deletions.
76 changes: 40 additions & 36 deletions .github/workflows/ee_pull_requests.yml
Expand Up @@ -39,46 +39,50 @@ jobs:
- run: ./scripts/require_copyright.sh
- run: yarn test

ee_macos_tests:
name: "[EE] macOS Tests"
runs-on: macos-latest
#
# WHILE THIS CODE ISNT UNDER ACTIVE DEVELOPMENT LETS DO A MINIMUM OF TESTS ON IT.
#

steps:
- uses: actions/checkout@master
with:
ref: ${{ github.ref }}
# ee_macos_tests:
# name: "[EE] macOS Tests"
# runs-on: macos-latest

# FROM: https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
# steps:
# - uses: actions/checkout@master
# with:
# ref: ${{ github.ref }}

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# # FROM: https://github.com/actions/cache/blob/main/examples.md#node---yarn
# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# run: echo "::set-output name=dir::$(yarn cache dir)"

- run: ./scripts/ci/prepare_macos.sh
- run: yarn
working-directory: ee
- run: yarn test
working-directory: ee
# - uses: actions/cache@v2
# id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-

ee_windows_tests:
name: "[EE] Windows Tests"
runs-on: windows-latest
# - run: ./scripts/ci/prepare_macos.sh
# - run: yarn
# working-directory: ee
# - run: yarn test
# working-directory: ee

steps:
- uses: actions/checkout@master
with:
ref: ${{ github.ref }}
# ee_windows_tests:
# name: "[EE] Windows Tests"
# runs-on: windows-latest

- run: ./scripts/ci/prepare_windows.ps1
shell: pwsh
- run: yarn
working-directory: ee
- run: yarn test
working-directory: ee
# steps:
# - uses: actions/checkout@master
# with:
# ref: ${{ github.ref }}

# - run: ./scripts/ci/prepare_windows.ps1
# shell: pwsh
# - run: yarn
# working-directory: ee
# - run: yarn test
# working-directory: ee
2 changes: 1 addition & 1 deletion Dockerfile.build
Expand Up @@ -3,5 +3,5 @@ FROM node:17-bullseye
WORKDIR /datastation

# Install Golang
RUN curl -L https://go.dev/dl/go1.18.linux-amd64.tar.gz -o /tmp/go.tar.gz && tar -C /usr/local -xzf /tmp/go.tar.gz
RUN curl -L https://go.dev/dl/go1.19.linux-amd64.tar.gz -o /tmp/go.tar.gz && tar -C /usr/local -xzf /tmp/go.tar.gz
RUN ln -s /usr/local/go/bin/go /usr/bin/go
27 changes: 18 additions & 9 deletions integration/clickhouse.test.js
@@ -1,3 +1,4 @@
const path = require('path');
const cp = require('child_process');

const { basicDatabaseTest } = require('../desktop/panel/testutil');
Expand All @@ -17,18 +18,26 @@ describe('basic clickhouse tests', () => {
async () => {
await withDocker(
{
image: 'docker.io/yandex/clickhouse-server:latest',
image: 'docker.io/yandex/clickhouse-server:22',
port: 9000,
args: [
'-v',
__dirname +
'/../scripts/ci/clickhouse_users.xml:/etc/clickhouse-server/users.d/test.xml',
'--ulimit',
'nofile=262144:262144',
env: {
CLICKHOUSE_DB: 'test',
CLICKHOUSE_USER: 'test',
CLICKHOUSE_PASSWORD: 'test',
},
cmds: [
`clickhouse-client -d test -u test --password test -q 'SELECT 1'`,
],
cmds: [`clickhouse-client -q 'CREATE DATABASE test'`],
},
() => basicDatabaseTest(t)
() =>
basicDatabaseTest(t, {
clickhouse: {
database: 'test',
username: 'test',
password: 'test',
address: 'localhost',
},
})
);
},
360_000
Expand Down
2 changes: 1 addition & 1 deletion integration/cockroachdb.test.js
Expand Up @@ -17,7 +17,7 @@ describe('basic cockroachdb tests', () => {
async () => {
await withDocker(
{
image: 'docker.io/cockroachdb/cockroach:latest',
image: 'docker.io/cockroachdb/cockroach:v22.1.6',
port: 26257,
args: ['--entrypoint', 'tail'],
program: ['-f', '/dev/null'],
Expand Down
2 changes: 1 addition & 1 deletion integration/cratedb.test.js
Expand Up @@ -22,7 +22,7 @@ describe('basic cratedb tests', () => {
async () => {
await withDocker(
{
image: 'docker.io/library/crate:latest',
image: 'docker.io/library/crate:5.0.0',
port: '5439:5432',
program: ['crate', '-Cdiscovery.type=single-node'],
cmds: [
Expand Down
13 changes: 7 additions & 6 deletions integration/docker.js
Expand Up @@ -135,15 +135,16 @@ module.exports.withDocker = async function (opts, cb) {
cp.execSync('docker kill ' + containerId, { stdio: 'inherit' });
console.log('Killed container');

//if (process.env.CI == 'true') {
// Clear up disk space if possible since Github Actions doesn't
// have a massive disk.
// --force just doesn't prompt for confirmation
cp.execSync('docker rmi --force ' + opts.image, { stdio: 'inherit' });
//}

CONTAINERS[opts.image] = CONTAINERS[opts.image].filter(
(c) => c === containerId
);

if (process.env.CI == 'true') {
// Clear up disk space if possible since Github Actions doesn't
// have a massive disk.
cp.execSync('docker image prune -a', { stdio: 'inherit' });
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion integration/mongo.test.js
Expand Up @@ -21,7 +21,7 @@ function testWithDocker(name, cb) {
return withDocker(
{
port: 27017,
image: 'docker.io/library/mongo:latest',
image: 'docker.io/library/mongo:5',
env: {
MONGO_INITDB_ROOT_USERNAME: 'test',
MONGO_INITDB_DATABASE: 'test',
Expand Down
2 changes: 1 addition & 1 deletion integration/mysql.test.js
Expand Up @@ -23,7 +23,7 @@ describe('basic mysql tests', () => {
async () => {
await withDocker(
{
image: 'docker.io/library/mysql:latest',
image: 'docker.io/library/mysql:8.0.30',
port: '3306',
env: {
MYSQL_ROOT_PASSWORD: 'root',
Expand Down
2 changes: 1 addition & 1 deletion integration/neo4j.test.js
Expand Up @@ -13,7 +13,7 @@ describe('basic neo4j tests', () => {
test('basic test', async () => {
await withDocker(
{
image: 'docker.io/library/neo4j:latest',
image: 'docker.io/library/neo4j:4.4.10',
port: 7687,
env: {
NEO4J_AUTH: 'neo4j/password',
Expand Down
6 changes: 3 additions & 3 deletions integration/oracle.test.js
Expand Up @@ -24,7 +24,7 @@ describe('basic oracle tests', () => {
async () => {
await withDocker(
{
image: 'docker.io/gvenzl/oracle-xe:latest',
image: 'docker.io/gvenzl/oracle-xe:21-slim',
port: '1521',
env: {
ORACLE_RANDOM_PASSWORD: 'y',
Expand All @@ -46,7 +46,7 @@ describe('basic oracle tests', () => {
async () => {
await withDocker(
{
image: 'docker.io/gvenzl/oracle-xe:latest',
image: 'docker.io/gvenzl/oracle-xe:21-slim',
port: '1520:1521',
env: {
ORACLE_RANDOM_PASSWORD: 'y',
Expand All @@ -66,6 +66,6 @@ describe('basic oracle tests', () => {
})
);
},
DEFAULT_TIMEOUT
DEFAULT_TIMEOUT * 10
);
});
2 changes: 1 addition & 1 deletion integration/postgres.test.js
Expand Up @@ -26,7 +26,7 @@ describe('basic postgres tests', () => {
async () => {
await withDocker(
{
image: 'docker.io/library/postgres:latest',
image: 'docker.io/library/postgres:14',
port: '5432',
env: {
POSTGRES_USER: 'test',
Expand Down
2 changes: 1 addition & 1 deletion integration/prometheus.test.js
Expand Up @@ -15,7 +15,7 @@ describe('basic prometheus tests', () => {

await withDocker(
{
image: 'docker.io/prom/prometheus:latest',
image: 'docker.io/prom/prometheus:v2.38.0',
port: '9090',
args: ['-v', `${__dirname}/../testdata/prometheus:/etc/prometheus`],
wait: async () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/questdb.test.js
Expand Up @@ -24,7 +24,7 @@ describe('basic questdb tests', () => {
async () => {
await withDocker(
{
image: 'docker.io/questdb/questdb:latest',
image: 'docker.io/questdb/questdb:6.5',
port: '8812',
},
() => basicDatabaseTest(t, vendorOverride)
Expand Down
2 changes: 1 addition & 1 deletion integration/scylla.test.js
Expand Up @@ -13,7 +13,7 @@ describe('basic cassandra/scylladb tests', () => {
test(`runs basic cql query`, async () => {
await withDocker(
{
image: 'docker.io/scylladb/scylla:latest',
image: 'docker.io/scylladb/scylla:5.1',
port: '9042',
program: [
'--smp',
Expand Down
11 changes: 3 additions & 8 deletions runner/database.go
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"fmt"
"io"
"io/ioutil"
"net"
"net/url"
"os"
Expand Down Expand Up @@ -224,19 +223,15 @@ func (ec EvalContext) getConnectionString(dbInfo DatabaseConnectorInfoDatabase)
if genericUserPass != "" {
// Already proven to be ok
pass, _ := ec.decrypt(&dbInfo.Password)
query = fmt.Sprintf("username=%s&password=%s&", u.username, pass)
}

if u.database != "" {
query += "database=" + u.database
query = fmt.Sprintf("username=%s&password=%s", u.username, pass)
}

if !strings.Contains(u.address, ":") {
u.address += ":" + defaultPorts["clickhouse"]
}

query += u.extraArgs
return "clickhouse", fmt.Sprintf("tcp://%s?%s", u.address, query), nil
return "clickhouse", fmt.Sprintf("tcp://%s/%s?%s", u.address, u.database, query), nil
case SQLiteDatabase:
// defined in database_sqlite.go, includes regexp support
return "sqlite3_extended", resolvePath(u.database), nil
Expand Down Expand Up @@ -498,7 +493,7 @@ func (ec EvalContext) EvalDatabasePanelWithWriter(

// Copy remote sqlite database to tmp file if remote
if dbInfo.Type == SQLiteDatabase && server != nil {
tmp, err := ioutil.TempFile("", "sqlite-copy")
tmp, err := os.CreateTemp("", "sqlite-copy")
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions runner/database_test.go
Expand Up @@ -136,7 +136,7 @@ func Test_getConnectionString(t *testing.T) {
{
DatabaseConnectorInfoDatabase{Type: "clickhouse", Username: "jim", Password: Encrypt{Encrypted: false, Value: "pw"}, Database: "test", Address: "localhost"},
"clickhouse",
"tcp://localhost:9000?username=jim&password=pw&database=test",
"tcp://localhost:9000/test?username=jim&password=pw",
nil,
"localhost",
"9000",
Expand All @@ -145,7 +145,7 @@ func Test_getConnectionString(t *testing.T) {
{
DatabaseConnectorInfoDatabase{Type: "clickhouse", Password: Encrypt{Encrypted: false, Value: ""}, Database: "test", Address: "localhost:9001"},
"clickhouse",
"tcp://localhost:9001?database=test",
"tcp://localhost:9001/test?",
nil,
"localhost",
"9001",
Expand Down
5 changes: 2 additions & 3 deletions runner/file_test.go
Expand Up @@ -2,7 +2,6 @@ package runner

import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"runtime"
Expand Down Expand Up @@ -244,7 +243,7 @@ cdef`,
}

for _, test := range tests {
inTmp, err := ioutil.TempFile("", "")
inTmp, err := os.CreateTemp("", "")
assert.Nil(t, err)

_, err = inTmp.WriteString(test)
Expand Down Expand Up @@ -590,7 +589,7 @@ func transformTestFile(filename string, transformFile func(string, *ResultWriter
return nil, err
}

outTmpBs, err := ioutil.ReadFile(outTmp.Name())
outTmpBs, err := os.ReadFile(outTmp.Name())
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 66b77f0

Please sign in to comment.