Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ed87d23
Create terraform tests that install the collector directly
avilevy18 Dec 30, 2024
b010a62
Merge branch 'refs/heads/main' into avilevy-collector-e2e-poc
avilevy18 Jan 28, 2025
fdf8252
Fixing conflicts
avilevy18 Jan 28, 2025
eb41c1b
Update otel config to match upstream change
avilevy18 Feb 13, 2025
d05d754
Fix deprecated address config (#74)
jefferbrecht Aug 7, 2025
111cb1b
Adding COS arm support
avilevy18 Sep 15, 2025
205f3fb
Merge remote-tracking branch 'origin/avilevy-collector-e2e-poc' into …
avilevy18 Sep 15, 2025
3b971f4
bug fix
avilevy18 Sep 15, 2025
fd01572
updating google resource
avilevy18 Sep 15, 2025
cc05ccd
bug fix
avilevy18 Sep 15, 2025
a94495e
change disk type
avilevy18 Sep 15, 2025
dd63fd1
attempt bug fix
avilevy18 Sep 15, 2025
dbf9706
upgrade terraform
avilevy18 Sep 15, 2025
2c26c6e
fixing provider
avilevy18 Sep 16, 2025
1f866f5
changing image family
avilevy18 Sep 16, 2025
fcc6f3a
adjusting timeout
avilevy18 Sep 16, 2025
9c2b884
adding debug to the tests.
avilevy18 Sep 16, 2025
987270c
Adding sleep
avilevy18 Sep 16, 2025
1fa4c13
remove sleep
avilevy18 Sep 17, 2025
d99f031
readd sleep
avilevy18 Sep 17, 2025
786483f
reducing version
avilevy18 Sep 17, 2025
9595b8d
removing arch
avilevy18 Sep 17, 2025
06061fd
Add logging
avilevy18 Sep 17, 2025
129896e
trying startup script
avilevy18 Sep 17, 2025
03a5386
bug fix
avilevy18 Sep 17, 2025
736e529
use a template for the startup script
avilevy18 Sep 17, 2025
a5e96dd
bug fix
avilevy18 Sep 17, 2025
507e6b1
Added timer
avilevy18 Sep 17, 2025
f9d61e2
fix startup_script.sh
avilevy18 Sep 17, 2025
1bfd252
fix startup_script.sh
avilevy18 Sep 17, 2025
96ac727
update startup_script.sh
avilevy18 Sep 18, 2025
5425796
update startup_script.sh
avilevy18 Sep 18, 2025
bd55c46
more testing
avilevy18 Sep 18, 2025
c953c4f
more testing
avilevy18 Sep 18, 2025
7f04bb6
env
avilevy18 Sep 18, 2025
d6a140e
env
avilevy18 Sep 18, 2025
791466d
double dollar
avilevy18 Sep 18, 2025
87adcd3
bug fixes
avilevy18 Sep 18, 2025
9e2bd1d
bug fixes
avilevy18 Sep 18, 2025
b4c914e
bug fixes
avilevy18 Sep 18, 2025
dfad8fb
change config
avilevy18 Sep 18, 2025
4d4f576
revert test
avilevy18 Sep 18, 2025
d726d0d
testing removing env variable for config.
avilevy18 Sep 18, 2025
c8dda88
removing echos
avilevy18 Sep 18, 2025
34eeee6
Clean up
avilevy18 Sep 18, 2025
e7a2421
Clean up part 2
avilevy18 Sep 18, 2025
4c0dc78
Sleep to test manifestlist
avilevy18 Sep 18, 2025
0bb203f
adding explicit arch
avilevy18 Sep 18, 2025
e2b96d2
bug fix
avilevy18 Sep 18, 2025
4710e0f
remove sleep
avilevy18 Sep 18, 2025
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

FROM golang:1.23 AS gobuild
WORKDIR /src
ARG BUILD_TAGS

# cache deps before copying source so that we don't re-download as much
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 go test -tags=e2e -c ./e2etestrunner -o opentelemetry-operations-e2e-testing.test
RUN set -x; if [ "$BUILD_TAGS" = "e2ecollector" ]; then BUILD_DIRECTORY="e2etestrunner-collector"; else BUILD_TAGS="e2e"; BUILD_DIRECTORY="e2etestrunner"; fi; CGO_ENABLED=0 go test -timeout 3600s -tags=$BUILD_TAGS -c "./$BUILD_DIRECTORY" -o opentelemetry-operations-e2e-testing.test

FROM hashicorp/terraform:light as tfbuild

Check warning on line 26 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
COPY tf /src/tf
WORKDIR /src/tf
ENV TF_PLUGIN_CACHE_DIR=/src/tf/terraform-plugin-cache
Expand Down
35 changes: 35 additions & 0 deletions cloudbuild-collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2021 Google LLC
#
# 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.

# Builds a docker image, tagging it as _DOCKER_TAG (substitution must be
# provided) and latest.

steps:
- name: docker
env:
- DOCKER_BUILDKIT=1
args:
- build
- --tag=${_TEST_RUNNER_IMAGE_NAME}:${_DOCKER_TAG}
- --tag=${_TEST_RUNNER_IMAGE_NAME}:latest
- --build-arg=BUILDKIT_INLINE_CACHE=1
- --build-arg=BUILD_TAGS=e2ecollector
- --cache-from=${_TEST_RUNNER_IMAGE_NAME}:latest
- .

images: ["${_TEST_RUNNER_IMAGE_NAME}"]
options:
dynamic_substitutions: true
substitutions:
_TEST_RUNNER_IMAGE_NAME: us-central1-docker.pkg.dev/${PROJECT_ID}/e2e-testing/opentelemetry-operations-e2e-testing
6 changes: 3 additions & 3 deletions cmd/testmatrix/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"bufio"
"context"
"fmt"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util"
"html/template"
"log"
"os"
Expand All @@ -33,7 +34,6 @@ import (
"strings"

"cloud.google.com/go/storage"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/e2etestrunner"
"github.com/alexflint/go-arg"
"golang.org/x/sync/errgroup"
"google.golang.org/api/cloudbuild/v1"
Expand Down Expand Up @@ -88,7 +88,7 @@ This will fetch recent Cloud Build logs to automatically update the statuses in
)

type Args struct {
e2etestrunner.CmdWithProjectId
util.CmdWithProjectId
}

type status string
Expand All @@ -106,7 +106,7 @@ var (
)

func main() {
args := e2etestrunner.Args{}
args := util.Args{}
arg.MustParse(&args)

ctx := context.Background()
Expand Down
86 changes: 86 additions & 0 deletions e2etestrunner-collector/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//go:build e2ecollector

package e2etestrunner_collector

Choose a reason for hiding this comment

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

The folder should be named the same as the package, i.e. the folder should be renamed to e2etestrunner_collector


import (
"context"
"flag"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util/setuptf"
"log"
"math/rand"
"os"
"strings"
"testing"
"time"

"github.com/alexflint/go-arg"
)

var (
args util.Args
resourceType string
)

func TestMain(m *testing.M) {
rand.New(rand.NewSource(time.Now().UnixNano()))

Choose a reason for hiding this comment

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

Are lines 26..57 the same as in e2etestrunner/main_test.go? Maybe those could be factored out somehow rather than doing the hard duplication like this.

p := arg.MustParse(&args)
if p.Subcommand() == nil {
p.Fail("missing command")
}
// Need a logger just for TestMain() before testing.T is available
logger := log.New(os.Stdout, "TestMain: ", log.LstdFlags|log.Lshortfile)
ctx := context.Background()

// Handle special case of just creating persistent resources
if args.ApplyPersistent != nil {
err := setuptf.ApplyPersistentCollector(ctx, args.ProjectID, args.ApplyPersistent.AutoApprove, logger)
if err != nil {
logger.Panic(err)
}
return
}

// hacky but works
os.Args = append([]string{os.Args[0]}, strings.Fields(args.GoTestFlags)...)
flag.Parse()

// handle any complex defaults
if args.TestRunID == "" {
hex, err := util.RandomHex(6)
if err != nil {
logger.Fatalf("error generating random hex string: %v\n", err)
}
args.TestRunID = hex
}

var setupFunc util.SetupCollectorFunc
switch {
case args.GceCollector != nil:
setupFunc = SetupGceCollector
resourceType = "gce_instance"
case args.GkeCollector != nil:
setupFunc = SetupGkeCollector
resourceType = "k8s_container"
case args.GkeOperatorCollector != nil:
setupFunc = SetupGkeOperatorCollector
resourceType = "k8s_container"
case args.CloudRunCollector != nil:
setupFunc = SetupCloudRunCollector
resourceType = "generic_task"
}
cleanup, err := setupFunc(ctx, &args, logger)

defer cleanup()
if err != nil {
logger.Panic(err)
}

// wait for instrumented test server to be healthy
logger.Printf("Waiting for health check on (will timeout after %v)\n", args.HealthCheckTimeout)
time.Sleep(args.HealthCheckTimeout)
// Run tests
logger.Print(util.BeginOutputArt)
m.Run()
logger.Print(util.EndOutputArt)
}
49 changes: 49 additions & 0 deletions e2etestrunner-collector/setupgcecollector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2021 Google LLC
//
// 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
//
// https://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 e2etestrunner_collector

import (
"context"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util/setuptf"
"log"
)

const gceCollectorTfDir string = "tf/gce-collector"

// SetupGceCollector Set up the collector to run in GCE container. Creates a new
// GCE VM resources, and runs the specified container image. The
// returned cleanup function tears down the VM.
func SetupGceCollector(

Choose a reason for hiding this comment

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

Do any of these setup functions differ in any way other than the terraform they are running?

ctx context.Context,
args *util.Args,
logger *log.Logger,
) (util.Cleanup, error) {
_, cleanupTf, err := setuptf.SetupTf(
ctx,
args.ProjectID,
args.TestRunID,
gceCollectorTfDir,
map[string]string{
"image": args.GceCollector.Image,
},
logger,
)
if err != nil {

Choose a reason for hiding this comment

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

44..48 is equivalent to

return cleanupTf, err

This comment applies to all the setups here it looks like

return cleanupTf, err
}

return cleanupTf, err
}
49 changes: 49 additions & 0 deletions e2etestrunner-collector/setupgcloudruncollector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2021 Google LLC
//
// 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
//
// https://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 e2etestrunner_collector

import (
"context"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util/setuptf"
"log"
)

const cloudRunCollectorTfDir string = "tf/cloud-run-collector"

// SetupCloudRunCollector sets up the collector to run in Cloud Run.
// Creates a new service and runs the specified container image as a revision.
// The returned cleanup function tears down everything.
func SetupCloudRunCollector(
ctx context.Context,
args *util.Args,
logger *log.Logger,
) (util.Cleanup, error) {
_, cleanupTf, err := setuptf.SetupTf(
ctx,
args.ProjectID,
args.TestRunID,
cloudRunCollectorTfDir,
map[string]string{
"image": args.CloudRunCollector.Image,
},
logger,
)
if err != nil {
return cleanupTf, err
}

return cleanupTf, err
}
35 changes: 35 additions & 0 deletions e2etestrunner-collector/setupgkecollector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package e2etestrunner_collector

import (
"context"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util/setuptf"
"log"
)

const gkeCollectorTfDir string = "tf/gke-collector"

// SetupGkeCollector Set up the collector to run in GKE.
// Creates a new pod and runs the specified container image in a pod.
// The returned cleanup function tears down the whole cluster.
func SetupGkeCollector(
ctx context.Context,
args *util.Args,
logger *log.Logger,
) (util.Cleanup, error) {
_, cleanupTf, err := setuptf.SetupTf(
ctx,
args.ProjectID,
args.TestRunID,
gkeCollectorTfDir,
map[string]string{
"image": args.GkeCollector.Image,
},
logger,
)
if err != nil {
return cleanupTf, err
}

return cleanupTf, err
}
35 changes: 35 additions & 0 deletions e2etestrunner-collector/setupgkeoperatorcollector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package e2etestrunner_collector

import (
"context"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util"
"github.com/GoogleCloudPlatform/opentelemetry-operations-e2e-testing/util/setuptf"
"log"
)

const gkeOperatorCollectorTfDir string = "tf/gke-operator-collector"

// SetupGkeOperatorCollector Set up the collector to run in GKE.
// Creates a new pod and runs the specified container image in a pod.
// The returned cleanup function tears down the whole cluster.
func SetupGkeOperatorCollector(
ctx context.Context,
args *util.Args,
logger *log.Logger,
) (util.Cleanup, error) {
_, cleanupTf, err := setuptf.SetupTf(
ctx,
args.ProjectID,
args.TestRunID,
gkeOperatorCollectorTfDir,
map[string]string{
"image": args.GkeOperatorCollector.Image,
},
logger,
)
if err != nil {
return cleanupTf, err
}

return cleanupTf, err
}
Loading