Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Extract current extension version to a single location
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesGuthrie committed Jun 8, 2022
1 parent 07aa741 commit 195f63d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/go-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
docker_image_prefix:
description: 'Docker image prefix'
required: true
default: 'ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2'
default: 'ghcr.io/timescale/dev_promscale_extension:<branch>-ts2'

env:
golang-version: 1.18.1
Expand Down Expand Up @@ -46,7 +46,8 @@ jobs:
run: |
branch_name=$(echo ${{github.head_ref || github.ref_name}} | sed 's#/#-#')
possible_branch_tag=$(echo ${branch_name}-ts2)
stable_branch_tag=$(echo 0.5.0-ts2)
extension_version=$(cat EXTENSION_VERSION | tr -d '[:space:]')
stable_branch_tag=$(echo ${extension_version}-ts2)
image_base="ghcr.io/timescale/dev_promscale_extension"
docker_image_12=$(./scripts/fallback-docker.sh ${image_base}:${possible_branch_tag}-pg12 ${image_base}:${stable_branch_tag}-pg12)
docker_image_13=$(./scripts/fallback-docker.sh ${image_base}:${possible_branch_tag}-pg13 ${image_base}:${stable_branch_tag}-pg13)
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
run: |
branch_name=$(echo ${{github.head_ref || github.ref_name}} | sed 's#/#-#')
possible_branch_tag=$(echo ${branch_name}-ts2-pg${{matrix.pg}})
stable_branch_tag=$(echo 0.5.0-ts2-pg${{matrix.pg}})
extension_version=$(cat EXTENSION_VERSION | tr -d '[:space:]')
stable_branch_tag=$(echo ${extension_version}-ts2-pg${{matrix.pg}})
image_base="ghcr.io/timescale/dev_promscale_extension"
docker_image=$(./scripts/fallback-docker.sh ${image_base}:${possible_branch_tag} ${image_base}:${stable_branch_tag})
echo "::set-output name=docker_image::${docker_image}"
Expand Down
1 change: 1 addition & 0 deletions EXTENSION_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5.0
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ pkg/tests/testdata/traces-dataset.sz:

.PHONY: e2e
e2e: CURRENT_BRANCH?=$(shell git branch --show-current | sed 's#/#-#')
e2e: DOCKER_IMAGE?=$(shell ./scripts/fallback-docker.sh $(LOCAL_DOCKER_BASE):head-ts2-pg14 $(GHCR_DOCKER_BASE):$(CURRENT_BRANCH)-ts2-pg14 $(GHCR_DOCKER_BASE):0.5.0-ts2-pg14)
e2e: EXTENSION_VERSION=$(shell cat EXTENSION_VERSION | tr -d '[:space:]')
e2e: DOCKER_IMAGE?=$(shell ./scripts/fallback-docker.sh $(LOCAL_DOCKER_BASE):head-ts2-pg14 $(GHCR_DOCKER_BASE):$(CURRENT_BRANCH)-ts2-pg14 $(GHCR_DOCKER_BASE):$(EXTENSION_VERSION)-ts2-pg14)
e2e: pkg/tests/testdata/traces-dataset.sz generate
go test -v ./pkg/tests/end_to_end_tests/ -timescale-docker-image=$(DOCKER_IMAGE)
go test -v ./pkg/tests/end_to_end_tests/ -use-timescaledb=false -timescale-docker-image=$(DOCKER_IMAGE)
go test -v ./pkg/tests/end_to_end_tests/ -use-multinode -timescale-docker-image=$(DOCKER_IMAGE)

.PHONY: upgrade-test
upgrade-test: CURRENT_BRANCH?=$(shell git branch --show-current | sed 's#/#-#')
upgrade-test: DOCKER_IMAGE?=$(shell ./scripts/fallback-docker.sh $(LOCAL_DOCKER_BASE):head-ts2-pg13 $(GHCR_DOCKER_BASE):$(CURRENT_BRANCH)-ts2-pg13 $(GHCR_DOCKER_BASE):0.5.0-ts2-pg13)
upgrade-test: EXTENSION_VERSION=$(shell cat EXTENSION_VERSION | tr -d '[:space:]')
upgrade-test: DOCKER_IMAGE?=$(shell ./scripts/fallback-docker.sh $(LOCAL_DOCKER_BASE):head-ts2-pg13 $(GHCR_DOCKER_BASE):$(CURRENT_BRANCH)-ts2-pg13 $(GHCR_DOCKER_BASE):$(EXTENSION_VERSION)-ts2-pg13)
upgrade-test:
go test -v ./pkg/tests/upgrade_tests/ -timescale-docker-image=$(DOCKER_IMAGE)

Expand Down
7 changes: 3 additions & 4 deletions pkg/internal/testhelpers/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"flag"
"fmt"
constants "github.com/timescale/promscale/pkg/tests"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -46,8 +47,7 @@ func TestWithDB(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
// TODO (james): Replace hardcoded value
extensionState := NewTestOptions(timescaleBit, "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14")
extensionState := NewTestOptions(timescaleBit, constants.PromscaleExtensionContainer)
WithDB(t, *testDatabase, Superuser, false, extensionState, func(db *pgxpool.Pool, t testing.TB, connectURL string) {
var res int
err := db.QueryRow(context.Background(), "SELECT 1").Scan(&res)
Expand All @@ -63,8 +63,7 @@ func TestWithDB(t *testing.T) {
func runMain(m *testing.M) int {
flag.Parse()
ctx := context.Background()
// TODO (james): Replace hardcoded value
extensionState := NewTestOptions(timescaleBit, "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14")
extensionState := NewTestOptions(timescaleBit, constants.PromscaleExtensionContainer)
if !testing.Short() && *useDocker {
_, closer, err := StartPGContainer(ctx, nil, extensionState, "", false)
if err != nil {
Expand Down
21 changes: 21 additions & 0 deletions pkg/tests/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package constants

import (
"os"
"strings"
)

var (
PromscaleExtensionVersion string
PromscaleExtensionContainer string
)

func init() {
content, err := os.ReadFile("../../../EXTENSION_VERSION")
if err != nil {
panic(err)
}

PromscaleExtensionVersion = strings.TrimSpace(string(content))
PromscaleExtensionContainer = "ghcr.io/timescale/dev_promscale_extension:" + PromscaleExtensionVersion + "-ts2-pg14"
}
12 changes: 6 additions & 6 deletions pkg/tests/end_to_end_tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"flag"
"fmt"
constants "github.com/timescale/promscale/pkg/tests"
"io"
"os"
"path/filepath"
Expand All @@ -31,12 +32,11 @@ import (
)

var (
testDatabase = flag.String("database", "tmp_db_timescale_migrate_test", "database to run integration tests on")
updateGoldenFiles = flag.Bool("update", false, "update the golden files of this test")
useDocker = flag.Bool("use-docker", true, "start database using a docker container")
useTimescaleDB = flag.Bool("use-timescaledb", true, "use TimescaleDB")
// TODO (james): Replace hardcoded value
timescaleDockerImage = flag.String("timescale-docker-image", "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14", "TimescaleDB docker image to run tests against")
testDatabase = flag.String("database", "tmp_db_timescale_migrate_test", "database to run integration tests on")
updateGoldenFiles = flag.Bool("update", false, "update the golden files of this test")
useDocker = flag.Bool("use-docker", true, "start database using a docker container")
useTimescaleDB = flag.Bool("use-timescaledb", true, "use TimescaleDB")
timescaleDockerImage = flag.String("timescale-docker-image", constants.PromscaleExtensionContainer, "TimescaleDB docker image to run tests against")
useMultinode = flag.Bool("use-multinode", false, "use TimescaleDB Multinode")
useTimescaleDBNightly = flag.Bool("use-timescaledb-nightly", false, "use TimescaleDB nightly images")
printLogs = flag.Bool("print-logs", false, "print TimescaleDB logs")
Expand Down
6 changes: 3 additions & 3 deletions pkg/tests/upgrade_tests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"context"
"flag"
"fmt"
constants "github.com/timescale/promscale/pkg/tests"
"io"
"io/ioutil"
"net"
Expand Down Expand Up @@ -43,7 +44,7 @@ var (
testDatabase = flag.String("database", "tmp_db_timescale_upgrade_test", "database to run integration tests on")
printLogs = flag.Bool("print-logs", false, "print TimescaleDB logs")
// use "local/dev_promscale_extension:head-ts2-pg13" for local testing
dockerImage = flag.String("timescale-docker-image", "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14", "TimescaleDB docker image for latest version to run tests against")
dockerImage = flag.String("timescale-docker-image", constants.PromscaleExtensionContainer, "TimescaleDB docker image for latest version to run tests against")
baseExtensionState testhelpers.TestOptions
)

Expand Down Expand Up @@ -789,8 +790,7 @@ func startDB(t *testing.T, ctx context.Context) (*pgx.Conn, testcontainers.Conta
t.Fatal(err)
}

// TODO (james): Replace hardcoded value
extensionState := testhelpers.NewTestOptions(testhelpers.Timescale, "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14")
extensionState := testhelpers.NewTestOptions(testhelpers.Timescale, constants.PromscaleExtensionContainer)

dbContainer, closer, err := testhelpers.StartDatabaseImage(ctx, t, "timescaledev/promscale-extension:testing-extension-upgrade", tmpDir, dataDir, *printLogs, extensionState)
if err != nil {
Expand Down

0 comments on commit 195f63d

Please sign in to comment.