DEV Community

cylon
cylon

Posted on

1 1

H3C HCL与WSL2共存

Background

由于Windows10 开启WSL2后无法和 eNSP 做到兼容,但是 H3C HCL 在版本 HCL_v2.1.2.1 提供了 VirtualBox 6.0.14 作为虚拟化后端,理论上来说可以做到 WSL2 与 HCL 共存。

并且开启了WSL2后并于其他虚拟化平台(VirtualBox, Vmvare)做到兼容的情况下,这种情况大部分禁止套娃(虚拟化下在虚拟化),通过安装虚拟机的方式再安装 eNSP 发现启动不报错,但是很长时间起不来。

Notes [1]:HCL官方给的建议是,对于windows7装的版本为HCL_v2.1.1;对于Windows10 并且开启了 Hype-v 或者 Dokcer-Desktop,推荐使用 HCL_v3.0.1.1

下载地址:HCL Download

安装过程

下载好安装时,直接下一步直至完成即可,VirtualBox已被内嵌至安装包内了。

image

图:HCL安装界面

Notes:如果需要抓包,自行安装Wireshark,安装好后,在HCL设置中配置 wireshark.exe 的路径即可

VirtualBox启用hyper-v支持 [2]

进入VirtualBox安装目录, 确定当前目录下存在VBoxManage.exe文件, 在当前目录打开powershell. 或者你将VBoxManage.exe所在目录加入环境变量, 任意路径下打开powershell.

# 或指定vbox所有虚拟系统开启
./VBoxManage.exe setextradata global "VBoxInternal/NEM/UseRing0Runloop" 0
Enter fullscreen mode Exit fullscreen mode

开启后,HCL所有的设备就工作正常了,这种情况下也不用牺牲WSL2或者Dokcer-Desktop。因为eNSP官方没有再更新,导致hype-v与VirtualBox无法兼容,暂时无解。

Reference

[1] H3C Cloud Lab

[2] Windows 10 (2004) 启用wsl2, 并与VirtualBox 6.0+共存

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
xmachli profile image
XMachli

package com.se.tests.sage;

import com.se.utility.Common;
import io.restassured.http.ContentType;
import io.restassured.path.json.JsonPath;
import org.json.simple.JSONObject;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.notNullValue;

public class SageTests {

private String idmsA3Token = "";
private String questionAnswerPairId = "";
private final String SagebatchId = "QA-Batch_1" + LocalDate.now().format(DateTimeFormatter.ofPattern("dd-MM-YY"));

@BeforeMethod
public void getIDMSA3Token() {

    // Create request body for token generation
    JSONObject body = new JSONObject();
    body.put("appId", Common.HEADER_APP_ID);
    body.put("appPassword", Common.HEADER_APP_PASSWORD);
    body.put("otherApp", "135942");
    body.put("context", Common.HEADER_CONTEXT_FEEDBACKENGINE);
    body.put("contextVersion", "1");
    body.put("oneTimeToken", false);

    // Logging the request body for debugging
    System.out.println("Request Body for Token Generation: " + body.toJSONString());

    // Make POST request to get token
    JsonPath jsonPath = given()
        .headers("Content-Type", "application/json")
        .contentType("application/json")
        .accept(ContentType.JSON)
        .body(body.toJSONString())
        .post("https://idmsac-uat.corp.apple.com/auth/apptoapp/token/generate")
        .then()
        .log().all() // Log the full response for debugging
        .statusCode(200) // Expecting 200 status
        .body(notNullValue())
        .extract()
        .jsonPath();

    // Check if the token is generated
    idmsA3Token = jsonPath.get("token").toString();
    System.out.println("Generated IDMSA3 Token: " + idmsA3Token);
    Assert.assertNotNull(idmsA3Token, "Token was not generated successfully!");
}

@Test
public void verify1CreateSage() {

    // Log token to ensure it's being passed correctly
    System.out.println("Token used for Sage creation: " + idmsA3Token);

    // Get initial Sage count
    JsonPath jsonPath = getAllSages();
    int sageCount = jsonPath.getList("$").size();

    // Set headers for the request
    JSONObject headers = new JSONObject();
    headers.put("Content-Type", "application/json");
    headers.put("X_APPID", Common.HEADER_APP_ID);
    headers.put("X-Apple-Client-App-ID", Common.HEADER_APP_ID);
    headers.put("X-Apple-Client-App-Name", Common.HEADER_CONTEXT_SUPPORTENGINE);
    headers.put("X-Apple-IDMS-A3-Token", idmsA3Token); // Pass token in headers

    // Prepare the body of the request
    JSONObject body = new JSONObject();
    JSONObject generation = new JSONObject();
    JSONObject tags = new JSONObject();
    generation.put("model", "gemini");
    tags.put("generation", generation);
    body.put("tags", tags);
    body.put("batchId", SagebatchId); // Ensure this matches the generated format
    body.put("question", "How to improve battery life of Iphone");
    body.put("answer", "Battery Life Improvement Answer");
    body.put("articleId", "QA_ArticleID");
    body.put("articleAccess", "Public");

    // Logging the request body and headers for debugging
    System.out.println("Request Body for Sage Creation: " + body.toJSONString());
    System.out.println("Request Headers: " + headers.toJSONString());

    // Send the POST request to create a Sage entry
    jsonPath = given()
        .headers(headers)
        .contentType("application/json")
        .accept(ContentType.JSON)
        .body(body.toJSONString())
        .post(Common.APP_URL + "/api/v1/service/topanswer/pregenerated/summaries")
        .then()
        .log().all() // Log the full response for debugging
        .statusCode(200) // Expecting 200 status
        .body(notNullValue())
        .extract()
        .jsonPath();

    // Debugging: Print the response
    System.out.println(jsonPath.prettify());

    // Retrieve and verify the newly created Sage entry
    jsonPath = getAllSages();
    questionAnswerPairId = jsonPath.get("find { it.batchId == '" + SagebatchId + "' }.questionAnswerPairId");

    System.out.println("questionAnswerPairId: " + questionAnswerPairId);

    // Assert that the number of sages has increased by 1
    Assert.assertEquals(jsonPath.getList("$").size(), sageCount + 1);

    // Check if the batchId is found and not null
    String batchId = jsonPath.getString("find { it.batchId == '" + SagebatchId + "' }.batchId");

    assert batchId != null : "displayName not found.";
    System.out.println("Assert statements passed.");
}

// Mock method for getting all sages (you need to implement the real method)
private JsonPath getAllSages() {
    // This should call the actual API endpoint to retrieve all sages
    return given()
        .headers("Content-Type", "application/json")
        .accept(ContentType.JSON)
        .get(Common.APP_URL + "/api/v1/service/topanswer/pregenerated/summaries")
        .then()
        .statusCode(200)
        .extract()
        .jsonPath();
}
Enter fullscreen mode Exit fullscreen mode

}