Skip to content

Commit

Permalink
Merge branch 'master' into issue-templates-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgit committed Jul 14, 2023
2 parents 2a1b42c + 773696a commit 7caa10c
Show file tree
Hide file tree
Showing 34 changed files with 1,209 additions and 346 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence.

* @newrelic/caos
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

^^ Provide a general summary of the issue in the title above. ^^

## Description
Describe the problem you're encountering.
TIP: Do NOT share sensitive information, whether personal, proprietary, or otherwise!

## Expected Behavior
Tell us what you expected to happen.

## [Troubleshooting](https://discuss.newrelic.com/t/troubleshooting-frameworks/108787) or [NR Diag](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/troubleshooting/new-relic-diagnostics) results
Provide any other relevant log data.
TIP: Scrub logs and diagnostic information for sensitive information

## Steps to Reproduce
Please be as specific as possible.
TIP: Link a sample application that demonstrates the issue.

## Your Environment
Include as many relevant details about your environment as possible including the running version of New Relic software and any relevant configurations.

## Additional context
Add any other context about the problem here. For example, relevant community posts or support tickets.

## For Maintainers Only or Hero Triaging this bug
*Suggested Priority (P1,P2,P3,P4,P5):*
*Suggested T-Shirt size (S, M, L, XL, Unknown):*
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Troubleshooting
url: https://github.com/newrelic/nrjmx/blob/master/README.md#support
about: Check out the README for troubleshooting directions
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/story.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Story
about: Issue describing development work to fulfill a feature request
title: ''
labels: ''
assignees: ''
priority: ''
---
### Description
_What's the goal of this unit of work? What is included? What isn't included?_

### Acceptance Criteria
_What tasks need to be accomplished to achieve the goal?_

### Design Consideration/Limitations
_Why is this the route we should take to achieve our goal?_
_What can't be achieved within this story?_

### Dependencies
_Do any other teams or parts of the New Relic product need to be considered?_
_Some common areas: UI, collector, documentation_

### Additional context
_What else should we know about this story that might not fit into the other categories?_

### Estimates
_Please provide initial t-shirt size. S = 1-3 days, M = 3-5 days (1 week), L = 1-2 weeks (1 sprint)_
3 changes: 0 additions & 3 deletions .github/ISSUE_TEMPLATE → .github/ISSUE_TEMPLATE~HEAD
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ _Some common areas: UI, collector, documentation_
### Additional context
_What else should we know about this story that might not fit into the other categories?_

### Estimates
_Please provide initial t-shirt size. S = 1-3 days, M = 3-5 days (1 week), L = 1-2 weeks (1 sprint)_

## For Maintainers Only or Hero Triaging this bug
*Suggested Priority (P1,P2,P3,P4,P5):*
*Suggested T-Shirt size (S, M, L, XL, Unknown):*
13 changes: 6 additions & 7 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ env:
AWS_S3_BUCKET_NAME: "nr-downloads-ohai-staging"
AWS_S3_LOCK_BUCKET_NAME: "onhost-ci-lock-staging"
AWS_REGION: "us-east-1"
GO_VERSION: '1.16.10'

jobs:
unit-test-linux:
Expand All @@ -45,11 +44,11 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}
- uses: actions/checkout@v2
go-version-file: 'gojmx/go.mod'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand All @@ -64,11 +63,11 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}
- uses: actions/checkout@v2
go-version-file: 'gojmx/go.mod'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Security Testing

env:
SNYK_TOKEN: ${{ secrets.CAOS_SNYK_TOKEN }}
DOCKER_HUB_ID: ${{ secrets.OHAI_DOCKER_HUB_ID }}
DOCKER_HUB_PASSWORD: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}

on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths-ignore:
- README.md

jobs:
scan-deps:
name: Run security checks Snyk
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKER_HUB_ID }}
password: ${{ env.DOCKER_HUB_PASSWORD }}
- name: Scan java code for vulnerabilities with Snyk
run: make ci/snyk-test-java

- name: Scan go code for vulnerabilities with Snyk
run: make ci/snyk-test-go

13 changes: 6 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ name: Testing
env:
DOCKER_HUB_ID: ${{ secrets.OHAI_DOCKER_HUB_ID }}
DOCKER_HUB_PASSWORD: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
GO_VERSION: '1.16.10'

on:
push:
Expand Down Expand Up @@ -35,11 +34,11 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}
- uses: actions/checkout@v2
go-version-file: 'gojmx/go.mod'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand All @@ -54,11 +53,11 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}
- uses: actions/checkout@v2
go-version-file: 'gojmx/go.mod'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ For more information about CLAs, please check out Alex Russell’s excellent pos

## Slack

We host a public Slack with a dedicated channel for contributors and maintainers of open source projects hosted by New Relic. If you are contributing to this project, you're welcome to request access to the #oss-contributors channel in the newrelicusers.slack.com workspace. To request access, see https://newrelicusers-signup.herokuapp.com/.
We host a public Slack with a dedicated channel for contributors and maintainers of open source projects hosted by New Relic. If you are contributing to this project, you're welcome to request access to the #oss-contributors channel in the newrelicusers.slack.com workspace. To request access, please use this [link](https://join.slack.com/t/newrelicusers/shared_invite/zt-1ayj69rzm-~go~Eo1whIQGYnu3qi15ng).
2 changes: 1 addition & 1 deletion DEVELOP_V2.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ You can easily spawn the container by running the following commands:

```bash
make go-test-utils
docker run -d -p 7199:7199 -p 4567:4567 test-server
docker rm -f nrjmx-test-server && docker run -d -p 7199:7199 -p 4567:4567 --name="nrjmx-test-server" test-server
```

If you need to configure SSL you can check the gojmx_test.go examples or
Expand Down
19 changes: 19 additions & 0 deletions build/ci.mk
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,22 @@ ci/docker/publish: code-gen-utils
@printf 'Publishing docker image\n'
@($(DOCKER_BIN) push ohaiops/nrjmx-code-generator:$(THRIFT_VERSION))
@($(DOCKER_BIN) push ohaiops/nrjmx-code-generator:latest)

.PHONY: ci/snyk-test-java
ci/snyk-test-java:
@docker run --rm -t \
--name "nrjmx-snyk-test-java" \
-v $(CURDIR):/src/nrjmx \
-w /src/nrjmx \
-e SNYK_TOKEN \
snyk/snyk:maven-3-jdk-11 snyk test --severity-threshold=high

.PHONY: ci/snyk-test-go
ci/snyk-test-go:
@docker run --rm -t \
--name "nrjmx-snyk-test-go" \
-v $(CURDIR):/src/nrjmx \
-w /src/nrjmx/gojmx \
-e SNYK_TOKEN \
-e GOFLAGS="-buildvcs=false" \
snyk/snyk:golang snyk test --severity-threshold=high
2 changes: 1 addition & 1 deletion commons/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04 as builder

ARG THRIFT_VERSION='0.16.0'
ARG THRIFT_VERSION='0.17.0'

ENV TZ=Etc/UCT
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Expand Down
4 changes: 2 additions & 2 deletions gojmx/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/newrelic/nrjmx/gojmx

go 1.18
go 1.20

require (
github.com/apache/thrift v0.16.0
github.com/apache/thrift v0.17.0
github.com/docker/go-connections v0.4.0
github.com/shirou/gopsutil/v3 v3.21.11
github.com/stretchr/testify v1.7.0
Expand Down
6 changes: 6 additions & 0 deletions gojmx/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:C
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY=
github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
github.com/apache/thrift v0.17.0 h1:cMd2aj52n+8VoAtvSvLn4kDC3aZ6IAkBuqWQ2IDu7wo=
github.com/apache/thrift v0.17.0/go.mod h1:OLxhMRJxomX+1I/KUw03qoV3mMz16BwaKI+d4fPBx7Q=
github.com/apache/thrift v0.17.1-0.20220919172347-60655d2de79e h1:gBqbHAi5abw97U8t2e12YLt5oAv3Ne6c0GTjKeqPpBA=
github.com/apache/thrift v0.17.1-0.20220919172347-60655d2de79e/go.mod h1:OLxhMRJxomX+1I/KUw03qoV3mMz16BwaKI+d4fPBx7Q=
github.com/apache/thrift v0.18.1 h1:lNhK/1nqjbwbiOPDBPFJVKxgDEGSepKuTh6OLiXW8kg=
github.com/apache/thrift v0.18.1/go.mod h1:rdQn/dCcDKEWjjylUeueum4vQEjG2v8v2PqriUnbr+I=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
Expand Down
56 changes: 55 additions & 1 deletion gojmx/gojmx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var timeStamp = time.Date(2022, time.January, 1, 01, 23, 45, 0, time.Local).Unix

func init() {
_ = os.Setenv("NR_JMX_TOOL", filepath.Join(testutils.PrjDir, "bin", "nrjmx"))
// _ = os.Setenv("NRIA_NRJMX_DEBUG", "true")
//_ = os.Setenv("NRIA_NRJMX_DEBUG", "true")
}

func Test_Query_Success_LargeAmountOfData(t *testing.T) {
Expand Down Expand Up @@ -194,6 +194,60 @@ func Test_Query_Success(t *testing.T) {
assert.ElementsMatch(t, expected, actual)
}

func Test_Query_Exception_Success(t *testing.T) {
ctx := context.Background()

// GIVEN a JMX Server running inside a container
container, err := testutils.RunJMXServiceContainer(ctx)
require.NoError(t, err)
defer container.Terminate(ctx)

// Populate the JMX Server with mbeans
resp, err := testutils.AddMBeansWithException(ctx, container, map[string]interface{}{
"name": "tomas",
"doubleValue": 1.2,
})

assert.NoError(t, err)
assert.Equal(t, "ok!\n", string(resp))

defer testutils.CleanMBeans(ctx, container)

jmxHost, jmxPort, err := testutils.GetContainerMappedPort(ctx, container, testutils.TestServerJMXPort)
require.NoError(t, err)

// THEN JMX connection can be opened
config := &JMXConfig{
Hostname: jmxHost,
Port: int32(jmxPort.Int()),
RequestTimeoutMs: testutils.DefaultTimeoutMs,
}

client, err := NewClient(ctx).Open(config)
assert.NoError(t, err)
defer assertCloseClientNoError(t, client)

actualMBeans, err := client.QueryMBeanAttributes("test:type=ExceptionalCat,*")
require.NoError(t, err)

// AND Query returns expected data
expected := []*AttributeResponse{
{
Name: "test:type=ExceptionalCat,name=tomas,attr=DoubleValue",

ResponseType: ResponseTypeDouble,
DoubleValue: 1.2,
},
{
Name: "test:type=ExceptionalCat,name=tomas,attr=NotSerializable",
StatusMsg: "can't get attribute, error: 'can't get attribute: NotSerializable for bean: test:type=ExceptionalCat,name=tomas: ', cause: 'error unmarshalling return; nested exception is: \n\tjava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.newrelic.jmx.ExceptionalCat$NotSerializable', stacktrace: ''",
ResponseType: ResponseTypeErr,
},
}

assert.ElementsMatch(t, expected, actualMBeans)
}

func Test_QueryMBean_Success(t *testing.T) {
ctx := context.Background()

Expand Down
2 changes: 1 addition & 1 deletion gojmx/internal/nrprotocol/GoUnusedProtection__.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7caa10c

Please sign in to comment.