Skip to content

Commit

Permalink
Merge pull request #18 from DanRoscigno/add-curl-helper
Browse files Browse the repository at this point in the history
add LongRunningJob helper
  • Loading branch information
DanRoscigno authored Feb 7, 2024
2 parents f2de2cc + 140a791 commit 0f8a677
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
5 changes: 5 additions & 0 deletions ci/SHELL/quickstart/basic/NYPD_download
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/ash
cd /tmp/
curl --silent --no-buffer \
-o /tmp/NYPD_Crash_Data.csv \
https://raw.githubusercontent.com/StarRocks/demo/master/documentation-samples/quickstart/datasets/NYPD_Crash_Data.csv
5 changes: 5 additions & 0 deletions ci/SHELL/quickstart/basic/Weather_download
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/ash
cd /tmp/
curl --silent --no-buffer \
-o 72505394728.csv \
https://raw.githubusercontent.com/StarRocks/demo/master/documentation-samples/quickstart/datasets/72505394728.csv
5 changes: 4 additions & 1 deletion ci/docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ var _ = Describe("Docs", func() {
fmt.Print(err)
}
SQL := string(b)
re := strings.NewReplacer("AAAAAAAAAAAAAAAAAAAA", AWS_S3_ACCESS_KEY, "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", AWS_S3_SECRET_KEY)
re := strings.NewReplacer(
"AAAAAAAAAAAAAAAAAAAA", AWS_S3_ACCESS_KEY,
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", AWS_S3_SECRET_KEY,
)

SQLWithKey := re.Replace(SQL)
_, err = db.Exec(SQLWithKey)
Expand Down
11 changes: 10 additions & 1 deletion ci/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"database/sql"
"os"
"fmt"
"github.com/go-sql-driver/mysql"
"github.com/go-sql-driver/mysql"
"os/exec"
. "github.com/onsi/gomega"
)
var db *sql.DB

Expand All @@ -28,3 +30,10 @@ func SQLFromFile(filename string) string {
return string(bytes)
}

func LongRunningScript(filename string) {
longJob := exec.Command(filename)
err := longJob.Start()
Expect(err).ToNot(HaveOccurred())
err = longJob.Wait()
Expect(err).ToNot(HaveOccurred())
}
26 changes: 4 additions & 22 deletions ci/quickstart_basic_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package docs_test

import (
"os/exec"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
Expand All @@ -14,19 +13,10 @@ var _ = Describe("QuickstartBasic", func() {
// download the crash data in /tmp/ dir
// https://stackoverflow.com/questions/16703647/why-does-curl-return-error-23-failed-writing-body
By("Downloading the NYPD Crash data")
NYPDCurl := exec.Command("/usr/bin/curl","-s","-N","-o","/tmp/NYPD_Crash_Data.csv","https://raw.githubusercontent.com/StarRocks/demo/master/documentation-samples/quickstart/datasets/NYPD_Crash_Data.csv")
err := NYPDCurl.Start()
Expect(err).ToNot(HaveOccurred())
err = NYPDCurl.Wait()
Expect(err).ToNot(HaveOccurred())
LongRunningScript("SHELL/quickstart/basic/NYPD_download")

By("Downloading the NOAA weather data")
WeatherCurl := exec.Command("/usr/bin/curl","-s","-N","-o","/tmp/72505394728.csv","https://raw.githubusercontent.com/StarRocks/demo/master/documentation-samples/quickstart/datasets/72505394728.csv")
err = WeatherCurl.Start()
Expect(err).ToNot(HaveOccurred())
err = WeatherCurl.Wait()
Expect(err).ToNot(HaveOccurred())

LongRunningScript("SHELL/quickstart/basic/Weather_download")
})

AfterAll(func() {
Expand Down Expand Up @@ -63,18 +53,10 @@ var _ = Describe("QuickstartBasic", func() {

It("should be able to load data via stream load", func() {
By("uploading the NYPD crash data")
NYPDStreamLoad := exec.Command("SHELL/quickstart/basic/NYPD_stream_load")
err := NYPDStreamLoad.Start()
Expect(err).ToNot(HaveOccurred())
err = NYPDStreamLoad.Wait()
Expect(err).ToNot(HaveOccurred())
LongRunningScript("SHELL/quickstart/basic/NYPD_stream_load")

By("uploading the NOAA weather data")
WeatherStreamLoad := exec.Command("SHELL/quickstart/basic/Weather_stream_load")
err = WeatherStreamLoad.Start()
Expect(err).ToNot(HaveOccurred())
err = WeatherStreamLoad.Wait()
Expect(err).ToNot(HaveOccurred())
LongRunningScript("SHELL/quickstart/basic/Weather_stream_load")
})

It("should be able to query tables", func() {
Expand Down

0 comments on commit 0f8a677

Please sign in to comment.