-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing cluster env in test workflow
- Add workflow dispatch trigger
- Loading branch information
Showing
25 changed files
with
292 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: "Dispatch" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Version tag" | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
uses: ./.github/workflows/tests.yml | ||
with: | ||
esdb_version: ${{ inputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,58 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
help: | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | ||
|
||
OS := $(shell uname) | ||
|
||
GENERATE_PROTOS_FLAG := | ||
|
||
.PHONY: build | ||
build: ## Build based on the OS. | ||
ifeq ($(OS),Linux) | ||
./build.sh $(GENERATE_PROTOS_FLAG) | ||
else ifeq ($(OS),Darwin) | ||
./build.sh $(GENERATE_PROTOS_FLAG) | ||
else | ||
.\build.ps1 $(GENERATE_PROTOS_FLAG) | ||
endif | ||
|
||
.PHONY: generate-protos | ||
generate-protos: ## Regenerate protobuf and gRPC files while building. | ||
ifeq ($(OS),Linux) | ||
$(eval GENERATE_PROTOS_FLAG := --generate-protos) | ||
else | ||
$(eval GENERATE_PROTOS_FLAG := -generateProtos) | ||
endif | ||
build | ||
|
||
|
||
DOCKER_COMPOSE_CMD := $(shell command -v docker-compose 2> /dev/null) | ||
ifeq ($(DOCKER_COMPOSE_CMD),) | ||
DOCKER_COMPOSE_CMD := docker compose | ||
endif | ||
|
||
.PHONY: singleNode | ||
singleNode: | ||
@go test -v ./esdb -run 'TestStreams|TestPersistentSubscriptions|TestExpectations' | ||
singleNode: ## Run tests against a single node. | ||
@EVENTSTORE_INSECURE=true go test -count=1 -v ./esdb -run 'TestStreams|TestPersistentSubscriptions|Expectations' | ||
|
||
.PHONY: secureNode | ||
secureNode: | ||
secureNode: ## Run tests against a secure node. | ||
@$(DOCKER_COMPOSE_CMD) down -v | ||
@$(DOCKER_COMPOSE_CMD) pull | ||
@$(DOCKER_COMPOSE_CMD) up -d | ||
@EVENTSTORE_INSECURE=FALSE go test -v ./esdb -run 'TestStreams|TestPersistentSubscriptions' | ||
@EVENTSTORE_INSECURE=false go test -v ./esdb -run 'TestStreams|TestPersistentSubscriptions' | ||
@$(DOCKER_COMPOSE_CMD) down | ||
|
||
.PHONY: clusterNode | ||
clusterNode: | ||
@$(DOCKER_COMPOSE_CMD) -f cluster-docker-compose.yml down -v | ||
clusterNode: ## Run tests against a cluster node. | ||
@$(DOCKER_COMPOSE_CMD) -f cluster-docker-compose.yml down --remove-orphans -v | ||
@$(DOCKER_COMPOSE_CMD) -f cluster-docker-compose.yml pull | ||
@$(DOCKER_COMPOSE_CMD) -f cluster-docker-compose.yml up -d | ||
@EVENTSTORE_INSECURE=FALSE go test -v ./esdb -run 'TestStreams|TestPersistentSubscriptions' | ||
@$(DOCKER_COMPOSE_CMD) -f cluster-docker-compose.yml down | ||
@echo "Waiting for services to be fully ready..." | ||
@sleep 5 | ||
@EVENTSTORE_INSECURE=false CLUSTER=true go test -count=1 -v ./esdb -run 'TestStreams|TestPersistentSubscriptions' | ||
@$(DOCKER_COMPOSE_CMD) -f cluster-docker-compose.yml down --remove-orphans | ||
|
||
.PHONY: test | ||
test: singleNode secureNode clusterNode ## Run all tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,92 @@ | ||
package esdb_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
type DatabaseType int | ||
|
||
const ( | ||
Empty DatabaseType = iota | ||
Prepopulated | ||
Insecure | ||
Cluster | ||
) | ||
|
||
func TestStreams(t *testing.T) { | ||
emptyContainer, emptyClient := CreateEmptyDatabase(t) | ||
defer emptyContainer.Close() | ||
defer emptyClient.Close() | ||
|
||
if emptyContainer != nil { | ||
defer emptyContainer.Close() | ||
} | ||
|
||
if emptyClient != nil { | ||
defer emptyClient.Close() | ||
} | ||
|
||
populatedContainer, populatedClient := CreatePopulatedDatabase(t) | ||
defer populatedContainer.Close() | ||
defer populatedClient.Close() | ||
|
||
if populatedContainer != nil { | ||
defer populatedContainer.Close() | ||
} | ||
|
||
if populatedClient != nil { | ||
defer populatedClient.Close() | ||
} | ||
|
||
isCluster := GetEnvOrDefault("CLUSTER", "false") == "true" | ||
isInsecure := GetEnvOrDefault("EVENTSTORE_INSECURE", "true") == "true" | ||
|
||
if isCluster { | ||
ClusterTests(t) | ||
} | ||
|
||
AppendTests(t, emptyContainer, emptyClient) | ||
ReadStreamTests(t, emptyClient, populatedClient) | ||
SubscriptionTests(t, emptyClient, populatedClient) | ||
DeleteTests(t, emptyClient) | ||
ConnectionTests(t, emptyContainer) | ||
|
||
if !isCluster { | ||
if !isInsecure { | ||
TLSTests(t, emptyContainer) | ||
SecureAuthenticationTests(t, emptyClient) | ||
} else { | ||
InsecureAuthenticationTests(t, emptyClient) | ||
} | ||
} | ||
} | ||
|
||
func TestPersistentSubscriptions(t *testing.T) { | ||
emptyContainer, emptyClient := CreateEmptyDatabase(t) | ||
defer emptyContainer.Close() | ||
defer emptyClient.Close() | ||
|
||
if emptyContainer != nil { | ||
defer emptyContainer.Close() | ||
} | ||
|
||
if emptyClient != nil { | ||
defer emptyClient.Close() | ||
} | ||
|
||
populatedContainer, populatedClient := CreatePopulatedDatabase(t) | ||
defer populatedContainer.Close() | ||
defer populatedClient.Close() | ||
|
||
if populatedContainer != nil { | ||
defer populatedContainer.Close() | ||
} | ||
|
||
if populatedClient != nil { | ||
defer populatedClient.Close() | ||
} | ||
|
||
PersistentSubReadTests(t, emptyClient) | ||
PersistentSubTests(t, emptyClient, populatedClient) | ||
} | ||
|
||
func TestExpectations(t *testing.T) { | ||
populatedContainer, populatedClient := CreatePopulatedDatabase(t) | ||
defer populatedContainer.Close() | ||
defer populatedClient.Close() | ||
|
||
if populatedContainer != nil { | ||
defer populatedContainer.Close() | ||
} | ||
|
||
if populatedClient != nil { | ||
defer populatedClient.Close() | ||
} | ||
|
||
ReadAllTests(t, populatedClient) | ||
} | ||
|
||
func TestMisc(t *testing.T) { | ||
os.Setenv("EVENTSTORE_INSECURE", "false") | ||
emptyContainer, emptyClient := CreateEmptyDatabase(t) | ||
defer emptyContainer.Close() | ||
defer emptyClient.Close() | ||
|
||
TLSTests(t, emptyContainer) | ||
SecureAuthenticationTests(t, emptyClient) | ||
|
||
os.Setenv("EVENTSTORE_INSECURE", "true") | ||
insecureContainer, insecureClient := CreateEmptyDatabase(t) | ||
defer insecureContainer.Close() | ||
defer insecureClient.Close() | ||
|
||
InsecureAuthenticationTests(t, insecureClient) | ||
// tests that don't require a database | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.