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

[jaeger-v2] add cassandra e2e integration tests #5398

Merged
merged 20 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci-cassandra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
jaeger-version: [v1, v2]
version:
- distribution: cassandra
major: 3.x
Expand All @@ -29,7 +30,7 @@ jobs:
major: 4.x
image: 4.0
schema: v004
name: ${{ matrix.version.distribution }} ${{ matrix.version.major }}
name: ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.jaeger-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
Expand All @@ -43,7 +44,7 @@ jobs:
go-version: 1.22.x

- name: Run cassandra integration tests
run: bash scripts/cassandra-integration-test.sh ${{ matrix.version.image }} ${{ matrix.version.schema }}
run: bash scripts/cassandra-integration-test.sh ${{ matrix.version.image }} ${{ matrix.version.schema }} ${{ matrix.jaeger-version }}
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

- name: Setup CODECOV_TOKEN
uses: ./.github/actions/setup-codecov
Expand All @@ -53,6 +54,6 @@ jobs:
with:
file: cover.out
verbose: true
flags: cassandra-${{ matrix.version.major }}
flags: cassandra-${{ matrix.version.major }}-${{ matrix.jaeger-version }}
fail_ci_if_error: true
token: ${{ env.CODECOV_TOKEN }}
8 changes: 6 additions & 2 deletions cmd/jaeger/config-cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ extensions:
cassandra_main:
servers: 127.0.0.1
port: 9042
keyspace: "jaeger_v1_dc1"
connections_per_host: 2
cassandra_archive:
servers: 127.0.0.1
port: 9042
keyspace: "jaeger_v1_dc1"
connections_per_host: 2
receivers:
otlp:
protocols:
grpc:
http:

jaeger:
protocols:
grpc:
Expand All @@ -38,4 +42,4 @@ processors:

exporters:
jaeger_storage_exporter:
trace_storage: cassandra_main
trace_storage: cassandra_main
38 changes: 38 additions & 0 deletions cmd/jaeger/internal/integration/cassandra_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package integration

import (
"testing"

"github.com/jaegertracing/jaeger/plugin/storage/integration"
)

func TestCassandraStorage(t *testing.T) {
integration.SkipUnlessEnv(t, "cassandra")
s := &E2EStorageIntegration{
ConfigFile: "../../config-cassandra.yaml",
StorageIntegration: integration.StorageIntegration{
CleanUp: cleanUp,
GetDependenciesReturnsSource: true,
SkipArchiveTest: true,

SkipList: []string{
"Tags_+_Operation_name_+_Duration_range",
"Tags_+_Duration_range",
"Tags_+_Operation_name_+_max_Duration",
"Tags_+_max_Duration",
"Operation_name_+_Duration_range",
"Duration_range",
"max_Duration",
"Multiple_Traces",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest defining this as a constant (CassandraSkippedTests) in v1 tests and reusing here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added it in the integration.go

},
}
s.e2eInitialize(t)
t.Cleanup(func() {
s.e2eCleanUp(t)
})
s.RunSpanStoreTests(t)
}
12 changes: 6 additions & 6 deletions pkg/cassandra/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ import (
// Configuration describes the configuration properties needed to connect to a Cassandra cluster
type Configuration struct {
Servers []string `valid:"required,url" mapstructure:"servers"`
Keyspace string `valid:"nonzero" mapstructure:"keyspace"`
Keyspace string `mapstructure:"keyspace"`
LocalDC string `mapstructure:"local_dc"`
ConnectionsPerHost int `valid:"min=1" mapstructure:"connections_per_host"`
Timeout time.Duration `valid:"min=500" mapstructure:"-"`
ConnectionsPerHost int `mapstructure:"connections_per_host"`
Timeout time.Duration `mapstructure:"-"`
ConnectTimeout time.Duration `mapstructure:"connection_timeout"`
ReconnectInterval time.Duration `valid:"min=500" mapstructure:"reconnect_interval"`
SocketKeepAlive time.Duration `valid:"min=0" mapstructure:"socket_keep_alive"`
MaxRetryAttempts int `valid:"min=0" mapstructure:"max_retry_attempts"`
ReconnectInterval time.Duration `mapstructure:"reconnect_interval"`
SocketKeepAlive time.Duration `mapstructure:"socket_keep_alive"`
MaxRetryAttempts int `mapstructure:"max_retry_attempts"`
ProtoVersion int `mapstructure:"proto_version"`
Consistency string `mapstructure:"consistency"`
DisableCompression bool `mapstructure:"disable_compression"`
Expand Down
5 changes: 5 additions & 0 deletions plugin/storage/cassandra/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ storage.Purger = (*Factory)(nil)
_ storage.ArchiveFactory = (*Factory)(nil)
_ storage.SamplingStoreFactory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
Expand Down Expand Up @@ -251,3 +252,7 @@
func (f *Factory) PrimarySession() cassandra.Session {
return f.primarySession
}

func (f *Factory) Purge() error {
return f.primarySession.Query("TRUNCATE traces").Exec()

Check warning on line 257 in plugin/storage/cassandra/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/cassandra/factory.go#L256-L257

Added lines #L256 - L257 were not covered by tests
akagami-harsh marked this conversation as resolved.
Show resolved Hide resolved
}
19 changes: 14 additions & 5 deletions scripts/cassandra-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ usage() {
}

check_arg() {
if [ ! $# -eq 2 ]; then
echo "ERROR: need exactly two arguments, <cassandra_version> <schema_version>"
if [ ! $# -eq 3 ]; then
echo "ERROR: need exactly three arguments, <cassandra_version> <schema_version> <jaeger_version>"
usage
fi
}
Expand Down Expand Up @@ -52,11 +52,20 @@ apply_schema() {
run_integration_test() {
local version=$1
local schema_version=$2
local jaegerVersion=$3
local cid
cid=$(setup_cassandra "${version}")
apply_schema "$2"
STORAGE=cassandra make storage-integration-test
exit_status=$?
if [ "${jaegerVersion}" = "v1" ]; then
STORAGE=cassandra make storage-integration-test
exit_status=$?
elif [ "${jaegerVersion}" == "v2" ]; then
STORAGE=cassandra make jaeger-v2-storage-integration-test
exit_status=$?
else
echo "Unknown jaeger version $jaegerVersion. Valid options are v1 or v2"
exit 1
fi
# shellcheck disable=SC2064
trap "teardown_cassandra ${cid}" EXIT
}
Expand All @@ -65,7 +74,7 @@ main() {
check_arg "$@"

echo "Executing integration test for $1 with schema $2.cql.tmpl"
run_integration_test "$1" "$2"
run_integration_test "$1" "$2" "$3"
}

main "$@"
Loading