Skip to content

Commit 5b174a3

Browse files
SNOW-920995 add CI configuration for regression tests (#1075)
1 parent bcb26f9 commit 5b174a3

19 files changed

+301
-7
lines changed

Jenkinsfile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import groovy.json.JsonOutput
2+
3+
4+
timestamps {
5+
node('regular-memory-node') {
6+
stage('checkout') {
7+
scmInfo = checkout scm
8+
println("${scmInfo}")
9+
env.GIT_BRANCH = scmInfo.GIT_BRANCH
10+
env.GIT_COMMIT = scmInfo.GIT_COMMIT
11+
}
12+
params = [
13+
string(name: 'svn_revision', value: 'main'),
14+
string(name: 'branch', value: 'main'),
15+
string(name: 'client_git_commit', value: scmInfo.GIT_COMMIT),
16+
string(name: 'client_git_branch', value: scmInfo.GIT_BRANCH),
17+
string(name: 'TARGET_DOCKER_TEST_IMAGE', value: 'go-centos7-go1.19'),
18+
string(name: 'parent_job', value: env.JOB_NAME),
19+
string(name: 'parent_build_number', value: env.BUILD_NUMBER)
20+
]
21+
stage('Test') {
22+
build job: 'RT-LanguageGo-PC',parameters: params
23+
}
24+
}
25+
}
26+
27+
28+
pipeline {
29+
agent { label 'regular-memory-node' }
30+
options { timestamps() }
31+
environment {
32+
COMMIT_SHA_LONG = sh(returnStdout: true, script: "echo \$(git rev-parse " + "HEAD)").trim()
33+
34+
// environment variables for semgrep_agent (for findings / analytics page)
35+
// remove .git at the end
36+
// remove SCM URL + .git at the end
37+
38+
BASELINE_BRANCH = "${env.CHANGE_TARGET}"
39+
}
40+
stages {
41+
stage('Checkout') {
42+
steps {
43+
checkout scm
44+
}
45+
}
46+
}
47+
}
48+
49+
def wgetUpdateGithub(String state, String folder, String targetUrl, String seconds) {
50+
def ghURL = "https://api.github.com/repos/snowflakedb/gosnowflake/statuses/$COMMIT_SHA_LONG"
51+
def data = JsonOutput.toJson([state: "${state}", context: "jenkins/${folder}",target_url: "${targetUrl}"])
52+
sh "wget ${ghURL} --spider -q --header='Authorization: token $GIT_PASSWORD' --post-data='${data}'"
53+
}

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test_teardown:
1616
kill -9 $$(ps -ewf | grep hang_webserver | grep -v grep | awk '{print $$2}') || true
1717

1818
test: deps test_setup
19-
./ci/scripts/test_component.sh
19+
./ci/scripts/execute_tests.sh
2020

2121
## Run Coverage tests
2222
cov:

bindings_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import (
77
"context"
88
"database/sql"
99
"fmt"
10+
"log"
1011
"math/big"
1112
"math/rand"
1213
"reflect"
1314
"strconv"
15+
"strings"
1416
"testing"
1517
"time"
1618
)
@@ -983,6 +985,10 @@ func TestFunctionParameters(t *testing.T) {
983985
}
984986

985987
runDBTest(t, func(dbt *DBTest) {
988+
_, err := dbt.exec("ALTER SESSION SET BIND_NULL_VALUE_USE_NULL_DATATYPE=false")
989+
if err != nil {
990+
log.Println(err)
991+
}
986992
for _, tc := range testcases {
987993
t.Run(tc.testDesc, func(t *testing.T) {
988994
query := fmt.Sprintf(`
@@ -1075,6 +1081,10 @@ func TestVariousBindingModes(t *testing.T) {
10751081

10761082
runDBTest(t, func(dbt *DBTest) {
10771083
for _, tc := range testcases {
1084+
// TODO SNOW-1264687
1085+
if strings.Contains(tc.testDesc, "LOB") {
1086+
skipOnJenkins(t, "skipped until SNOW-1264687 is fixed")
1087+
}
10781088
for _, bindingMode := range bindingModes {
10791089
t.Run(tc.testDesc+" "+bindingMode.param, func(t *testing.T) {
10801090
query := fmt.Sprintf(`CREATE OR REPLACE TABLE BINDING_MODES(param1 %v)`, tc.paramType)
@@ -1142,18 +1152,26 @@ func testLOBRetrieval(t *testing.T, useArrowFormat bool) {
11421152
}
11431153

11441154
func TestInsertLobDataWithLiteralArrow(t *testing.T) {
1155+
// TODO SNOW-1264687
1156+
skipOnJenkins(t, "skipped until SNOW-1264687 is fixed")
11451157
testInsertLOBData(t, true, true)
11461158
}
11471159

11481160
func TestInsertLobDataWithLiteralJSON(t *testing.T) {
1161+
// TODO SNOW-1264687
1162+
skipOnJenkins(t, "skipped until SNOW-1264687 is fixed")
11491163
testInsertLOBData(t, false, true)
11501164
}
11511165

11521166
func TestInsertLobDataWithBindingsArrow(t *testing.T) {
1167+
// TODO SNOW-1264687
1168+
skipOnJenkins(t, "skipped until SNOW-1264687 is fixed")
11531169
testInsertLOBData(t, true, false)
11541170
}
11551171

11561172
func TestInsertLobDataWithBindingsJSON(t *testing.T) {
1173+
// TODO SNOW-1264687
1174+
skipOnJenkins(t, "skipped until SNOW-1264687 is fixed")
11571175
testInsertLOBData(t, false, false)
11581176
}
11591177

ci/_init.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash -e
2+
3+
export PLATFORM=$(echo $(uname) | tr '[:upper:]' '[:lower:]')
4+
# Use the internal Docker Registry
5+
export INTERNAL_REPO=nexus.int.snowflakecomputing.com:8086
6+
export DOCKER_REGISTRY_NAME=$INTERNAL_REPO/docker
7+
export WORKSPACE=${WORKSPACE:-/tmp}
8+
9+
export DRIVER_NAME=go
10+
11+
TEST_IMAGE_VERSION=1
12+
declare -A TEST_IMAGE_NAMES=(
13+
[$DRIVER_NAME-centos7-go1.19]=$DOCKER_REGISTRY_NAME/client-$DRIVER_NAME-centos7-go1.19-test:$TEST_IMAGE_VERSION
14+
)
15+
export TEST_IMAGE_NAMES

ci/container/test_component.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
CI_SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
TOPDIR=$(cd $CI_SCRIPTS_DIR/../.. && pwd)
8+
9+
cd $TOPDIR
10+
cp parameters.json.local parameters.json
11+
make test
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM centos:7
2+
3+
# update OS and install basic tools
4+
RUN yum -y update && \
5+
yum -y install epel-release && \
6+
yum -y install centos-release-scl && \
7+
yum -y install git && \
8+
yum -y install which && \
9+
yum -y install zstd && \
10+
yum -y install jq
11+
12+
# gosu
13+
RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.11/gosu-amd64"
14+
RUN chmod +x /usr/local/bin/gosu
15+
16+
# Install build tools
17+
RUN yum -y groupinstall 'Development Tools'
18+
RUN yum -y install centos-release-scl
19+
RUN yum -y install devtoolset-8-gcc*
20+
SHELL [ "/usr/bin/scl", "enable", "devtoolset-8"]
21+
22+
# python
23+
RUN yum -y install python36
24+
RUN python3 -V
25+
26+
# install Go
27+
RUN curl -O -L https://go.dev/dl/go1.19.13.linux-amd64.tar.gz && \
28+
tar -C /usr/local -xzf go1.19.13.linux-amd64.tar.gz
29+
ENV GOROOT /usr/local/go
30+
ENV GOPATH=/tmp/go
31+
ENV GOCACHE=/tmp/cache
32+
ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin
33+
ENV CGO_ENABLED=1
34+
35+
# workspace
36+
RUN mkdir -p /home/user && \
37+
chmod 777 /home/user
38+
WORKDIR /home/user
39+
40+
# entry point
41+
COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
42+
RUN chmod +x /usr/local/bin/entrypoint.sh
43+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

ci/image/build.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash -e
2+
#
3+
# Build Docker images
4+
#
5+
set -o pipefail
6+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
source $THIS_DIR/../_init.sh
8+
9+
for name in "${!TEST_IMAGE_NAMES[@]}"; do
10+
docker build \
11+
--platform linux/amd64 \
12+
--file $THIS_DIR/Dockerfile.$name-test \
13+
--label snowflake \
14+
--label $DRIVER_NAME \
15+
--tag ${TEST_IMAGE_NAMES[$name]} .
16+
done

ci/image/scripts/entrypoint.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash -x
2+
# Add local user
3+
# Either use the LOCAL_USER_ID if passed in at runtime or
4+
# fallback
5+
6+
USER_ID=${LOCAL_USER_ID:-9001}
7+
8+
echo "Starting with UID : $USER_ID"
9+
useradd --shell /bin/bash -u $USER_ID -o -c "" -m user
10+
export HOME=/home/user
11+
12+
exec /usr/local/bin/gosu user "$@"

ci/image/update.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash -e
2+
#
3+
# Build Docker images
4+
#
5+
set -o pipefail
6+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
source $THIS_DIR/../_init.sh
8+
9+
source $THIS_DIR/../scripts/login_internal_docker.sh
10+
11+
for image in $(docker images --format "{{.ID}},{{.Repository}}:{{.Tag}}" | grep "nexus.int.snowflakecomputing.com" | grep "client-$DRIVER_NAME"); do
12+
target_id=$(echo $image | awk -F, '{print $1}')
13+
target_name=$(echo $image | awk -F, '{print $2}')
14+
for name in "${!TEST_IMAGE_NAMES[@]}"; do
15+
if [[ "$target_name" == "${TEST_IMAGE_NAMES[$name]}" ]]; then
16+
echo $name
17+
docker_hub_image_name=$(echo ${TEST_IMAGE_NAMES[$name]/$DOCKER_REGISTRY_NAME/snowflakedb})
18+
set -x
19+
docker tag $target_id $docker_hub_image_name
20+
set +x
21+
docker push "${TEST_IMAGE_NAMES[$name]}"
22+
fi
23+
done
24+
done

ci/scripts/test_component.sh ci/scripts/execute_tests.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ if [[ -n "$GITHUB_WORKFLOW" ]]; then
1212
fi
1313
env | grep SNOWFLAKE | grep -v PASS | sort
1414
cd $TOPDIR
15-
go test -timeout 50m -race -coverprofile=coverage.txt -covermode=atomic -v .
15+
if [[ -n "$JENKINS_HOME" ]]; then
16+
export WORKSPACE=${WORKSPACE:-/mnt/workspace}
17+
go install github.com/jstemmer/go-junit-report/v2@latest
18+
go test -timeout 50m -race -v . | go-junit-report -iocopy -out $WORKSPACE/junit-go.xml
19+
else
20+
go test -timeout 50m -race -coverprofile=coverage.txt -covermode=atomic -v .
21+
fi

ci/scripts/login_internal_docker.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash -e
2+
#
3+
# Login the Internal Docker Registry
4+
#
5+
if [[ -z "$GITHUB_ACTIONS" ]]; then
6+
echo "[INFO] Login the internal Docker Resistry"
7+
NEXUS_USER=${USERNAME:-jenkins}
8+
if [[ -z "$NEXUS_PASSWORD" ]]; then
9+
echo "[ERROR] Set NEXUS_PASSWORD to your LDAP password to access the internal repository!"
10+
exit 1
11+
fi
12+
if ! docker login --username "$NEXUS_USER" --password "$NEXUS_PASSWORD" $INTERNAL_REPO; then
13+
echo "[ERROR] Failed to connect to the nexus server. Verify the environment variable NEXUS_PASSWORD is set correctly for NEXUS_USER: $NEXUS_USER"
14+
exit 1
15+
fi
16+
else
17+
echo "[INFO] No login the internal Docker Registry"
18+
fi
File renamed without changes.

ci/test.sh

+58-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,61 @@ set -e
66
set -o pipefail
77

88
CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
9-
source $CI_DIR/scripts/setup.sh
10-
cd $CI_DIR/..
11-
make test
9+
10+
if [[ -n "$JENKINS_HOME" ]]; then
11+
ROOT_DIR="$(cd "${CI_DIR}/.." && pwd)"
12+
export WORKSPACE=${WORKSPACE:-/tmp}
13+
14+
source $CI_DIR/_init.sh
15+
source $CI_DIR/scripts/login_internal_docker.sh
16+
17+
echo "Use /sbin/ip"
18+
IP_ADDR=$(/sbin/ip -4 addr show scope global dev eth0 | grep inet | awk '{print $2}' | cut -d / -f 1)
19+
20+
declare -A TARGET_TEST_IMAGES
21+
if [[ -n "$TARGET_DOCKER_TEST_IMAGE" ]]; then
22+
echo "[INFO] TARGET_DOCKER_TEST_IMAGE: $TARGET_DOCKER_TEST_IMAGE"
23+
IMAGE_NAME=${TEST_IMAGE_NAMES[$TARGET_DOCKER_TEST_IMAGE]}
24+
if [[ -z "$IMAGE_NAME" ]]; then
25+
echo "[ERROR] The target platform $TARGET_DOCKER_TEST_IMAGE doesn't exist. Check $CI_DIR/_init.sh"
26+
exit 1
27+
fi
28+
TARGET_TEST_IMAGES=([$TARGET_DOCKER_TEST_IMAGE]=$IMAGE_NAME)
29+
else
30+
echo "[ERROR] Set TARGET_DOCKER_TEST_IMAGE to the docker image name to run the test"
31+
for name in "${!TEST_IMAGE_NAMES[@]}"; do
32+
echo " " $name
33+
done
34+
exit 2
35+
fi
36+
37+
for name in "${!TARGET_TEST_IMAGES[@]}"; do
38+
echo "[INFO] Testing $DRIVER_NAME on $name"
39+
docker container run \
40+
--rm \
41+
--add-host=snowflake.reg.local:${IP_ADDR} \
42+
--add-host=s3testaccount.reg.local:${IP_ADDR} \
43+
-v $ROOT_DIR:/mnt/host \
44+
-v $WORKSPACE:/mnt/workspace \
45+
-e LOCAL_USER_ID=$(id -u ${USER}) \
46+
-e GIT_COMMIT \
47+
-e GIT_BRANCH \
48+
-e GIT_URL \
49+
-e AWS_ACCESS_KEY_ID \
50+
-e AWS_SECRET_ACCESS_KEY \
51+
-e GITHUB_ACTIONS \
52+
-e GITHUB_SHA \
53+
-e GITHUB_REF \
54+
-e RUNNER_TRACKING_ID \
55+
-e JOB_NAME \
56+
-e BUILD_NUMBER \
57+
-e JENKINS_HOME \
58+
${TEST_IMAGE_NAMES[$name]} \
59+
/mnt/host/ci/container/test_component.sh
60+
echo "[INFO] Test Results: $WORKSPACE/junit.xml"
61+
done
62+
else
63+
source $CI_DIR/scripts/setup_connection_parameters.sh
64+
cd $CI_DIR/..
65+
make test
66+
fi

connection_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ func TestGetQueryStatus(t *testing.T) {
419419
t.Error("there was no query status returned")
420420
return
421421
}
422-
423-
if qStatus.ErrorCode != "" || qStatus.ScanBytes != 2048 || qStatus.ProducedRows != 10 {
422+
if qStatus.ErrorCode != "" || qStatus.ScanBytes <= 0 || qStatus.ProducedRows != 10 {
424423
t.Errorf("expected no error. got: %v, scan bytes: %v, produced rows: %v",
425424
qStatus.ErrorCode, qStatus.ScanBytes, qStatus.ProducedRows)
426425
return

datetime_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ func TestIncorrectSecondsFraction(t *testing.T) {
6666
func TestSnowflakeFormatToGoFormatIntegrationTest(t *testing.T) {
6767
runDBTest(t, func(dbt *DBTest) {
6868
dbt.mustExec("ALTER SESSION SET TIME_OUTPUT_FORMAT = 'HH24:MI:SS.FF'")
69+
dbt.mustExec("ALTER SESSION SET TIMESTAMP_OUTPUT_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF3 TZHTZM'")
70+
dbt.mustExec("ALTER SESSION SET TIMESTAMP_NTZ_OUTPUT_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF3'")
6971
for _, forceFormat := range []string{forceJSON, forceARROW} {
7072
dbt.mustExec(forceFormat)
7173

htap_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ func TestQueryContextCacheDisabled(t *testing.T) {
338338
}
339339

340340
func TestHybridTablesE2E(t *testing.T) {
341+
skipOnJenkins(t, "HTAP is not enabled on environment")
341342
if runningOnGithubAction() && !runningOnAWS() {
342343
t.Skip("HTAP is enabled only on AWS")
343344
}

parameters.json.local

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"testconnection": {
3+
"SNOWFLAKE_TEST_HOST": "snowflake.reg.local",
4+
"SNOWFLAKE_TEST_PROTOCOL": "http",
5+
"SNOWFLAKE_TEST_PORT": "8082",
6+
"SNOWFLAKE_TEST_USER": "snowman",
7+
"SNOWFLAKE_TEST_PASSWORD": "test",
8+
"SNOWFLAKE_TEST_ACCOUNT": "s3testaccount",
9+
"SNOWFLAKE_TEST_WAREHOUSE": "regress",
10+
"SNOWFLAKE_TEST_DATABASE": "testdb",
11+
"SNOWFLAKE_TEST_SCHEMA": "testschema",
12+
"SNOWFLAKE_TEST_ROLE": "sysadmin"
13+
}
14+
}

secure_storage_manager_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func TestSetAndGetCredentialIdToken(t *testing.T) {
7070
}
7171
}
7272
func TestCreateCredentialCache(t *testing.T) {
73+
skipOnJenkins(t, "cannot write to file system")
7374
if runningOnGithubAction() {
7475
t.Skip("cannot write to github file system")
7576
}

0 commit comments

Comments
 (0)