Skip to content

Commit

Permalink
Add a test to verify that the server can be run for 1 minute with all…
Browse files Browse the repository at this point in the history
… services enabled
  • Loading branch information
MichaelSnowden committed Feb 3, 2023
1 parent 5721cf8 commit b2c09ef
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -307,6 +307,11 @@ integration-test-coverage: $(COVER_ROOT)
@printf $(COLOR) "Run integration tests with coverage..."
@go test $(INTEGRATION_TEST_DIRS) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) $(INTEGRATION_TEST_COVERPKG) -coverprofile=$(INTEGRATION_COVER_PROFILE)

# TODO(snowden): add coverage for these tests
smoke-tests:
@printf $(COLOR) "Run smoke tests..."
@go test ./tests/smoke -timeout=$(TEST_TIMEOUT) $(TEST_TAG)

functional-test-coverage: $(COVER_ROOT)
@printf $(COLOR) "Run functional tests with coverage with $(PERSISTENCE_DRIVER) driver..."
@go test $(FUNCTIONAL_TEST_ROOT) -timeout=$(TEST_TIMEOUT) -race $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(FUNCTIONAL_TEST_COVERPKG) -coverprofile=$(FUNCTIONAL_COVER_PROFILE)
Expand Down
12 changes: 12 additions & 0 deletions develop/buildkite/pipeline.yml
Expand Up @@ -35,6 +35,18 @@ steps:
run: db-integration-test
config: ./develop/buildkite/docker-compose.yml

- label: ":golang: smoke tests"
agents:
queue: "default"
docker: "*"
command: "make smoke-tests"
artifact_paths:
- ".coverage/*.out"
plugins:
- docker-compose#v3.8.0:
run: db-integration-test
config: ./develop/buildkite/docker-compose.yml

- label: ":golang: functional test with cassandra"
agents:
queue: "default"
Expand Down
1 change: 0 additions & 1 deletion temporal/server_test.go
Expand Up @@ -48,5 +48,4 @@ func TestNewServer(t *testing.T) {
WithConfig(cfg),
)
assert.NoError(t, err)
// TODO: add tests for Server.Run(), etc.
}
66 changes: 66 additions & 0 deletions tests/smoke/server_start_test.go
@@ -0,0 +1,66 @@
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// package smoke contains tests that verify very basic functionality of the server.
// They're similar to integration tests, but we only run them for one DB type.
// This needs to be in a separate package because the other tests in the parent directory modify the same global
// variables as this test.
package smoke

import (
"path"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.temporal.io/server/common/config"
"go.temporal.io/server/temporal"
"go.temporal.io/server/tests/testutils"

// this is needed to register the sqlite plugin
_ "go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite"
)

// TestServerImpl_Start verifies that the server can be started and run for a minute without crashing
func TestServerImpl_Start(t *testing.T) {
configDir := path.Join(testutils.GetRepoRootDirectory(), "config")
cfg, err := config.LoadConfig("development-sqlite", configDir, "")
require.NoError(t, err)
cfg.DynamicConfigClient.Filepath = path.Join(configDir, "dynamicconfig", "development-sql.yaml")
server, err := temporal.NewServer(
temporal.ForServices(temporal.DefaultServices),
temporal.WithConfig(cfg),
)
assert.NoError(t, err)
err = server.Start()
if assert.NoError(t, err) {
time.Sleep(time.Minute)
}
defer func() {
err = server.Stop()
assert.NoError(t, err)
}()
}

0 comments on commit b2c09ef

Please sign in to comment.