Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Tests: adds runtime version skew tests #7575

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6e9ccba
Integration Tests: adds runtime version skew tests
JoshVanL Mar 1, 2024
1e28529
Update tests/integration/suite/daprd/serviceinvocation/grpc/skew.go
JoshVanL Mar 1, 2024
760f1be
Update tests/integration/suite/daprd/serviceinvocation/grpc/skew.go
JoshVanL Mar 1, 2024
dfe2e30
Update tests/integration/suite/daprd/serviceinvocation/http/skew.go
JoshVanL Mar 1, 2024
661f9de
Update tests/integration/suite/daprd/serviceinvocation/http/skew.go
JoshVanL Mar 1, 2024
4a2b592
Get available versions by checking previous directory
JoshVanL Mar 2, 2024
9a8e836
Fix CLI flags set of daprd for v1.13 skew process
JoshVanL May 23, 2024
5c5dbe9
Linting
JoshVanL May 31, 2024
71551e4
Merge branch 'master' into test-integration-skew
dapr-bot Jun 17, 2024
dab843a
Merge branch 'master' into test-integration-skew
dapr-bot Jun 18, 2024
fd53546
Merge branch 'master' into test-integration-skew
dapr-bot Jun 18, 2024
14d7265
Merge branch 'master' into test-integration-skew
dapr-bot Jun 19, 2024
66672f0
Merge branch 'master' into test-integration-skew
dapr-bot Jun 19, 2024
a96c118
Merge branch 'master' into test-integration-skew
dapr-bot Jun 20, 2024
2dcc6dd
Merge branch 'master' into test-integration-skew
dapr-bot Jun 20, 2024
ea85c2b
Merge branch 'master' into test-integration-skew
dapr-bot Jun 20, 2024
5b98b4f
Merge branch 'master' into test-integration-skew
dapr-bot Jun 21, 2024
bab7663
Merge branch 'master' into test-integration-skew
dapr-bot Jun 21, 2024
90eedc8
Merge branch 'master' into test-integration-skew
dapr-bot Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ require (
go.uber.org/ratelimit v0.3.0
golang.org/x/crypto v0.22.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/mod v0.14.0
golang.org/x/net v0.24.0
golang.org/x/sync v0.6.0
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237
Expand Down Expand Up @@ -405,7 +406,6 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
Expand Down
126 changes: 96 additions & 30 deletions tests/integration/framework/binary/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@ func BuildAll(t *testing.T) {

binaryNames := []string{"daprd", "placement", "sentry", "operator", "injector"}

t.Logf("Building binaries: %v", binaryNames)

var wg sync.WaitGroup
wg.Add(len(binaryNames))
wg.Add(len(binaryNames) * 2)
for _, name := range binaryNames {
if runtime.GOOS == "windows" {
Build(t, name)
wg.Done()
} else {
go func(name string) {
defer wg.Done()
Build(t, name)
}(name)
}
go func(name string) {
defer wg.Done()
BuildLocal(t, name)
}(name)
go func(name string) {
defer wg.Done()
BuildPrevious(t, name)
}(name)
}
wg.Wait()
}

func Build(t *testing.T, name string) {
func BuildLocal(t *testing.T, name string) {
t.Helper()
if _, ok := os.LookupEnv(EnvKey(name)); !ok {
t.Logf("%q not set, building %q binary", EnvKey(name), name)
Expand All @@ -66,31 +67,96 @@ func Build(t *testing.T, name string) {
} else {
tmpdir = os.TempDir()
}

binPath := filepath.Join(tmpdir, "dapr_integration_tests/"+name)
if runtime.GOOS == "windows" {
binPath += ".exe"
}
buildBin(t, buildReq{
name: name,
rootDir: rootDir,
mainLocation: filepath.Join("cmd", name),
outputBinPath: binPath,
})
require.NoError(t, os.Setenv(EnvKey(name), binPath))
} else {
t.Logf("%q set, using %q pre-built binary", EnvKey(name), EnvValue(name))
}
}

func BuildPrevious(t *testing.T, name string) {
t.Helper()

var wg sync.WaitGroup
defer wg.Wait()

_, tfile, _, ok := runtime.Caller(0)
require.True(t, ok)
prevPath := filepath.Join(tfile, "../previous")

versions := PreviousVersions(t)
wg.Add(len(versions))
for _, v := range versions {
go func(v string) {
defer wg.Done()

t.Logf("Building previous binary: [%q] %q", v, name)
rootDir := filepath.Join(prevPath, v)
buildBin(t, buildReq{
name: name,
rootDir: rootDir,
mainLocation: name,
outputBinPath: filepath.Join(os.TempDir(), "dapr_integration_tests/"+name+"-"+v),
})
}(v)
}
}

ioout := iowriter.New(t, name)
ioerr := iowriter.New(t, name)
func PreviousVersions(t *testing.T) []string {
_, tfile, _, ok := runtime.Caller(0)
require.True(t, ok)
prevPath := filepath.Join(tfile, "../previous")

t.Logf("Root dir: %q", rootDir)
t.Logf("Compiling %q binary to: %q", name, binPath)
cmd := exec.Command("go", "build", "-tags=allcomponents,wfbackendsqlite", "-v", "-o", binPath, "./cmd/"+name)
cmd.Dir = rootDir
cmd.Stdout = ioout
cmd.Stderr = ioerr
// Ensure CGO is disabled to avoid linking against system libraries.
cmd.Env = append(os.Environ(), "CGO_ENABLED=0")
require.NoError(t, cmd.Run())
dir, err := os.ReadDir(prevPath)
require.NoError(t, err)

require.NoError(t, ioout.Close())
require.NoError(t, ioerr.Close())
versions := make([]string, 0, len(dir)-1)
for _, d := range dir {
if !d.IsDir() {
continue
}
versions = append(versions, d.Name())
}

require.NoError(t, os.Setenv(EnvKey(name), binPath))
} else {
t.Logf("%q set, using %q pre-built binary", EnvKey(name), EnvValue(name))
return versions
}

type buildReq struct {
name string
rootDir string
mainLocation string
outputBinPath string
}

// Use a consistent temp dir for the binary so that the binary is cached on
// subsequent runs.
func buildBin(t *testing.T, req buildReq) {
if runtime.GOOS == "windows" {
req.outputBinPath += ".exe"
}

ioout := iowriter.New(t, req.name)
ioerr := iowriter.New(t, req.name)

t.Logf("Root dir: %q", req.rootDir)
t.Logf("Compiling %q binary to: %q", req.name, req.outputBinPath)
cmd := exec.Command("go", "build", "-tags=allcomponents,wfbackendsqlite", "-v", "-o", req.outputBinPath, "./"+req.mainLocation) // #nosec G204
cmd.Dir = req.rootDir
cmd.Stdout = ioout
cmd.Stderr = ioerr
// Ensure CGO is disabled to avoid linking against system libraries.
cmd.Env = append(os.Environ(), "CGO_ENABLED=0")
require.NoError(t, cmd.Run())

require.NoError(t, ioout.Close())
require.NoError(t, ioerr.Close())
}

func EnvValue(name string) string {
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/framework/binary/previous/v1.13/daprd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2024 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"github.com/dapr/dapr/cmd/daprd/app"
_ "github.com/dapr/dapr/cmd/daprd/components"
)

func main() {
app.Run()
}