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

LOG-5030: functional tests for testing log forwarding to Azure Monitor Log #2334

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

vparfonov
Copy link
Contributor

@vparfonov vparfonov commented Feb 2, 2024

Signed-off-by: Vitalii Parfonov vparfono@redhat.com

Description

This pull request addresses adding functional tests for testing log forwarding to Azure Monitor Log.

Changes:

  • Implemented functional tests using Mockoon, a mocking API tool for describing environments via JSON files.
  • Mockoon has capabilities to define rules for checking HTTP requests and sending responses accordingly.
  • Proposed rules to validate the log-type header and body fields in each record (message and log_type) to ensure that log records are properly formatted, e.g.:
"rules": [
            {
              "target": "header",
              "modifier": "log-type",
              "value": "myLogType",
              "invert": false,
              "operator": "equals"
            },
            {
              "target": "body",
              "modifier": "$.[0].message",
              "value": "This is my test message",
              "invert": false,
              "operator": "equals"
            },
            {
              "target": "body",
              "modifier": "$.[0].log_type",
              "value": "application",
              "invert": false,
              "operator": "equals"
            }
          ],
  • Set up a mocking environment within a Pod and made it available via a Route to emulate the original API URI format
  • Emulate the original API URI format (https://<CustomerId>.<Host>/api/logs?api-version=2016-04-01), including the <CustomerID> and <Host> components, to accurately replicate the production environment

/cc
/assign

/cherry-pick

Links

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 2, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 2, 2024

@vparfonov: This pull request references LOG-4606 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the spike to target either version "4.8." or "openshift-4.8.", but it targets "Logging 5.9.0" instead.

In response to this:

Signed-off-by: Vitalii Parfonov vparfono@redhat.com

Description

This pull request addresses adding functional tests for testing log forwarding to Azure Monitor Log.

Changes:

  • Implemented functional tests using Mockoon, a tool for describing environments via JSON files.
  • Mockoon has capabilities to define rules for checking HTTP requests and sending responses accordingly.
  • Proposed rules to validate the log-type header and body fields in each record (message and log_type) to ensure that log records are properly formatted, e.g.:
"rules": [
           {
             "target": "header",
             "modifier": "log-type",
             "value": "myLogType",
             "invert": false,
             "operator": "equals"
           },
           {
             "target": "body",
             "modifier": "$.[0].message",
             "value": "This is my test message",
             "invert": false,
             "operator": "equals"
           },
           {
             "target": "body",
             "modifier": "$.[0].log_type",
             "value": "application",
             "invert": false,
             "operator": "equals"
           }
         ],
  • Set up a mocking environment within a Pod and made it available via a Route to emulate the original API URI format
  • Emulate the original API URI format (https://<CustomerId>.<Host>/api/logs?api-version=2016-04-01), including the <CustomerID> and <Host> components, to accurately replicate the production environment

/cc
/assign

/cherry-pick

Links

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 2, 2024
Copy link
Contributor

openshift-ci bot commented Feb 2, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 2, 2024
@vparfonov
Copy link
Contributor Author

/assign @jcantrill

@vparfonov vparfonov changed the title LOG-4606: Forwarding logs to the Azure Monitor Logs LOG-4606: functional tests for testing log forwarding to Azure Monitor Log Feb 2, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 2, 2024

@vparfonov: This pull request references LOG-4606 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the spike to target either version "4.8." or "openshift-4.8.", but it targets "Logging 5.9.0" instead.

In response to this:

Signed-off-by: Vitalii Parfonov vparfono@redhat.com

Description

This pull request addresses adding functional tests for testing log forwarding to Azure Monitor Log.

Changes:

  • Implemented functional tests using Mockoon, a mocking API tool for describing environments via JSON files.
  • Mockoon has capabilities to define rules for checking HTTP requests and sending responses accordingly.
  • Proposed rules to validate the log-type header and body fields in each record (message and log_type) to ensure that log records are properly formatted, e.g.:
"rules": [
           {
             "target": "header",
             "modifier": "log-type",
             "value": "myLogType",
             "invert": false,
             "operator": "equals"
           },
           {
             "target": "body",
             "modifier": "$.[0].message",
             "value": "This is my test message",
             "invert": false,
             "operator": "equals"
           },
           {
             "target": "body",
             "modifier": "$.[0].log_type",
             "value": "application",
             "invert": false,
             "operator": "equals"
           }
         ],
  • Set up a mocking environment within a Pod and made it available via a Route to emulate the original API URI format
  • Emulate the original API URI format (https://<CustomerId>.<Host>/api/logs?api-version=2016-04-01), including the <CustomerID> and <Host> components, to accurately replicate the production environment

/cc
/assign

/cherry-pick

Links

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 8, 2024
@vparfonov vparfonov force-pushed the log5030 branch 5 times, most recently from ee5a3a3 to 70f5f42 Compare February 8, 2024 12:32
@vparfonov vparfonov marked this pull request as ready for review February 8, 2024 12:32
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 8, 2024
@vparfonov vparfonov changed the title LOG-4606: functional tests for testing log forwarding to Azure Monitor Log LOG-5030: functional tests for testing log forwarding to Azure Monitor Log Feb 8, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 8, 2024

@vparfonov: This pull request references LOG-5030 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.8.0" version, but no target version was set.

In response to this:

Signed-off-by: Vitalii Parfonov vparfono@redhat.com

Description

This pull request addresses adding functional tests for testing log forwarding to Azure Monitor Log.

Changes:

  • Implemented functional tests using Mockoon, a mocking API tool for describing environments via JSON files.
  • Mockoon has capabilities to define rules for checking HTTP requests and sending responses accordingly.
  • Proposed rules to validate the log-type header and body fields in each record (message and log_type) to ensure that log records are properly formatted, e.g.:
"rules": [
           {
             "target": "header",
             "modifier": "log-type",
             "value": "myLogType",
             "invert": false,
             "operator": "equals"
           },
           {
             "target": "body",
             "modifier": "$.[0].message",
             "value": "This is my test message",
             "invert": false,
             "operator": "equals"
           },
           {
             "target": "body",
             "modifier": "$.[0].log_type",
             "value": "application",
             "invert": false,
             "operator": "equals"
           }
         ],
  • Set up a mocking environment within a Pod and made it available via a Route to emulate the original API URI format
  • Emulate the original API URI format (https://<CustomerId>.<Host>/api/logs?api-version=2016-04-01), including the <CustomerID> and <Host> components, to accurately replicate the production environment

/cc
/assign

/cherry-pick

Links

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@vparfonov
Copy link
Contributor Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 8, 2024
@vparfonov
Copy link
Contributor Author

/test functional

1 similar comment
@vparfonov
Copy link
Contributor Author

/test functional

@vparfonov
Copy link
Contributor Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 12, 2024
BeforeEach(func() {
framework = functional.NewCollectorFunctionalFrameworkUsingCollector(logging.LogCollectionTypeVector)
// Start mockServer server
mockServer = azuremonitor.NewMockServer(framework.Namespace, azuremonitor.Mockoon)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can this test not rely upon the output container being added to the pod of the functional test? It is just a container and there are benefits to all the containers running in the same pod. If we really can not us the functional framework we should move this test to rely upon the e2e framework but I suspect its possible with the functional one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is: i need to know public URL of Route, before deploy collector, that's why i did it in this way.
See my comment here: forward_to_azuremonitor_test.go#L43.
I will try to find way how do it in one pod

@jcantrill

Copy link
Contributor

Choose a reason for hiding this comment

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

We do we need a public URL? I thought there was a place to set the host? Can we not craft the URL from "localhost" and a port?

Copy link
Contributor

@jcantrill jcantrill Feb 13, 2024

Choose a reason for hiding this comment

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

Another thing we could do is to modify the framework to mount the /etc/host file into the collector container using either an emptydir or maybe a configmap. This would provide a way to resolve a name without needing a route

Copy link
Contributor Author

@vparfonov vparfonov Feb 14, 2024

Choose a reason for hiding this comment

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

Maybe we can do something with /etc/host, at the end URL must have format: https://some-id.host/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

merged to one pod

var AzureHttpDataCollectorApi string

const (
image = "mockoon/cli:latest"
Copy link
Contributor

Choose a reason for hiding this comment

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

lets tag a version of this and push it to quay.io/openshift-logging so we can ensure it will not change from under us

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 16, 2024
@vparfonov
Copy link
Contributor Author

/test functional
/test functional-target

@vparfonov vparfonov marked this pull request as ready for review February 16, 2024 17:20
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 16, 2024
@vparfonov
Copy link
Contributor Author

/test functional
/test functional-target

1 similar comment
@vparfonov
Copy link
Contributor Author

/test functional
/test functional-target

@vparfonov
Copy link
Contributor Author

/test e2e-ocp-target-minus-one
/test functional
/test functional-target

Copy link
Contributor

@jcantrill jcantrill left a comment

Choose a reason for hiding this comment

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

This is much closer to what I would expect. Good work

Expect(strings.Count(collectorLog, failedReason)).To(BeEquivalentTo(0))

//read log from mock server container and validate it
mockoonLogs := readLogFromMockoon(framework)
Copy link
Contributor

Choose a reason for hiding this comment

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

My statement of "filter" was more in the direction of we control what we return from the "read" function. Within that function we can return only the bits that are of interest to us. The following lines already do some of this logic by separating receiver logs from the logs we are interested.

@vparfonov
Copy link
Contributor Author

/test lint

@vparfonov
Copy link
Contributor Author

/retest all

Copy link
Contributor

openshift-ci bot commented Feb 21, 2024

@vparfonov: The /retest command does not accept any targets.
The following commands are available to trigger required jobs:

  • /test ci-index-cluster-logging-operator-bundle
  • /test e2e-target
  • /test functional-target
  • /test images
  • /test lint
  • /test unit

The following commands are available to trigger optional jobs:

  • /test e2e-ocp-target-minus-one
  • /test e2e-ocp-target-minus-two
  • /test functional

Use /test all to run all jobs.

In response to this:

/retest all

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@vparfonov
Copy link
Contributor Author

/retest

… Monitor Log

Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
@jcantrill
Copy link
Contributor

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 21, 2024
Copy link
Contributor

openshift-ci bot commented Feb 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jcantrill, vparfonov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 21, 2024
@vparfonov
Copy link
Contributor Author

/test functional

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD e03cbb8 and 2 for PR HEAD df05fff in total

Copy link
Contributor

openshift-ci bot commented Feb 21, 2024

@vparfonov: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 56a5a91 into openshift:master Feb 21, 2024
10 checks passed
@vparfonov vparfonov deleted the log5030 branch February 21, 2024 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. release/5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants