Skip to content

Commit

Permalink
Add NRIA_STAGING to the agent if region is set to Staging (#25)
Browse files Browse the repository at this point in the history
* Add NRIA_STAGING to the agent if region is set to Staging
* Bump up the number of retries
* change new defaults to infra platform needs

Co-authored-by: Juan Manuel Perez <jperezflorez@newrelic.com>
  • Loading branch information
alvarocabanas and kilokang authored Jan 24, 2023
1 parent 065d77a commit d9493ff
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 27 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/push-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,29 @@ on:

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO_VERSION: '1.18'

jobs:
static-analysis:
name: Run all static analysis checks
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: newrelic/newrelic-infra-checkers@v1
- name: Semgrep
uses: returntocorp/semgrep-action@v1
with:
auditOn: push
- uses: actions/setup-go@v2
with:
go-version: ${{env.GO_VERSION}}
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
continue-on-error: ${{ github.event_name != 'pull_request' }}
with:
only-new-issues: true
snyk:
name: Run security checks via snyk
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
Expand All @@ -53,7 +52,7 @@ jobs:

test-nix:
name: Run unit tests on *Nix
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
Expand All @@ -64,6 +63,6 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{env.GO_VERSION}}
go-version-file: go.mod
- name: Unit tests
run: make test
30 changes: 14 additions & 16 deletions .github/workflows/selftest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ jobs:
runs-on: ubuntu-latest
name: Test run the e2e test on powerdns local testdata
steps:
- name: checkout-repository
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v1
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: 1.18
go-version-file: go.mod
- name: Run action for PowerDNS (exporter based)
uses: ./
with:
Expand All @@ -33,12 +31,10 @@ jobs:
runs-on: ubuntu-latest
name: Test run the e2e test on kafka local testdata
steps:
- name: checkout-repository
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v1
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: 1.18
go-version-file: go.mod
- name: Run action for Kafka (sample based)
uses: ./
with:
Expand All @@ -47,21 +43,23 @@ jobs:
api_key: ${{ secrets.API_KEY }}
license_key: ${{ secrets.LICENSE_KEY }}
test_local_k8s:
runs-on: ubuntu-latest
# To be able to use driver=none we have to provide a CRI that kubelet allows.
# Or we do the research to use `ubuntu-latest` or we should keep to an old version of Ubuntu and Kubernetes
# so this test can run using Docker as a CRI.
runs-on: ubuntu-20.04
name: Test run the e2e test on k8s local testdata
steps:
- name: checkout-repository
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v1
uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: 1.18
go-version-file: go.mod
- name: Setup Minikube
uses: manusa/actions-setup-minikube@v2.4.2
with:
minikube version: v1.20.0
kubernetes version: v1.21.4
driver: none # required for nri-kubernetes, as metrics gathered for the host are tested as well
driver: none # required for nri-kubernetes, as metrics gathered for the host are tested as well
- name: Setup Helm
run: |
chmod go-r /home/runner/.kube/config
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ inputs:
retry_seconds:
description: Number of seconds to wait after retrying a test
required: false
default: "30"
default: "60"
retry_attempts:
description: Number of attempts a failed test can be retried
required: false
default: "10"
default: "15"
agent_enabled:
description: Enable the agent execution
required: false
Expand Down
8 changes: 8 additions & 0 deletions internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
dockerCompose = "docker-compose.yml"
defConfigFile = "nri-config.yml"
container = "agent"
regionStaging = "Staging"
)

//go:embed resources/docker-compose.yml
Expand Down Expand Up @@ -69,6 +70,13 @@ func NewAgent(settings e2e.Settings) *agent {
a.ExtraEnvVars = settings.SpecDefinition().AgentExtensions.EnvVars
}

if settings.Region() == regionStaging {
if a.ExtraEnvVars == nil {
a.ExtraEnvVars = map[string]string{}
}
a.ExtraEnvVars["NRIA_STAGING"] = "1"
}

return &a
}

Expand Down
1 change: 1 addition & 0 deletions internal/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAgent_SetUp(t *testing.T) {

settings, err := e2e.NewSettings(
e2e.SettingsWithSpecPath(filepath.Join(specPath, "spec_file.yml")),
e2e.SettingsWithRegion("Staging"),
)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func processCliArgs() (string, string, bool, string, int, int, int, string, logr
verboseMode := flag.Bool(flagVerboseMode, false, "If true the debug level is enabled")
apiKey := flag.String(flagApiKey, "", "New Relic Api Key")
accountID := flag.Int(flagAccountID, 0, "New Relic accountID to be used")
retryAttempts := flag.Int(flagRetryAttempts, 10, "Number of attempts to retry a test")
retrySeconds := flag.Int(flagRetrySecons, 30, "Number of seconds before retrying a test")
retryAttempts := flag.Int(flagRetryAttempts, 15, "Number of attempts to retry a test")
retrySeconds := flag.Int(flagRetrySecons, 60, "Number of seconds before retrying a test")
commitSha := flag.String(flagCommitSha, "", "Current commit sha")
region := flag.String(flagRegion, "", "Current commit sha")
flag.Parse()
Expand Down

0 comments on commit d9493ff

Please sign in to comment.