Skip to content

Commit

Permalink
fix connection issue in github action
Browse files Browse the repository at this point in the history
  • Loading branch information
bimalkjha committed Aug 26, 2024
1 parent 9f85fa3 commit c522a23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,11 @@ jobs:
echo "CGO_LDFLAGS=$cgo_ldflags" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=$ld_library_path" >> "$GITHUB_ENV"
db2_user=
db2_passwd=
db2_database=
db2_hostname=
db2_port=
echo "DB2_USER=$db2_user" >> "$GITHUB_ENV"
echo "DB2_PASSWD=$db2_passwd" >> "$GITHUB_ENV"
echo "DB2_DATABASE=$db2_database" >> "$GITHUB_ENV"
echo "DB2_HOSTNAME=$db2_hostname" >> "$GITHUB_ENV"
echo "DB2_PORT=$db2_port" >> "$GITHUB_ENV"
- name: Test
env:
DB2_CONNSTR: ${{ secrets.DB2_CONNSTR }}
run: |
pwd
cd testdata
echo "============TEST CASES ======"
#echo "CGO_LDFLAGS = " $CGO_LDFLAGS
#echo "DB2_USER = " $DB2_USER
go test -v
10 changes: 6 additions & 4 deletions testdata/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ func UpdateConnectionVariables() {

//Createconnection will return the db instance
func Createconnection() (db *sql.DB) {
UpdateConnectionVariables()
connStr = "PROTOCOL=tcpip;HOSTNAME=" + host + ";PORT=" + port + ";DATABASE=" + database + ";UID=" + uid + ";PWD=" + pwd
//connStr = "PROTOCOL=tcpip;HOSTNAME=" + host + ";PORT=" + port + ";DATABASE=" + database + ";UID=" + uid + ";PWD=" + pwd +";Security=ssl"
connStr, connStrFound = os.LookupEnv("DB2_CONNSTR")
if !connStrFound{
UpdateConnectionVariables()
connStr = "PROTOCOL=tcpip;HOSTNAME=" + host + ";PORT=" + port + ";DATABASE=" + database + ";UID=" + uid + ";PWD=" + pwd
}

db, _ = sql.Open("go_ibm_db", connStr)
return db
}
Expand Down Expand Up @@ -919,7 +922,6 @@ func QueryDisplayTable(db *sql.DB) error {
func ConnectionInvalidUserPassword() int {
var errStr string
UpdateConnectionVariables()
//badConnStr := "HOSTNAME=hostname1;PORT1234=;DATABASE=sample;UID=uid;PWD=pwd"
badConnStr := "PROTOCOL=tcpip;HOSTNAME=" + host + ";PORT=" + port + ";DATABASE=" + database + ";UID=" + uid + ";PWD=abcd"

db, _ := sql.Open("go_ibm_db", badConnStr )
Expand Down

0 comments on commit c522a23

Please sign in to comment.