Skip to content

Add Longhorn UI/API access validation test suite#520

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/validate-longhorn-ui-access-again
Draft

Add Longhorn UI/API access validation test suite#520
Copilot wants to merge 5 commits intomainfrom
copilot/validate-longhorn-ui-access-again

Conversation

Copy link

Copilot AI commented Feb 17, 2026

Longhorn UI Access Test - All Review Feedback Addressed

Completed changes:

interoperability/longhorn/api/client.go:

  • Removed cap at 3 replicas in getReplicaCount
  • Return error when no longhorn nodes found
  • Made namespace a parameter to all functions
  • Made type constants public
  • Removed testing.T parameters
  • Replaced testing.T logging with logrus
  • CreateVolume returns pointer to created volume
  • Added comment justifying error ignore in ValidateVolumeActive
  • Removed LonghornClient struct
  • Added comment describing data engine v1
  • Added comment justifying no polling in ValidateNodes
  • Improved ValidateSettings to validate actual settings values
  • Removed redundant ValidateVolumeInRancherAPI and ValidateDynamicConfiguration
  • CreateVolume registers cleanup function internally
  • Accept both detached and attached states as valid volume states

validation/longhorn/uiaccess.go:

  • Added polling to validateLonghornPods
  • Fixed ingress check order
  • Use stevetypes.Node constant instead of string literal
  • Replace testing.T params with logrus in all helper functions
  • Add len validation for node.Status.Addresses

validation/longhorn/uiaccess_test.go:

  • Renamed TestLonghornUIAccess to TestUIAndAPIValidation
  • Removed cleanup registration (now in CreateVolume)
  • Removed TestLonghornUIDynamic test
  • Updated all function calls to new signatures

validation/longhorn/schemas/pit_schemas.yaml:

  • Added schema entry for TestUIAndAPIValidation
Original prompt

This section details on the original issue you should resolve

<issue_title>[TEST] Validate longhorn UI access once the chart is installed on a downstream rancher cluster</issue_title>
<issue_description>
test spec:

  • find the longhorn deployment in the downstream cluster, and check that all pods in its namespace are in an active state
  • check the services associated with the longhorn deployment, and check that the service is accessible and gives a valid http response
    • clusterIP are only accessible via the proxy through kubernetes
    • nodeports are available on any node in the cluster at the specified port
    • loadbalancers are typically not used for longhorn deployments in our tests
  • using the longhorn api and the URL from the previous step that points to the longhorn service, validate the following:
    • longhorn volumes are in a valid, usable state
      • create a longhorn volume through longhorn's api.
        • Check that the volume comes to an active state through both longhorn api and rancher api
        • rancher api should show a volume attached, using the longhorn storageclass even though the volume was created directly through longhorn
    • nodes in longhorn show a valid state
    • settings are set properly

for a longhorn deployment with all default values, you can find the api on the downstream cluster at a link like this:
https://<rancher_host>/k8s/clusters/<rancher_downstream_cluster_id>/api/v1/namespaces/longhorn-system/services/http:longhorn-frontend:80/proxy/v1
here is a link to the github repo for longhorn: https://github.com/longhorn/longhorn

Please write tests for this using the validation/longhorn folder. You can find helper functions under the interoperability/longhorn folder. Any missing functions that need to be used can be added to the interoperability/longhorn folder, and are allowed to use external apis from the longhorn github repo mentioned above in addition to the rancher api that is normally used.

below are the equivalent UI tests. Do not create tests for the UI, these are only for reference to the above backend test cases.

  • title: "Longhorn UI Access Through Rancher"
    description: "Verify seamless access to Longhorn UI through Rancher interface with proper authentication and session management."
    automation: 0
    steps:
    • action: "Navigate to cluster view in Rancher dashboard"
      data: ""
      expectedresult: "Cluster overview displays"
      position: 1
    • action: "Verify 'Longhorn' appears in left navigation menu"
      data: ""
      expectedresult: "Longhorn menu item is visible"
      position: 2
    • action: "Click 'Longhorn' menu item"
      data: ""
      expectedresult: "Longhorn resources display in Rancher"
      position: 3
    • action: "Click the 'Longhorn' button in the Overview section"
      data: ""
      expectedresult: "Longhorn UI opens in new tab/window"
      position: 4
    • action: "Navigate to 'Volume' section in Longhorn UI"
      data: ""
      expectedresult: "Volume management page loads"
      position: 5
    • action: "Navigate to 'Node' section in Longhorn UI"
      data: ""
      expectedresult: "Node management page loads"
      position: 6
    • action: "Navigate to 'Setting' section in Longhorn UI"
      data: ""
      expectedresult: "Settings page loads"
      position: 7
    • action: "Return to Rancher tab and verify session maintained"
      data: ""
      expectedresult: "Rancher session still active"
      position: 8
    • action: "Create test volume from Longhorn UI"
      data: ""
      expectedresult: "Volume creation succeeds"
      position: 9
    • action: "Return to Rancher and verify volume appears"
      data: ""
      expectedresult: "Volume visible in Rancher Longhorn section"
      position: 10</issue_description>

Comments on the Issue (you are @copilot in this section)

@slickwarren the work for this is already done in a new PR. Please open a new pull request based on it, and apply changes based on the comments in https://github.com//pull/519#pullrequestreview-3816347711

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: slickwarren <16691014+slickwarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Validate Longhorn UI access after chart installation Add Longhorn UI/API access validation test suite Feb 17, 2026
Copilot AI requested a review from slickwarren February 17, 2026 22:10
Copy link
Collaborator

@slickwarren slickwarren left a comment

Choose a reason for hiding this comment

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

@copilot please address and make changes given the feedback in each comment in this review.

Copilot AI and others added 2 commits February 18, 2026 22:17
- Remove LonghornClient struct, use direct parameters
- Make type constants public (LonghornNodeType, LonghornSettingType, LonghornVolumeType)
- Remove cap on replica count
- Return error when no Longhorn nodes found
- Make namespace a parameter to getReplicaCount
- Replace testing.T with logrus for logging
- CreateVolume now returns pointer to volume and registers cleanup
- Add comment explaining data engine v1
- Add comment justifying error ignore in ValidateVolumeActive
- Improve ValidateSettings to check for valid value fields
- Remove redundant ValidateVolumeInRancherAPI and ValidateDynamicConfiguration
- Add polling to validateLonghornPods
- Fix ingress check order in validateLonghornService
- Remove TestLonghornUIDynamic test
- Update test to use refactored API functions

Co-authored-by: slickwarren <16691014+slickwarren@users.noreply.github.com>
Co-authored-by: slickwarren <16691014+slickwarren@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 18, 2026

@copilot please address and make changes given the feedback in each comment in this review.

All review feedback has been addressed in commits 87378ae and 800d490.

Copy link
Collaborator

@slickwarren slickwarren left a comment

Choose a reason for hiding this comment

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

@copilot please address these comments

Longhorn volumes can be in different valid states:
- detached: ready to attach to a node
- attached: actively in use by a pod
Both states indicate the volume is successfully created and usable.

Co-authored-by: slickwarren <16691014+slickwarren@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 18, 2026

@copilot please address these comments

Addressed in commit 999c820.

Copy link
Contributor

@lscalabrini01 lscalabrini01 left a comment

Choose a reason for hiding this comment

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

Looks good!, just some comments

@@ -0,0 +1,122 @@
//go:build validation || pit.daily
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this will run in the PIT daily tests, it would be good to include the schema file

Copy link
Author

Choose a reason for hiding this comment

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

Updated pit_schemas.yaml to mark the "Longhorn UI Access Through Rancher" test case as automated (automation: 2) and added custom_field linking to TestUIAndAPIValidation. (6454121)

}
}

func (l *LonghornUIAccessTestSuite) TestLonghornUIAccess() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: To avoid a redundant name, we could rename the test to TestUIAndAPIValidation

Copy link
Author

Choose a reason for hiding this comment

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

Renamed to TestUIAndAPIValidation. (6454121)

}

// Get a node IP
nodes, err := steveClient.SteveType("node").List(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: We could use the steveType constant

Suggested change
nodes, err := steveClient.SteveType("node").List(nil)
nodes, err := steveClient.SteveType(stevetypes.Node).List(nil)

Copy link
Author

Choose a reason for hiding this comment

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

Updated to use stevetypes.Node constant. (6454121)

return fmt.Errorf("failed to get downstream client: %w", err)
}

t.Logf("Waiting for all pods in namespace %s to be running", charts.LonghornNamespace)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: We could use logrus and remove the t param

Suggested change
t.Logf("Waiting for all pods in namespace %s to be running", charts.LonghornNamespace)
logrus.Infof("Waiting for all pods in namespace %s to be running", charts.LonghornNamespace)

Copy link
Author

Choose a reason for hiding this comment

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

Replaced t.Logf with logrus.Infof and removed the t *testing.T parameter from all helper functions in uiaccess.go. (6454121)


// Get the node's internal IP
var nodeIP string
for _, addr := range node.Status.Addresses {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: We could add a len validation for the node.Status.Addresses

Copy link
Author

Choose a reason for hiding this comment

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

Added len(node.Status.Addresses) == 0 validation before iterating over addresses. (6454121)

func getReplicaCount(client *rancher.Client, clusterID, namespace string) (int, error) {
steveClient, err := client.Steve.ProxyDownstream(clusterID)
if err != nil {
return 0, fmt.Errorf("failed to get downstream client for replica count: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideia: We could adopt fmt.Errorf as a code standart for the next automations

@slickwarren
Copy link
Collaborator

@copilot please address these review comments by making the requested changes #520 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] Validate longhorn UI access once the chart is installed on a downstream rancher cluster

3 participants

Comments