Skip to content

Commit 5644ab3

Browse files
committed
Merge branch 'flakeguardRename' of github.com:smartcontractkit/chainlink-testing-framework into flakeguardRename
2 parents fb0a2c5 + 264fd17 commit 5644ab3

File tree

17 files changed

+281
-34
lines changed

17 files changed

+281
-34
lines changed

.github/workflows/parrot-release.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ jobs:
3131
mask-password: 'true'
3232
env:
3333
AWS_REGION: ${{ secrets.AWS_REGION }}
34+
- name: Login to Docker Hub
35+
uses: docker/login-action@v3
36+
with:
37+
username: kalverra
38+
password: ${{ secrets.KALVERRA_DOCKER_PASSWORD }}
3439
- name: Set up Go
3540
uses: actions/setup-go@v5
3641
with:
3742
go-version: stable
43+
cache-dependency-path: ./parrot/go.mod
3844
- name: Goreleaser Release
3945
uses: goreleaser/goreleaser-action@v6
4046
with:
@@ -45,4 +51,6 @@ jobs:
4551
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4652
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
4753
IMAGE_PREFIX: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
48-
IMAGE_TAG: ${{ github.ref_name}}
54+
IMAGE_TAG: ${{ github.ref_name }}
55+
DOCKER_USERNAME: kalverra
56+
DOCKER_PASSWORD: ${{ secrets.KALVERRA_DOCKER_PASSWORD }}

book/src/framework/components/blockchains/solana.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ arm64 f4hrenh9it/solana:latest - used locally
1616
contracts_dir = "."
1717
# optional, in case you need some custom image
1818
# image = "solanalabs/solana:v1.18.26"
19+
# you can add docker cmd params, for example to clone some contracts
20+
docker_cmd_params = ["--clone", "y9MdSjD9Beg9EFaeQGdMpESFWLNdSfZKQKeYLBfmnjJ", "-u", "https://api.mainnet-beta.solana.com"]
21+
1922

2023
# optional
2124
# To deploy a solana program, we can provide a mapping of program name to program id.

framework/.changeset/v0.5.1.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Override solana-test-validator cmd params
2+
- Copy annotator API to use it in tests explicitly for non-k8s stuff

framework/components/blockchain/solana.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func defaultSolana(in *Input) {
4646
func newSolana(in *Input) (*Output, error) {
4747
defaultSolana(in)
4848
ctx := context.Background()
49+
4950
containerName := framework.DefaultTCName("blockchain-node")
5051
// Solana do not allow to set ws port, it just uses --rpc-port=N and sets WS as N+1 automatically
5152
bindPort := fmt.Sprintf("%s/tcp", in.Port)
@@ -89,6 +90,7 @@ func newSolana(in *Input) (*Output, error) {
8990
"--rpc-port", in.Port,
9091
"--mint", in.PublicKey,
9192
}, flags...)
93+
args = append(args, in.DockerCmdParamsOverrides...)
9294

9395
req := testcontainers.ContainerRequest{
9496
AlwaysPullImage: in.PullImage,

framework/grafana/grafana.go

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package framework
2+
3+
import (
4+
"fmt"
5+
"net/url"
6+
"time"
7+
8+
"github.com/go-resty/resty/v2"
9+
)
10+
11+
type Client struct {
12+
resty *resty.Client
13+
}
14+
15+
// NewGrafanaClient initializes a new Grafana client with the specified URL and API key.
16+
func NewGrafanaClient(url, apiKey string) *Client {
17+
return &Client{
18+
resty: resty.New().
19+
SetBaseURL(url).
20+
SetHeader("Authorization", "Bearer "+apiKey),
21+
}
22+
}
23+
24+
type Annotation struct {
25+
ID int64 `json:"id"`
26+
AlertID int64 `json:"alertId"`
27+
DashboardID int64 `json:"dashboardId"`
28+
DashboardUID string `json:"dashboardUID"`
29+
PanelID int64 `json:"panelId"`
30+
PrevState string `json:"prevState"`
31+
NewState string `json:"newState"`
32+
Text string `json:"text"`
33+
Time time.Time `json:"time"`
34+
TimeEnd time.Time `json:"timeEnd"`
35+
Created time.Time `json:"created"`
36+
Updated time.Time `json:"updated"`
37+
Tags []interface{} `json:"tags"`
38+
Data interface{} `json:"data"`
39+
}
40+
41+
type AnnotationsQueryParams struct {
42+
Limit *int
43+
AlertID *int
44+
DashboardID *int
45+
DashboardUID *string
46+
Type *string
47+
From *time.Time
48+
To *time.Time
49+
}
50+
51+
type PostAnnotation struct {
52+
DashboardID *int
53+
PanelID *int
54+
DashboardUID string
55+
Time *time.Time
56+
TimeEnd *time.Time
57+
Tags []string
58+
Text string
59+
}
60+
61+
type PostAnnotationResponse struct {
62+
Message string `json:"message"`
63+
ID int64 `json:"id"`
64+
}
65+
66+
// GetAnnotations retrieves a list of annotations based on specified query parameters.
67+
func (c *Client) GetAnnotations(params AnnotationsQueryParams) ([]Annotation, *resty.Response, error) {
68+
query := make(url.Values)
69+
if params.Limit != nil {
70+
query.Set("limit", fmt.Sprintf("%d", *params.Limit))
71+
}
72+
if params.AlertID != nil {
73+
query.Set("alertId", fmt.Sprintf("%d", *params.AlertID))
74+
}
75+
if params.DashboardID != nil {
76+
query.Set("dashboardId", fmt.Sprintf("%d", *params.DashboardID))
77+
}
78+
if params.DashboardUID != nil {
79+
query.Set("dashboardUID", *params.DashboardUID)
80+
}
81+
if params.Type != nil {
82+
query.Set("type", *params.Type)
83+
}
84+
85+
if (params.From != nil && params.To == nil) || (params.To != nil && params.From == nil) {
86+
return nil, nil, fmt.Errorf("both From and To must be set")
87+
}
88+
89+
if params.From != nil {
90+
query.Set("from", fmt.Sprintf("%d", params.From.UnixMilli()))
91+
}
92+
if params.To != nil {
93+
query.Set("to", fmt.Sprintf("%d", params.To.UnixMilli()))
94+
}
95+
96+
var result []Annotation
97+
r, err := c.resty.R().
98+
SetResult(&result).
99+
SetQueryString(query.Encode()).
100+
Get("/api/annotations")
101+
return result, r, err
102+
}
103+
104+
// PostAnnotation sends a new annotation to a specified dashboard.
105+
func (c *Client) PostAnnotation(annotation PostAnnotation) (PostAnnotationResponse, *resty.Response, error) {
106+
a := map[string]interface{}{
107+
"dashboardUID": annotation.DashboardUID,
108+
"tags": annotation.Tags,
109+
"text": annotation.Text,
110+
}
111+
if annotation.DashboardID != nil {
112+
a["dashboardId"] = *annotation.DashboardID
113+
}
114+
if annotation.PanelID != nil {
115+
a["panelId"] = *annotation.PanelID
116+
}
117+
if annotation.Time != nil {
118+
a["time"] = annotation.Time.UnixMilli()
119+
}
120+
if annotation.TimeEnd != nil {
121+
a["timeEnd"] = annotation.TimeEnd.UnixMilli()
122+
}
123+
var result PostAnnotationResponse
124+
r, err := c.resty.R().
125+
SetBody(a).
126+
SetResult(&result).
127+
Post("/api/annotations")
128+
return result, r, err
129+
}

framework/grafana/grafana_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package framework
2+
3+
import (
4+
"os"
5+
"testing"
6+
"time"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
// TestPostAnnotationIntegration tests the PostAnnotation method against a real Grafana instance.
12+
func TestPostAnnotationIntegration(t *testing.T) {
13+
t.Skip("manual grafana integration test")
14+
grafanaURL := os.Getenv("GRAFANA_URL")
15+
apiKey := os.Getenv("GRAFANA_TOKEN")
16+
if grafanaURL == "" || apiKey == "" {
17+
t.Skip("Skipping integration test: GRAFANA_URL or GRAFANA_API_KEY environment variables not set")
18+
}
19+
client := NewGrafanaClient(grafanaURL, apiKey)
20+
21+
annotation := PostAnnotation{
22+
DashboardUID: "WaspDebug",
23+
Text: "CTFv2 test annotation",
24+
Tags: []string{"tag-1", "tag-2"},
25+
Time: Ptr(time.Now().Add(-1 * time.Minute)),
26+
TimeEnd: Ptr(time.Now()),
27+
}
28+
response, resp, err := client.PostAnnotation(annotation)
29+
assert.NoError(t, err, "PostAnnotation should not return an error")
30+
assert.Equal(t, 200, resp.StatusCode(), "Expected HTTP status code 200")
31+
assert.NotEmpty(t, response.ID, "Annotation ID should not be empty")
32+
assert.NotEmpty(t, response.Message, "Annotation message should not be empty")
33+
}
34+
35+
func Ptr[T any](value T) *T {
36+
return &value
37+
}

parrot/.changeset/v0.4.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Public docker releases for parrot

parrot/.changeset/v0.4.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes release env vars

parrot/.changeset/v0.4.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updates parrot to Go 1.24.0

parrot/.changeset/v0.4.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes dockerhub versioning

0 commit comments

Comments
 (0)