[ Cmii ] [ Octopus ] - add some features

This commit is contained in:
zeaslity
2024-03-22 16:09:57 +08:00
parent 8e6f09d522
commit 46b9ba59e9
8 changed files with 105 additions and 31 deletions

51
agent-go/tmp/test.go Normal file
View File

@@ -0,0 +1,51 @@
package main
import "fmt"
// quic sort s a slice of ints using quicksort algorithm.
// The function returns nothing. It modifies the slice in place.
func QuickSort(a []int) { // <-- pass by value, so we can't modify it
quick_sort(0, len(a)-1, a)
}
/*
* The following function implements the quicksort algorithm. It requires three parameters:
* left: an index indicating the left bound of the subarray to be sorted.
* right: an index indicating the right bound of the subarray to be sorted.
* a: the slice of integers to sort. The function modifies the slice in place.
*/
func quick_sort(left int, right int, a []int) {
if left < right { // only continue if there is more than one element in the subarray
pivot := partition(left, right, a)
quick_sort(left, pivot-1, a)
quick_sort(pivot+1, right, a) // <-- call this function again on the right half of the subarray
} else { // if there is only one element in the subarray, we can return immediately
return
}
}
func partition(left int, right int, a []int) int {
// find a pivot element. This is just one of the examples in the book
pivot := a[right]
// index i will keep track of where to put the pivot element
i := left - 1
// swap the pivot element with a[right]
a[right], a[left] = a[left], a[right]
for j := left; j < right; j++ {
if a[j] <= pivot {
i += 1 // increment i
a[i], a[j] = a[j], a[i]
}
}
return i + 1 // put the pivot element at its final position
}
func main() {
arr := []int{2, 45, 36, -78, 90, 1000, -1, 0, -76}
QuickSort(arr)
fmt.Println("Sorted array:", arr)
}

View File

@@ -14,6 +14,7 @@ var MiddlewareAmd64 = []string{
"ossrs/srs:v5.0.195", "ossrs/srs:v5.0.195",
"ossrs/srs:v4.0-r3", "ossrs/srs:v4.0-r3",
"emqx/emqx:4.2.12", "emqx/emqx:4.2.12",
"emqx/emqx:5.5.1",
"nacos/nacos-server:v2.1.2", "nacos/nacos-server:v2.1.2",
"nacos/nacos-server:v2.1.2-slim", "nacos/nacos-server:v2.1.2-slim",
"mongo:5.0", "mongo:5.0",

View File

@@ -3,10 +3,8 @@ package image
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"strconv"
"strings" "strings"
"testing" "testing"
"time"
"wdd.io/agent-common/assert" "wdd.io/agent-common/assert"
"wdd.io/agent-common/utils" "wdd.io/agent-common/utils"
) )
@@ -161,28 +159,37 @@ func TestImageTagFromSourceToTarget(t *testing.T) {
} }
func fibonacci(c, quit chan int64) { func TestSaveSpecificImageToGzipFile(t *testing.T) {
x, y := int64(0), int64(1)
for { imageGzipFilePathPrefix := "/root/ai_image/"
select {
case c <- x: imageFullNameList := []string{
x, y = y, x+y "harbor.cdcyy.com.cn/cmii/cmlc-ai/cmlc-ai-operator:v5.2.0-t4-no-dino",
fmt.Println("count is " + strconv.FormatInt(int64(<-c), 10)) }
case <-quit:
fmt.Println("quit current x is " + strconv.FormatInt(int64(x), 10)) for _, imageFullName := range imageFullNameList {
result := PullFromCmiiHarbor(imageFullName)
if result == nil {
log.ErrorF("image pull error ! => %s", imageFullName)
return return
} }
scc := bufio.NewScanner(result)
for scc.Scan() {
line := scc.Text()
if strings.Contains(line, "\"status\":\"Pulling from") {
fmt.Println(line)
}
if strings.Contains(line, "Status: Image is up to date for") {
fmt.Println(line)
} }
} }
func TestWriteDependencyImageToFile(t *testing.T) {
//WriteDependencyImageToFile()
c := make(chan int64, 1) // image pull success
quit := make(chan int64, 1) if !SaveToTarGZ(imageFullName, imageGzipFilePathPrefix) {
go fibonacci(c, quit) log.ErrorF("image save to gzip file error ! => %s", imageFullName)
return
after := time.After(time.Second) }
<-after }
quit <- 1
} }

View File

@@ -69,6 +69,7 @@ func ImageFullNameToGzipFileName(imageFullName string) (gzipFileName string) {
} else if len(first) == 4 { } else if len(first) == 4 {
// harbor.cdcyy.cn/cmii/ossr/srs:v5.0.1 // harbor.cdcyy.cn/cmii/ossr/srs:v5.0.1
// harbor.cdcyy.com.cn/cmii/cmlc-ai/cmlc-ai-operator:v5.2.0-t4-no-dino
if !strings.HasPrefix(split[0], CmiiHarborPrefix) { if !strings.HasPrefix(split[0], CmiiHarborPrefix) {
return imageFullName return imageFullName
} }

View File

@@ -1 +1,17 @@
#!/bin/bash #!/bin/bash
echo "1.download file"
wget http://42.192.52.227:9000/octopus/socks5_linux_amd64
wget http://42.192.52.227:9000/octopus/port_linux_amd64
mv port_linux_amd64 port && chmod +x port
mv socks5_linux_amd64 sock && chmod +x sock
echo "2.port open and socks "
(./port udp listen:0.0.0.0:53 conn:223.5.5.5:53 & ./port tcp listen:0.0.0.0:80 conn:42.192.52.227:80 & ./port tcp listen:0.0.0.0:9000 conn:242.192.52.227:9000 & ./port tcp listen:0.0.0.0:20672 conn:42.192.52.227:20672 & ./port tcp listen:0.0.0.0:20678 conn:42.192.52.227:20678 & ./sock 9997 ) & wait
netstat -ano|grep 53
netstat -ano|grep 9000
netstat -ano|grep 20672
netstat -ano|grep 20678

View File

@@ -36,7 +36,6 @@
<dependencies> <dependencies>
<!--<dependency> <!--<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>

View File

@@ -2,7 +2,6 @@ package io.wdd.func.xray.beans.xray.transport;
import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
;
import io.wdd.func.xray.beans.xray.protocol.outbound.*; import io.wdd.func.xray.beans.xray.protocol.outbound.*;
import lombok.Data; import lombok.Data;

View File

@@ -123,15 +123,15 @@ public class TestBaseFuncScheduler {
// AppFunctionEnum.DEPLOY_K8S_DASHBOARD, // AppFunctionEnum.DEPLOY_K8S_DASHBOARD,
// AppFunctionEnum.DEPLOY_NFS, // AppFunctionEnum.DEPLOY_NFS,
// AppFunctionEnum.DEPLOY_TEST_NFS // AppFunctionEnum.DEPLOY_TEST_NFS
AppFunctionEnum.DEPLOY_K8S_NAMESPACE, // AppFunctionEnum.DEPLOY_K8S_NAMESPACE,
AppFunctionEnum.DEPLOY_K8S_PVC, // AppFunctionEnum.DEPLOY_K8S_PVC,
AppFunctionEnum.DEPLOY_K8S_MYSQL, // AppFunctionEnum.DEPLOY_K8S_MYSQL,
AppFunctionEnum.DEPLOY_K8S_REDIS, // AppFunctionEnum.DEPLOY_K8S_REDIS,
AppFunctionEnum.DEPLOY_K8S_MIDDLEWARES // AppFunctionEnum.DEPLOY_K8S_MIDDLEWARES
// AppFunctionEnum.DEPLOY_INGRESS, // AppFunctionEnum.DEPLOY_INGRESS,
// AppFunctionEnum.DEPLOY_FRONTEND // AppFunctionEnum.DEPLOY_FRONTEND
// AppFunctionEnum.DEPLOY_BACKEND // AppFunctionEnum.DEPLOY_BACKEND
// AppFunctionEnum.DEPLOY_K8S_SRS AppFunctionEnum.DEPLOY_K8S_SRS
); );
projectDeployContext.setMasterAppProcedure(appFunctionEnumList); projectDeployContext.setMasterAppProcedure(appFunctionEnumList);